Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float4x4 World;
- float4x4 View;
- float4x4 Projection;
- float4 AmbientColor;
- float AmbientIntensity;
- float3 DiffuseDirection;
- float4 DiffuseColor;
- float DiffuseIntensity;
- Texture xTexture;
- Texture bTexture;
- sampler TextureSampler = sampler_state { texture = <xTexture> ; magfilter = LINEAR; minfilter = LINEAR; mipfilter=LINEAR; AddressU = mirror; AddressV = mirror;};
- sampler TextureSampler2 = sampler_state { texture = <bTexture> ; magfilter = LINEAR; minfilter = LINEAR; mipfilter=LINEAR; AddressU = mirror; AddressV = mirror;};
- // TODO: add effect parameters here.
- struct VertexShaderInput
- {
- float4 Position : POSITION0;
- float2 TexCoords1 : TEXCOORD0;
- float2 TexCoords2 : TEXCOORD1;
- float BlendWeight : BLENDWEIGHT0;
- float4 Color : COLOR0;
- // TODO: add input channels such as texture
- // coordinates and vertex colors here.
- };
- struct VertexShaderOutput
- {
- float4 Position : POSITION0;
- float3 Normal : NORMAL0;
- float2 TexCoords1 : TEXCOORD0;
- float2 TexCoords2 : TEXCOORD1;
- float BlendWeight : BLENDWEIGHT0;
- float4 Color : COLOR0;
- // TODO: add vertex shader outputs such as colors and texture
- // coordinates here. These values will automatically be interpolated
- // over the triangle, and provided as input to your pixel shader.
- };
- VertexShaderOutput VertexShaderFunction(VertexShaderInput input, float3 Normal : NORMAL0)
- {
- VertexShaderOutput output;
- float4 worldPosition = mul(input.Position, World);
- float4 viewPosition = mul(worldPosition, View);
- output.Position = mul(viewPosition, Projection);
- output.Normal = normalize(mul(Normal,World));
- output.BlendWeight = input.BlendWeight;
- output.TexCoords1 = input.TexCoords1;
- output.TexCoords2 = input.TexCoords2;
- output.Color = input.Color;
- // TODO: add your vertex shader code here.
- return output;
- }
- float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
- {
- // TODO: add your pixel shader code here.
- float4 norm = float4(input.Normal, 1.0);
- float4 diffuse = saturate(dot(-DiffuseDirection,norm));
- float4 blend = tex2D(TextureSampler2, input.TexCoords2) * input.BlendWeight;
- float4 normtex = tex2D(TextureSampler, input.TexCoords1) * (1 - input.BlendWeight);
- float4 merge = (blend + normtex) / 2;
- return merge * (AmbientColor*AmbientIntensity + DiffuseIntensity*DiffuseColor*diffuse + input.Color);
- // (AmbientColor*AmbientIntensity + DiffuseIntensity*DiffuseColor*diffuse)
- // return float4(1, 0, 0, 1);
- }
- technique Technique1
- {
- pass Pass1
- {
- // TODO: set renderstates here.
- VertexShader = compile vs_3_0 VertexShaderFunction();
- PixelShader = compile ps_3_0 PixelShaderFunction();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement