//#define VARIANCE_SHADOW_MAPPING #define MAX_LIGHT 2 #define MAX_CAU_CASTER 2 #include "illum.hlsl" uniform sampler2D tileTexture : register(s0); uniform sampler2D detailTexture : register(s1); uniform sampler2D bumpMap : register(s2); uniform sampler2D PathMap : register(s3); uniform sampler2D WeightIndexMap : register(s4); uniform sampler2D WeightMap : register(s5); uniform samplerCUBE ShadowMap1Point : register(s6); uniform samplerCUBE ShadowMap2Point : register(s7); uniform float4x4 WorldViewProj; uniform float4x4 World; uniform float4x4 WorldI; uniform float3 wCamPos; uniform float4 wLightPos1; uniform float4 wLightPos2; uniform float4 lightRange1; uniform float4 lightRange2; uniform float lightPower1; uniform float lightPower2; uniform float4 lightColor1; float4 lightColor2 = 0; uniform float4x4 LightView1; uniform float4x4 LightView2; uniform float lightFarPlane1; uniform float lightFarPlane2; uniform float specularity; uniform float4 specularColor; struct MORIA_HALL_BASE_VSOUT { float4 hPos : POSITION; float4 texCoord : TEXCOORD0; float4 texCoord2 : TEXCOORD1; float3 wView : TEXCOORD2; float3 wTangent : TEXCOORD3; float3 wBinormal : TEXCOORD4; float3 wNormal : TEXCOORD5; float3 wPos : TEXCOORD6; }; MORIA_HALL_BASE_VSOUT MoriaHallBase_VS(float4 position :POSITION, float3 normal :NORMAL, float2 texCoord1 : TEXCOORD0, float2 texCoord2 : TEXCOORD1, float2 atlasTex : TEXCOORD2, float3 tangent : TEXCOORD3, uniform float normalCoord, uniform float texture_repeat) { MORIA_HALL_BASE_VSOUT OUT = (MORIA_HALL_BASE_VSOUT) 0; texCoord2.xy *= texture_repeat; OUT.texCoord = float4(texCoord1.xy, texCoord2.xy); if(normalCoord == 0) OUT.texCoord2.xy = texCoord1; else OUT.texCoord2.xy = texCoord2; OUT.texCoord2.zw = atlasTex; OUT.hPos = mul(WorldViewProj, position); OUT.wPos = mul(World, position); OUT.wView = wCamPos - OUT.wPos; OUT.wTangent = normalize(mul(float4(tangent, 1),WorldI)).xyz; OUT.wNormal = normalize(mul(float4(normal, 1),WorldI)).xyz; OUT.wBinormal = cross(OUT.wTangent, OUT.wNormal).xyz; return OUT; } float4 MoriaHallBase_PS(MORIA_HALL_BASE_VSOUT IN):COLOR0 { float4 Color = 0; float3 N = NormalMap(IN.wTangent, IN.wBinormal, IN.wNormal, IN.texCoord2.xy, bumpMap); float dist = length(IN.wView); float3 V = IN.wView / dist; // read textures float4 diffuseColor = tex2D(tileTexture, IN.texCoord.zw) * tex2D(detailTexture, IN.texCoord.xy); //---------------------------------------------------------------------------------------------------------------- //light1 //light dir float3 L; float4 col; float3 lightCPos; float shadow; if( dot(lightRange1, lightRange1) != 0) { L = wLightPos1.xyz - IN.wPos * wLightPos1.w; //illumination col = Illumination(N, L, V, lightColor1 * lightPower1, lightRange1, diffuseColor, specularity, specularColor); //shadowing lightCPos = mul(LightView1, float4(IN.wPos, 1)).xyz; shadow = shadowPoint(ShadowMap1Point, lightCPos, lightFarPlane1); //shadow = 1; Color += col * shadow; //Color = col; } //---------------------------------------------------------------------------------------------------------------- //light2 if( dot(lightRange2, lightRange2) != 0 ) { //light dir L = wLightPos2.xyz - IN.wPos * wLightPos2.w; //illumination col = Illumination(N, L, V, lightColor2 * lightPower2, lightRange2, diffuseColor, specularity, specularColor); //shadowing lightCPos = mul(LightView2, float4(IN.wPos, 1)).xyz; shadow = shadowPoint(ShadowMap2Point, lightCPos, lightFarPlane2); Color += col * shadow; } //do Path Map to gather indirect illumination float4 indirect = PathMapIndirect(PathMap, WeightIndexMap, WeightMap, IN.texCoord2.zw) * 1.2; indirect *= diffuseColor; //Color = Color + indirect*2.0; Color += lightPower1 * diffuseColor * 0.001; //gather caustics for all casters //return diffuseColor; Color.a = dist; return Color; }