source: GTP/trunk/App/Demos/Illum/Ogre/Media/MORIA/MoriaHallBase.hlsl @ 2386

Revision 2386, 4.1 KB checked in by szirmay, 17 years ago (diff)
Line 
1//#define VARIANCE_SHADOW_MAPPING
2
3#define MAX_LIGHT 2
4#define MAX_CAU_CASTER 2
5#define SPOT_ANGLE 2.093
6#define SPOT_FALLOFF 1
7#define SHADOW_COLOR float4(0.3,0.3,0.3,1.0)
8#define SHADOW_BIAS_POINT 0.0001
9#define SHADOW_EPSILON_POINT 0.0001
10
11#include "illum.hlsl"
12
13uniform sampler2D tileTexture : register(s0);
14uniform sampler2D detailTexture : register(s1);
15uniform sampler2D bumpMap : register(s2);
16uniform sampler2D PathMap : register(s3);
17uniform sampler2D WeightIndexMap : register(s4);
18uniform sampler2D WeightMap : register(s5);
19uniform samplerCUBE ShadowMap1Point : register(s6);
20uniform samplerCUBE ShadowMap2Point : register(s7);
21
22uniform float4x4 WorldViewProj;
23uniform float4x4 World;
24uniform float4x4 WorldI;
25
26uniform float3 wCamPos;
27
28uniform float4 wLightPos1;
29uniform float4 wLightPos2;
30uniform float4 lightRange1;
31uniform float4 lightRange2;
32uniform float lightPower1;
33uniform float lightPower2;
34uniform float4 lightColor1;
35uniform float4 lightColor2;
36                                               
37uniform float4x4 LightView1;
38uniform float4x4 LightView2;
39uniform float lightFarPlane1;
40uniform float lightFarPlane2;
41
42uniform float specularity;
43uniform float4 specularColor;
44
45
46struct MORIA_HALL_BASE_VSOUT
47{
48        float4 hPos : POSITION;
49        float4 texCoord           : TEXCOORD0;
50        float4 texCoord2      : TEXCOORD1;
51        float3 wView              : TEXCOORD2;
52        float3 wTangent           : TEXCOORD3;
53        float3 wBinormal          : TEXCOORD4;
54        float3 wNormal            : TEXCOORD5;
55        float3 wPos                       : TEXCOORD6; 
56};
57
58MORIA_HALL_BASE_VSOUT MoriaHallBase_VS(float4 position :POSITION,
59                                                                                float3 normal :NORMAL,
60                                                                                float2 texCoord1 : TEXCOORD0,
61                                                                                float2 texCoord2 : TEXCOORD1,
62                                                                                float2 atlasTex  : TEXCOORD2,
63                                                                                float3 tangent   : TEXCOORD3,
64                                                                                uniform float normalCoord,
65                                                                                uniform float texture_repeat)
66{
67        MORIA_HALL_BASE_VSOUT OUT = (MORIA_HALL_BASE_VSOUT) 0;
68       
69        texCoord2.xy *= texture_repeat;
70        OUT.texCoord = float4(texCoord1.xy, texCoord2.xy);     
71        if(normalCoord == 0)
72                OUT.texCoord2.xy = texCoord1;
73        else
74                OUT.texCoord2.xy = texCoord2;
75       
76        OUT.texCoord2.zw = atlasTex;
77               
78        OUT.hPos = mul(WorldViewProj, position);
79        OUT.wPos = mul(World, position);
80       
81        OUT.wView = wCamPos - OUT.wPos;
82       
83        OUT.wTangent = normalize(mul(float4(tangent, 1),WorldI)).xyz;
84        OUT.wNormal = normalize(mul(float4(normal, 1),WorldI)).xyz;             
85        OUT.wBinormal = cross(OUT.wTangent, OUT.wNormal).xyz;           
86               
87        return OUT;
88}
89
90float4 MoriaHallBase_PS(MORIA_HALL_BASE_VSOUT IN):COLOR0
91{       
92        float4 Color = 0;
93        float3 N = NormalMap(IN.wTangent, IN.wBinormal, IN.wNormal, IN.texCoord2.xy, bumpMap);
94        float3 V = normalize(IN.wView);
95        // read textures
96        float4 diffuseColor = tex2D(tileTexture, IN.texCoord.zw) * tex2D(detailTexture, IN.texCoord.xy);
97       
98//----------------------------------------------------------------------------------------------------------------
99//light1               
100        //light dir
101float3 L;
102float4 col;
103float3 lightCPos;
104float shadow;
105
106if(dot(lightColor1, lightColor1) != 0)
107{
108        L = wLightPos1.xyz - IN.wPos * wLightPos1.w;
109        //illumination
110        col = Illumination(N, L, V, lightColor1 * lightPower1, lightRange1, diffuseColor, specularity, specularColor);
111        //shadowing     
112        lightCPos = mul(LightView1, float4(IN.wPos, 1)).xyz;
113        shadow = shadowPoint(ShadowMap1Point, lightCPos, lightFarPlane1);
114        Color += col * shadow; 
115}
116
117//----------------------------------------------------------------------------------------------------------------
118//light2                       
119/*if(dot(lightColor2, lightColor2) != 0)
120{
121        //light dir
122        L = wLightPos2.xyz - IN.wPos * wLightPos2.w;
123        //illumination
124        col = Illumination(N, L, V, lightColor2 * lightPower2, lightRange2, diffuseColor, specularity, specularColor);
125        //shadowing     
126        lightCPos = mul(LightView2, float4(IN.wPos, 1)).xyz;
127        shadow = shadowPoint(ShadowMap2Point, lightCPos, lightFarPlane2);
128        Color += col * shadow; 
129}*/
130       
131        //do Path Map to gather indirect illumination
132       
133//      float4 indirect = PathMapIndirect(PathMap, WeightIndexMap, WeightMap, IN.texCoord2.zw) * 1.2;
134//      indirect *= diffuseColor;
135//      Color = Color + indirect;
136       
137        //gather caustics for all casters
138        //return diffuseColor;
139        return Color;
140}
Note: See TracBrowser for help on using the repository browser.