[1049] | 1 | struct VertOut
|
---|
| 2 | {
|
---|
| 3 | float4 hPosition :POSITION;
|
---|
| 4 | float2 texCoord :TEXCOORD;
|
---|
| 5 | float3 wPosition :TEXCOORD1;
|
---|
| 6 | float3 wNormal :TEXCOORD2;
|
---|
| 7 | };
|
---|
| 8 |
|
---|
| 9 |
|
---|
| 10 | VertOut deaultVS(float4 position : POSITION,
|
---|
| 11 | float3 normal:NORMAL,
|
---|
| 12 | float2 texCoord : TEXCOORD0,
|
---|
| 13 | uniform float4x4 world_IT,
|
---|
| 14 | uniform float4x4 worldViewProj,
|
---|
| 15 | uniform float4x4 world)
|
---|
| 16 | {
|
---|
| 17 | VertOut OUT;
|
---|
| 18 | OUT.texCoord = texCoord;
|
---|
| 19 | OUT.hPosition = mul(worldViewProj, position);
|
---|
| 20 | OUT.wPosition = mul(world, position).xyz;
|
---|
| 21 | OUT.wNormal = mul( normal, world_IT);
|
---|
| 22 | //OUT.wNormal = normal;
|
---|
| 23 | return OUT;
|
---|
| 24 | }
|
---|
| 25 |
|
---|
| 26 | float4 deaultPS(VertOut IN,
|
---|
| 27 | uniform samplerCUBE CubeMap : register(s1),
|
---|
| 28 | uniform sampler2D Texture : register(s0),
|
---|
| 29 | uniform float3 cubeMapCameraPosition):COLOR
|
---|
| 30 | {
|
---|
| 31 | float4 Color = float4(1,1,1,1);
|
---|
| 32 |
|
---|
| 33 | float3 dir = IN.wPosition - cubeMapCameraPosition;
|
---|
| 34 | float4 shadow = texCUBE(CubeMap, float3(dir.xy,-dir.z) );
|
---|
| 35 |
|
---|
| 36 | Color = tex2D(Texture, IN.texCoord) * (1.0- shadow);
|
---|
| 37 |
|
---|
| 38 | return Color;
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 |
|
---|
| 42 | float4 deault2PS(VertOut IN,
|
---|
| 43 | uniform samplerCUBE CubeMap : register(s0),
|
---|
| 44 | uniform float3 cubeMapCameraPosition,
|
---|
| 45 | uniform float3 lightPosition,
|
---|
| 46 | uniform float3 cameraPos
|
---|
| 47 | ):COLOR
|
---|
| 48 | {
|
---|
| 49 | float4 Color = float4(1,1,1,1);
|
---|
| 50 |
|
---|
| 51 | float3 dir = IN.wPosition - cubeMapCameraPosition;
|
---|
| 52 | float4 shadow = texCUBE(CubeMap, float3(dir.xy,-dir.z) );
|
---|
| 53 |
|
---|
| 54 | IN.wNormal = normalize(IN.wNormal);
|
---|
| 55 | float3 V = normalize(IN.wPosition - cameraPos);
|
---|
| 56 | float3 L = normalize(lightPosition - IN.wPosition);
|
---|
| 57 | float3 H = normalize(L + V);
|
---|
| 58 | float4 lighting = lit(dot(IN.wNormal, L),dot(IN.wNormal, H), 80);
|
---|
| 59 |
|
---|
| 60 |
|
---|
| 61 | Color = (1.0 - shadow ) * lighting.y * float4(0.4, 0.7, 0.6, 1) + lighting.z;
|
---|
| 62 |
|
---|
| 63 | return Color;
|
---|
| 64 | } |
---|