Skip to content
This repository has been archived by the owner on Dec 25, 2023. It is now read-only.

Commit

Permalink
improved specular.
Browse files Browse the repository at this point in the history
  • Loading branch information
allenhux-intel committed Dec 19, 2022
1 parent 5df1a26 commit 7ae351b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/shaders/terrainPS.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,22 @@ float3 evaluateLight(in float3 normal, in float3 pos, in float3 tex)
{
float ambient = 0.1f;

// diffuse
// directional light. from the point toward the light is the opposite direction.
float3 pointToLight = -g_lightDir.xyz;
float diffuse = saturate(dot(pointToLight, normal));
float3 color = max(ambient, diffuse) * g_lightColor.xyz * tex;

// specular
float3 eyeToPoint = normalize(pos - g_eyePos.xyz);
float3 reflected = reflect(eyeToPoint, normal);
float3 reflected = normalize(reflect(eyeToPoint, normal));
float specDot = saturate(dot(reflected, pointToLight));
float specular = pow(specDot, g_specularColor.a);
float3 specular = pow(specDot, g_specularColor.a) * g_specularColor.xyz;

float3 color = max(ambient, diffuse) * g_lightColor.xyz;
color *= tex;
color = pow(color, 1.0f / 1.3f);
// gamma
color = pow(color + specular, 1.0f / 1.5f);
color = saturate(color);

color += (specular * g_specularColor.xyz);

return color;
}

Expand Down

0 comments on commit 7ae351b

Please sign in to comment.