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

Commit

Permalink
separate specular color from texture color.
Browse files Browse the repository at this point in the history
  • Loading branch information
allenhux-intel committed Nov 16, 2022
1 parent 72265aa commit 5c73edf
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/shaders/terrainPS.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ SamplerState g_sampler : register(s0);

//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
float3 evaluateLight(in float3 normal, in float3 pos)
float3 evaluateLight(in float3 normal, in float3 pos, in float3 tex)
{
float ambient = 0.1f;

// directional light. from the point toward the light is the opposite direction.
float3 pointToLight = -g_lightDir.xyz;
float diffuse = saturate(dot(pointToLight, normal));
Expand All @@ -46,11 +48,12 @@ float3 evaluateLight(in float3 normal, in float3 pos)
float specDot = saturate(dot(reflected, pointToLight));
float specular = pow(specDot, g_specularColor.a);

float ambient = 0.1f;

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

color = pow(color, 1.0f / 1.5f);
color += (specular * g_specularColor.xyz);

return color;
}
Expand All @@ -68,7 +71,7 @@ float4 ps(VS_OUT input) : SV_TARGET0

// clamp the streaming texture to the mip level specified in the min mip map
float3 color = g_streamingTexture.Sample(g_sampler, input.tex, 0, mipLevel).rgb;
color *= evaluateLight(input.normal, input.worldPos);
color = evaluateLight(input.normal, input.worldPos, color);

if ((g_visualizeFeedback) && (mipLevel < 16))
{
Expand Down

0 comments on commit 5c73edf

Please sign in to comment.