-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
189 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
//-------------------------------------------------------------------------------------- | ||
// Constant Buffer Variables | ||
//-------------------------------------------------------------------------------------- | ||
cbuffer ConstantBuffer : register( b0 ) | ||
{ | ||
matrix World; | ||
matrix View; | ||
matrix Projection; | ||
float4 vLightDir[2]; | ||
float4 vLightColor[2]; | ||
float4 vOutputColor; | ||
} | ||
|
||
|
||
//-------------------------------------------------------------------------------------- | ||
struct VS_INPUT | ||
{ | ||
float4 Pos : POSITION; | ||
float3 Norm : NORMAL; | ||
}; | ||
|
||
struct PS_INPUT | ||
{ | ||
float4 Pos : SV_POSITION; | ||
float3 Norm : TEXCOORD0; | ||
}; | ||
|
||
|
||
//-------------------------------------------------------------------------------------- | ||
// Vertex Shader | ||
//-------------------------------------------------------------------------------------- | ||
PS_INPUT VS( VS_INPUT input ) | ||
{ | ||
PS_INPUT output = (PS_INPUT)0; | ||
output.Pos = mul( input.Pos, World ); | ||
output.Pos = mul( output.Pos, View ); | ||
output.Pos = mul( output.Pos, Projection ); | ||
output.Norm = mul( float4( input.Norm, 1 ), World ).xyz; | ||
|
||
return output; | ||
} | ||
|
||
|
||
//-------------------------------------------------------------------------------------- | ||
// Pixel Shader | ||
//-------------------------------------------------------------------------------------- | ||
float4 PS( PS_INPUT input) : SV_Target | ||
{ | ||
float4 finalColor = 0; | ||
|
||
//do NdotL lighting for 2 lights | ||
for(int i=0; i<2; i++) | ||
{ | ||
finalColor += saturate( dot( (float3)vLightDir[i],input.Norm) * vLightColor[i] ); | ||
} | ||
finalColor.a = 1; | ||
return finalColor; | ||
} | ||
|
||
|
||
//-------------------------------------------------------------------------------------- | ||
// PSSolid - render a solid color | ||
//-------------------------------------------------------------------------------------- | ||
float4 PSSolid( PS_INPUT input) : SV_Target | ||
{ | ||
return vOutputColor; | ||
} |