Skip to content

Commit

Permalink
Adjusting emissive calculation on main shader
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuaskelly committed Sep 23, 2020
1 parent f4138d5 commit f889b15
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
16 changes: 7 additions & 9 deletions Dungeoneer/assets/shaders/animate.frag
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,15 @@ varying vec2 v_texCoords;
varying float v_fogFactor;
varying float v_eyeDistance;

vec4 tex_Color;

void main() {
vec4 color;
float epsilon = 1.0 / 256.0;

tex_Color = texture2D( u_texture, v_texCoords );
color = v_color * tex_Color;
if(tex_Color.a < 0.01) discard;
vec4 tex_Color = texture2D(u_texture, v_texCoords);
if(tex_Color.a < epsilon) discard;

// Pack emissive into the alpha channel
color += tex_Color * (1.0 - tex_Color.a) * 2.5;
// Alpha channel drives emissive/fullbrite
vec4 fullbrite = tex_Color / (tex_Color.a);
vec4 color = mix(fullbrite, tex_Color * v_color, tex_Color.a);

gl_FragColor = mix(u_FogColor, color, v_fogFactor);
gl_FragColor = mix(u_FogColor, color, v_fogFactor);
}
18 changes: 8 additions & 10 deletions Dungeoneer/assets/shaders/main.frag
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,15 @@ varying vec2 v_texCoords;
varying float v_fogFactor;
varying float v_eyeDistance;

vec4 tex_Color;

void main() {
vec4 color;

tex_Color = texture2D( u_texture, v_texCoords );
color = v_color * tex_Color;
if(tex_Color.a < 0.01) discard;
float epsilon = 1.0 / 256.0;

vec4 tex_Color = texture2D(u_texture, v_texCoords);
if(tex_Color.a < epsilon) discard;

// Pack emissive into the alpha channel
color += tex_Color * (1.0 - tex_Color.a) * 2.5;
// Alpha channel drives emissive/fullbrite
vec4 fullbrite = tex_Color / (tex_Color.a);
vec4 color = mix(fullbrite, tex_Color * v_color, tex_Color.a);

gl_FragColor = mix(u_FogColor, color, v_fogFactor);
gl_FragColor = mix(u_FogColor, color, v_fogFactor);
}

0 comments on commit f889b15

Please sign in to comment.