renormalize world normal in pixel shader

shadows
Evan Hemsley 2020-08-16 11:48:51 -07:00
parent 393b8bcb03
commit f972392544
2 changed files with 8 additions and 8 deletions

Binary file not shown.

View File

@ -25,7 +25,7 @@ BEGIN_CONSTANTS
float3 LightPositions[4] _ps(c4) _cb(c4); float3 LightPositions[4] _ps(c4) _cb(c4);
float3 PositionLightColors[4] _ps(c8) _cb(c8); float3 PositionLightColors[4] _ps(c8) _cb(c8);
float3 LightDirections[4] _ps(c12) _cb(c12); float3 LightDirections[4] _ps(c12) _cb(c12);
float3 DirectionLightColors[4] _ps(c16) _cb(c16); float3 DirectionLightColors[4] _ps(c16) _cb(c16);
float3 EyePosition _ps(c20) _cb(c20); float3 EyePosition _ps(c20) _cb(c20);
@ -57,7 +57,7 @@ struct PixelShaderInput
PixelShaderInput main_vs(VertexShaderInput input) PixelShaderInput main_vs(VertexShaderInput input)
{ {
PixelShaderInput output; PixelShaderInput output;
output.TexCoord = input.TexCoord; output.TexCoord = input.TexCoord;
output.PositionWS = mul(input.Position, World).xyz; output.PositionWS = mul(input.Position, World).xyz;
output.NormalWS = mul(input.Normal, (float3x3)WorldInverseTranspose).xyz; output.NormalWS = mul(input.Normal, (float3x3)WorldInverseTranspose).xyz;
@ -155,14 +155,14 @@ float3 ComputeLight(
} }
float4 ComputeColor( float4 ComputeColor(
float3 worldPosition, float3 worldPosition,
float3 worldNormal, float3 worldNormal,
float3 albedo, float3 albedo,
float metallic, float metallic,
float roughness float roughness
) { ) {
float3 V = normalize(EyePosition - worldPosition); float3 V = normalize(EyePosition - worldPosition);
float3 N = worldNormal; float3 N = normalize(worldNormal);
float3 F0 = float3(0.04, 0.04, 0.04); float3 F0 = float3(0.04, 0.04, 0.04);
F0 = lerp(F0, albedo, metallic); F0 = lerp(F0, albedo, metallic);
@ -204,7 +204,7 @@ float4 None(PixelShaderInput input) : SV_TARGET0
{ {
return ComputeColor( return ComputeColor(
input.PositionWS, input.PositionWS,
input.NormalWS, input.NormalWS,
AlbedoValue, AlbedoValue,
MetallicValue, MetallicValue,
RoughnessValue RoughnessValue