forked from microsoft/Xbox-GDK-Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPixelShader.hlsl
More file actions
24 lines (20 loc) · 925 Bytes
/
Copy pathPixelShader.hlsl
File metadata and controls
24 lines (20 loc) · 925 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "SimpleInstancing.hlsli"
//--------------------------------------------------------------------------------------
// Desc: Pixel Shader main entrypoint.
//--------------------------------------------------------------------------------------
[RootSignature(rootSig)]
float4 main(Interpolants In) : SV_Target
{
float4 colorOut = 0;
// Directional component:
colorOut = saturate(dot(In.Normal, Directional.xyz)) * In.Color * 0.5;
for (uint i = 0; i < c_pointLightCount; ++i)
{
float3 pointDirection = PointPositions[i].xyz - In.WorldPos;
float d = length(pointDirection);
float attenuation = max(0, 1.0f - (dot(pointDirection, pointDirection) / 500));
pointDirection = normalize(pointDirection);
colorOut += saturate(dot(In.Normal, pointDirection)) * In.Color * PointColors[i] * attenuation;
}
return colorOut + ((sign(In.Color.a) * In.Color));
}