Skip to content

Commit

Permalink
sokol: Avoid pow neg warning
Browse files Browse the repository at this point in the history
  • Loading branch information
IonAgorria committed Apr 5, 2024
1 parent ea09870 commit a35d84c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Source/Render/sokol/shaders/normal_texture.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const vec3 gamma_power = vec3(1.0/2.2);
const vec3 ambient_k = vec3(1);

vec4 gamma(vec4 c) {
return vec4(pow(c.xyz, gamma_power), c.w);
return vec4(pow(abs(c.xyz), gamma_power), c.w);
}

vec4 phong(vec3 pos, vec3 nrm, vec3 l, vec3 eye,
Expand All @@ -70,7 +70,7 @@ vec4 phong(vec3 pos, vec3 nrm, vec3 l, vec3 eye,
vec3 r = reflect(-l, n);
float r_dot_v = max(dot(r, v), 0.0);
float diff = n_dot_l;
float spec = pow(r_dot_v, spec_power) * n_dot_l;
float spec = pow(abs(r_dot_v), spec_power) * n_dot_l;
vec3 ambient_v = l_ambient * ambient * ambient_k;
vec3 diffuse_v = l_diffuse * diffuse * diff;
vec3 specular_v = l_specular * specular * spec;
Expand Down

0 comments on commit a35d84c

Please sign in to comment.