Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float4x4 WorldViewProj : WorldViewProjection;
- float4x4 World : World;
- float3 CameraPos : CameraPosition;
- texture m_texture : DIFFUSE;
- sampler texSampler = sampler_state
- {
- Texture = <m_texture>;
- FILTER = MIN_MAG_MIP_LINEAR;
- };
- float4 diffuseColor
- <
- string UIName = "Diffuse Color";
- string UIWidget = "Color";
- > = (1,1,1,1);
- float4 ambientColor
- <
- string UIName = "Ambient Color";
- string UIWidget = "Color";
- > = (1,1,1,1);
- float3 Lamp0Pos : POSITION
- <
- string Object = "DirectionalLight0";
- string UIName = "Directional Light";
- string Space = "World";
- > = (0,0,0);
- float phongExp
- <
- string UIName= "PhongExponent";
- > = (1);
- struct VertexInput
- {
- float4 pos : POSITION;
- float2 uvCor : TEXCOORD0;
- float4 nor : NORMAL;
- };
- struct VertexOutput
- {
- float4 pos : POSITION;
- float2 uvCor : TEXCOORD0;
- float4 lightColor : COLOR0;
- };
- VertexOutput mainVS(VertexInput IN)
- {
- VertexOutput vOUT = (VertexOutput) 0;
- vOUT.pos = mul(float4(IN.pos.xyz, 1.0), WorldViewProj);
- vOUT.uvCor = IN.uvCor;
- float4 worldPos = mul(IN.pos, World);
- float4 worldNor = mul(IN.nor, World);
- //Specular
- float3 reflectedLight = normalize(reflect((Lamp0Pos-worldPos), worldNor));
- float3 viewVec = normalize(CameraPos-worldPos);
- float specIntensity = pow(clamp(dot(reflectedLight, viewVec), 0, 1), phongExp);
- float lightIntensity = max(dot(normalize(Lamp0Pos-worldPos), normalize(worldNor)), 0);
- vOUT.lightColor = lightIntensity * diffuseColor + ambientColor + specIntensity;
- return vOUT;
- }
- float4 mainPS(VertexOutput IN) : COLOR
- {
- return tex2D(texSampler, IN.uvCor) * IN.lightColor;
- }
- technique technique0
- {
- pass p0
- {
- VertexShader = compile vs_3_0 mainVS();
- PixelShader = compile ps_3_0 mainPS();
- }
- }
Add Comment
Please, Sign In to add comment