Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct VertexShaderInput {
- float4 Position : SV_Position;
- float3 Normal : NORMAL;
- float2 TextureCoords: TEXCOORD0;
- };
- struct VertexShaderOutput {
- float4 Position : SV_Position;
- float2 TextureCoords: TEXCOORD0;
- float LightingFactor: TEXCOORD1;
- };
- struct PixelShaderOutput {
- float4 Color : SV_Target;
- };
- cbuffer Parameters {
- float4x4 xView;
- float4x4 xProjection;
- float4x4 xWorld;
- float3 xLightDirection;
- float xAmbient;
- }
- Texture2D dirtTexture;
- SamplerState WrapSampler {
- Filter = MIN_MAG_MIP_LINEAR;
- AddressU = Wrap;
- AddressV = Wrap;
- };
- VertexShaderOutput TexturedVS(VertexShaderInput VSin) {
- VertexShaderOutput Output = (VertexShaderOutput)0;
- float4x4 preViewProjection = mul(xView, xProjection);
- float4x4 preWorldViewProjection = mul(xWorld, preViewProjection);
- Output.Position = mul(VSin.Position, preWorldViewProjection);
- Output.TextureCoords = VSin.TextureCoords;
- float3 Normal = normalize(mul(normalize(VSin.Normal), xWorld));
- Output.LightingFactor = dot(Normal, xLightDirection);
- return Output;
- }
- PixelShaderOutput TexturedPS(VertexShaderOutput PSIn) {
- PixelShaderOutput Output = (PixelShaderOutput)0;
- Output.Color = dirtTexture.Sample(WrapSampler, PSIn.TextureCoords);
- Output.Color.rgb *= saturate(PSIn.LightingFactor) + xAmbient;
- return Output;
- }
- technique Textured {
- pass p0 {
- AlphaBlendEnable = false;
- Profile = fx_4_0;
- PixelShader = TexturedPS;
- VertexShader = TexturedVS;
- GeometryShader = 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement