[1808] | 1 | //
|
---|
| 2 | // Default effect
|
---|
| 3 | // Single texture
|
---|
| 4 | // Copyright (c) 2000 Microsoft Corporation. All rights reserved.
|
---|
| 5 | //
|
---|
| 6 |
|
---|
| 7 | texture Texture0 < string Name = ""; >;
|
---|
| 8 |
|
---|
| 9 | float4 Ambient : Ambient
|
---|
| 10 | <
|
---|
| 11 | string Object = "Geometry";
|
---|
| 12 | > = float4( 0.4f, 0.4f, 0.4f, 1.0f );
|
---|
| 13 |
|
---|
| 14 | float4 Diffuse : Diffuse
|
---|
| 15 | <
|
---|
| 16 | string Object = "Geometry";
|
---|
| 17 | > = float4( 0.6f, 0.6f, 0.6f, 1.0f );
|
---|
| 18 |
|
---|
| 19 | float4 Specular : Specular
|
---|
| 20 | <
|
---|
| 21 | string Object = "Geometry";
|
---|
| 22 | > = float4( 1.0f, 1.0f, 1.0f, 1.0f );
|
---|
| 23 |
|
---|
| 24 | float4 Emissive : Emissive
|
---|
| 25 | <
|
---|
| 26 | string Object = "Geometry";
|
---|
| 27 | > = float4( 0.0f, 0.0f, 0.0f, 1.0f );
|
---|
| 28 |
|
---|
| 29 | float Power : SpecularPower
|
---|
| 30 | <
|
---|
| 31 | string Object = "Geometry";
|
---|
| 32 | > = 4;
|
---|
| 33 |
|
---|
| 34 | float4 g_vLightColor : Diffuse
|
---|
| 35 | <
|
---|
| 36 | string Object = "Light0";
|
---|
| 37 | > = float4( 1.0f, 1.0f, 1.0f, 1.0f );
|
---|
| 38 |
|
---|
| 39 | float4 g_vLightDirection: Direction
|
---|
| 40 | <
|
---|
| 41 | string Object = "Light0";
|
---|
| 42 | > = float4( 0.5f, 0.75f, 1.0f, 1.0f );
|
---|
| 43 |
|
---|
| 44 | float4 g_vCameraPosition : Position
|
---|
| 45 | <
|
---|
| 46 | string Object = "Camera";
|
---|
| 47 | > = float4( 0.0f, 0.0f, 0.0f, 1.0f );
|
---|
| 48 |
|
---|
| 49 | float4x4 g_mWorld : World; // World matrix
|
---|
| 50 | //float4x4 g_mView : View; // View matrix
|
---|
| 51 | //float4x4 g_mProjection : Projection; // Projection matrix
|
---|
| 52 |
|
---|
| 53 | float4x4 g_mWorldViewProjection : WorldViewProjection; // World * View * Projection matrix
|
---|
| 54 |
|
---|
| 55 |
|
---|
| 56 |
|
---|
| 57 | //--------------------------------------------------------------------------------------
|
---|
| 58 | // Texture samplers
|
---|
| 59 | //--------------------------------------------------------------------------------------
|
---|
| 60 | sampler MeshTextureSampler =
|
---|
| 61 | sampler_state
|
---|
| 62 | {
|
---|
| 63 | Texture = <Texture0>;
|
---|
| 64 | MipFilter = LINEAR;
|
---|
| 65 | MinFilter = LINEAR;
|
---|
| 66 | MagFilter = LINEAR;
|
---|
| 67 | };
|
---|
| 68 |
|
---|
| 69 |
|
---|
| 70 | //--------------------------------------------------------------------------------------
|
---|
| 71 | // Name: VS
|
---|
| 72 | // Type: Vertex Shader
|
---|
| 73 | // Desc: Projection transform
|
---|
| 74 | //--------------------------------------------------------------------------------------
|
---|
| 75 | void VS( float4 vPosObj: POSITION,
|
---|
| 76 | float3 vNormalObj: NORMAL,
|
---|
| 77 | float2 vTexCoordIn: TEXCOORD0,
|
---|
| 78 | out float4 vPosProj: POSITION,
|
---|
| 79 | out float4 vColorOut: COLOR0,
|
---|
| 80 | out float2 vTexCoordOut: TEXCOORD0
|
---|
| 81 | )
|
---|
| 82 | {
|
---|
| 83 | // Transform the position into projected space for display and world space for lighting
|
---|
| 84 | vPosProj = mul( vPosObj, g_mWorldViewProjection );
|
---|
| 85 | //PosProj = mul( vPosObj, g_mWorld );
|
---|
| 86 | //vPosProj = mul( vPosProj, g_mView );
|
---|
| 87 | //vPosProj = mul( vPosProj, g_mProjection );
|
---|
| 88 |
|
---|
| 89 |
|
---|
| 90 | // Transform the normal into world space for lighting
|
---|
| 91 | float3 vNormalWorld = mul( vNormalObj, (float3x3)g_mWorld );
|
---|
| 92 |
|
---|
| 93 | // Compute ambient and diffuse lighting
|
---|
| 94 | vColorOut = g_vLightColor * Ambient;
|
---|
| 95 | vColorOut += g_vLightColor * Diffuse * saturate( dot( g_vLightDirection.xyz, vNormalWorld ) );
|
---|
| 96 |
|
---|
| 97 | // Pass the texture coordinate
|
---|
| 98 | vTexCoordOut = vTexCoordIn;
|
---|
| 99 | }
|
---|
| 100 |
|
---|
| 101 |
|
---|
| 102 |
|
---|
| 103 | //--------------------------------------------------------------------------------------
|
---|
| 104 | // Name: PS
|
---|
| 105 | // Type: Pixel Shader
|
---|
| 106 | // Desc: Modulate the texture by the vertex color
|
---|
| 107 | //--------------------------------------------------------------------------------------
|
---|
| 108 | void PS( float4 vColorIn: COLOR0,
|
---|
| 109 | float2 vTexCoord: TEXCOORD0,
|
---|
| 110 | out float4 vColorOut: COLOR0 )
|
---|
| 111 | {
|
---|
| 112 | // Sample and modulate the texture
|
---|
| 113 | //float4 vTexColor = tex2D( MeshTextureSampler, vTexCoord );
|
---|
| 114 | //vColorOut = vColorIn * vTexColor;
|
---|
| 115 | vColorOut = vColorIn;
|
---|
| 116 | }
|
---|
| 117 |
|
---|
| 118 |
|
---|
| 119 | //--------------------------------------------------------------------------------------
|
---|
| 120 | // Techniques
|
---|
| 121 | //--------------------------------------------------------------------------------------
|
---|
| 122 | technique T0
|
---|
| 123 | {
|
---|
| 124 | pass P0
|
---|
| 125 | {
|
---|
| 126 | VertexShader = compile vs_1_1 VS();
|
---|
| 127 | PixelShader = compile ps_1_1 PS();
|
---|
| 128 | }
|
---|
| 129 | }
|
---|