Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define VS_SHADERMODEL vs_4_0_level_9_1
- #define PS_SHADERMODEL ps_4_0_level_9_1
- //-----------------------------------------------------
- matrix World;
- matrix View;
- matrix Projection;
- //-----------------------------------------------------
- struct VertexShaderInput
- {
- float4 Position : SV_POSITION;
- float3 Normal : NORMAL0;
- };
- struct VertexShaderOutput
- {
- float4 Position : SV_POSITION;
- float4 Color : COLOR0;
- };
- //-----------------------------------------------------
- VertexShaderOutput MainVS(in VertexShaderInput input)
- {
- VertexShaderOutput output = (VertexShaderOutput)0;
- float4 worldPosition = mul(input.Position, World);
- float4 viewPosition = mul(worldPosition, View);
- output.Position = mul(viewPosition, Projection);
- float4 N = mul(input.Normal, World); // normal in world space
- float3 L = normalize(float3(0, 1, 0)); // light direction
- float4 diffuse = dot(L, N) * float4(1,1,1,1); // dot * light color
- output.Color = saturate(diffuse);
- return output;
- }
- float4 MainPS(VertexShaderOutput input) : COLOR
- {
- return saturate(input.Color);
- }
- //-----------------------------------------------------
- technique Phong
- {
- pass P0
- {
- VertexShader = compile VS_SHADERMODEL MainVS();
- PixelShader = compile PS_SHADERMODEL MainPS();
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement