Commit a69de679 authored by chili's avatar chili
Browse files

exponential glossiness mapping

parent bfe02273
...@@ -14,8 +14,6 @@ Texture2D spec; ...@@ -14,8 +14,6 @@ Texture2D spec;
SamplerState splr; SamplerState splr;
static const float specularPowerFactor = 100.0f;
float4 main(float3 worldPos : Position, float3 n : Normal, float2 tc : Texcoord) : SV_Target float4 main(float3 worldPos : Position, float3 n : Normal, float2 tc : Texcoord) : SV_Target
{ {
...@@ -33,7 +31,7 @@ float4 main(float3 worldPos : Position, float3 n : Normal, float2 tc : Texcoord) ...@@ -33,7 +31,7 @@ float4 main(float3 worldPos : Position, float3 n : Normal, float2 tc : Texcoord)
// calculate specular intensity based on angle between viewing vector and reflection vector, narrow with power function // calculate specular intensity based on angle between viewing vector and reflection vector, narrow with power function
const float4 specularSample = spec.Sample(splr, tc); const float4 specularSample = spec.Sample(splr, tc);
const float3 specularReflectionColor = specularSample.rgb; const float3 specularReflectionColor = specularSample.rgb;
const float specularPower = specularSample.a * specularPowerFactor; const float specularPower = pow(2.0f, specularSample.a * 13.0f);
const float3 specular = att * (diffuseColor * diffuseIntensity) * pow(max(0.0f, dot(normalize(-r), normalize(worldPos))), specularPower); const float3 specular = att * (diffuseColor * diffuseIntensity) * pow(max(0.0f, dot(normalize(-r), normalize(worldPos))), specularPower);
// final color // final color
return float4(saturate((diffuse + ambient) * tex.Sample(splr, tc).rgb + specular * specularReflectionColor), 1.0f); return float4(saturate((diffuse + ambient) * tex.Sample(splr, tc).rgb + specular * specularReflectionColor), 1.0f);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment