Skip to content

Commit

Permalink
Back to uniform med/high shaders. Allowed more brightness control
Browse files Browse the repository at this point in the history
  • Loading branch information
pkozuchowskiPS committed May 19, 2020
1 parent 47703b3 commit 78a67a0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
15 changes: 11 additions & 4 deletions src/shaders/ShipMaterialP2.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ bool UseNormalMap;
static const float3 lDir = float3(0,0,1);


float3 getLightContribution(float3 Normal)
{
float diffuse = saturate(dot(Normal, lDir));
float3 Reflect = normalize(4.0 * diffuse * Normal - lDir);
float specFac = saturate(dot(Reflect, lDir));
float specular = pow(specFac, SpecularExponent);

return clamp(diffuse + specular, 0.25, 1);
}

float4 pixelMain
(
float2 TexCoords : TEXCOORD0,
Expand Down Expand Up @@ -48,10 +58,7 @@ float4 pixelMain
albedoColor = lerp(albedoColor, tex2D(EnvMapSampler, refCoords), 0.5);
}


float diffuse = clamp(dot(Normal, lDir), 0.25, 1);
float3 finalLightColor = diffuse + (AmbientColor / 4);

float3 finalLightColor = getLightContribution(Normal) + (AmbientColor / 3);
float4 finalColor = saturate(albedoColor * float4(finalLightColor.xyz, 1.0));
finalColor.a = saturate(DiffuseTint.a);

Expand Down
4 changes: 2 additions & 2 deletions src/shaders/ShipMaterialP3.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ float3 getLightContribution(float3 Normal)
{
float diffuse = saturate(dot(Normal, lDir));
float3 Reflect = normalize(4.0 * diffuse * Normal - lDir);
float specFac = clamp(dot(Reflect, lDir),0, 0.97);
float specFac = saturate(dot(Reflect, lDir));
float specular = pow(specFac, SpecularExponent);

return clamp(diffuse + specular, 0.25, 1);
Expand Down Expand Up @@ -58,7 +58,7 @@ float4 pixelMain
albedoColor = lerp(albedoColor, tex2D(EnvMapSampler, refCoords), 0.5);
}

float3 finalLightColor = getLightContribution(Normal) + (AmbientColor / 4);
float3 finalLightColor = getLightContribution(Normal) + (AmbientColor / 3);
float4 finalColor = saturate(albedoColor * float4(finalLightColor.xyz, 1.0));
finalColor.a = saturate(DiffuseTint.a);

Expand Down

0 comments on commit 78a67a0

Please sign in to comment.