Skip to content

Commit

Permalink
Merge pull request #93 from Interrupt/fixes/adjust-emissive-shader
Browse files Browse the repository at this point in the history
Adjusting emissive calculation on main shader
  • Loading branch information
Interrupt authored Sep 24, 2020
2 parents ca611b1 + 89622f0 commit e006725
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 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;
const float c_epsilon = 1.0 / 256.0;

void main() {
vec4 color;
vec4 tex_Color = texture2D(u_texture, v_texCoords);
if(tex_Color.a < c_epsilon) discard;

tex_Color = texture2D( u_texture, v_texCoords );
color = v_color * tex_Color;
if(tex_Color.a < 0.01) discard;
// Alpha channel drives emissive/fullbrite
vec4 fullbrite = tex_Color / (tex_Color.a);
vec4 color = mix(fullbrite, tex_Color * v_color, tex_Color.a);

// Pack emissive into the alpha channel
color += tex_Color * (1.0 - tex_Color.a) * 2.5;

gl_FragColor = mix(u_FogColor, color, v_fogFactor);
gl_FragColor = mix(u_FogColor, color, v_fogFactor);
}
16 changes: 7 additions & 9 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;
const float c_epsilon = 1.0 / 256.0;

void main() {
vec4 color;

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 < c_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 e006725

Please sign in to comment.