Skip to content

Commit

Permalink
reduce alpha value for discard with blend True. Now set <= 0b00000001
Browse files Browse the repository at this point in the history
  • Loading branch information
paddywwoof committed Jan 14, 2021
1 parent 5671bdd commit 87c405a
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions pi3d/Buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,13 @@ def draw(self, shape=None, M=None, unif=None, shader=None,

if texture.blend:
# i.e. if any of the textures set to blend then all will for this shader.
self.unib[2] = 0.05
self.unib[2] = 0.0035 # i.e. alpha byte in image 0b00000001 is 0.00392

if self.unib[2] != 0.6 or shape.unif[16] < 1.0 or shape.unif[17] < 1.0:
#use unib[2] as flag to indicate if any Textures to be blended
#needs to be done outside for..textures so materials can be transparent
opengles.glEnable(GL_BLEND)
self.unib[2] = 0.05
self.unib[2] = 0.0035

self.disp.last_shader = shader

Expand Down
2 changes: 1 addition & 1 deletion pi3d/shaders/2d_flat.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ void main(void) {
coord -= unif[14].xy; // offset
coord *= pix_inv; // really dividing to scale 0-1 i.e. (x/w, y/h)
vec4 texc = texture2D(tex0, coord);
if (texc.a < unib[0][2]) discard; // ------ to allow rendering behind the transparent parts of this object
if (texc.a <= unib[0][2]) discard; // ------ to allow rendering behind the transparent parts of this object
gl_FragColor = texc;
gl_FragColor.a *= unif[5][2];
}
2 changes: 1 addition & 1 deletion pi3d/shaders/shadowcast.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ vec4 pack (float depth)

void main(void) {
vec4 texc = texture2D(tex0, texcoordout); // ------ material or basic colour from texture
if (texc.a < unib[0][2]) discard; // ------ to allow rendering behind the transparent parts of this object
if (texc.a <= unib[0][2]) discard; // ------ to allow rendering behind the transparent parts of this object
float normPosn = position.z / position.w;
normPosn = (normPosn + 1.0) / 2.0;
gl_FragColor = pack(normPosn);
Expand Down
2 changes: 1 addition & 1 deletion pi3d/shaders/std_main_mat.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
// NB previous define: unib, unif, dist

vec4 texc = vec4(unib[1], 1.0); // ------ basic colour from material vector
if (texc.a < unib[0][2]) discard; // ------ to allow rendering behind the transparent parts of this object
if (texc.a <= unib[0][2]) discard; // ------ to allow rendering behind the transparent parts of this object
float ffact = smoothstep(unif[5][0]/3.0, unif[5][0], dist); // ------ smoothly increase fog between 1/3 and full fogdist
2 changes: 1 addition & 1 deletion pi3d/shaders/std_main_uv.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// NB previous define: tex0, texcoordout, unib, unif, dist

vec4 texc = texture2D(tex0, texcoordout); // ------ material or basic colour from texture
if (texc.a < unib[0][2]) discard; // ------ to allow rendering behind the transparent parts of this object
if (texc.a <= unib[0][2]) discard; // ------ to allow rendering behind the transparent parts of this object
if (unif[5][0] < 0.0) {
if (dist > abs(unif[5][0]) || dist <= fract(fog_start) * 100.0) discard; // don't draw
}
Expand Down
2 changes: 1 addition & 1 deletion pi3d/shaders/uv_pointsprite.fs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void main(void) {
if (any(greaterThan(abs(rot_coord), limit))) discard;
rot_coord += p_centre;
vec4 texc = texture2D(tex0, (rot_coord * subsize + corner));
if (texc.a < unib[0][2]) discard; // ------ to allow rendering behind the transparent parts of this object
if (texc.a <= unib[0][2]) discard; // ------ to allow rendering behind the transparent parts of this object
gl_FragColor = colour * texc;
//gl_FragColor.a *= texc.a;
}
2 changes: 1 addition & 1 deletion pi3d/shaders/uv_toon.fs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void main(void) {
float bfact = 1.0 - smoothstep(30.0, 100.0, dist); // ------ attenuate smoothly between 30 and 100 units

float intensity = clamp(dot(lightVector, normalize(vec3(0.0, 0.0, 1.0) + bump * bfact)) * lightFactor, 0.0, 1.0); // ------ adjustment of colour according to combined normal
if (texc.a < unib[0][2]) discard; // ------ to allow rendering behind the transparent parts of this object
if (texc.a <= unib[0][2]) discard; // ------ to allow rendering behind the transparent parts of this object
texc.rgb = (texc.rgb * unif[9]) * intensity + (texc.rgb * unif[10]); // ------ directional lightcol * intensity + ambient lightcol

float d = 5.0;
Expand Down

0 comments on commit 87c405a

Please sign in to comment.