From: <av...@us...> - 2011-06-27 13:03:17
|
Revision: 36574 http://crystal.svn.sourceforge.net/crystal/?rev=36574&view=rev Author: avoicu Date: 2011-06-27 13:03:10 +0000 (Mon, 27 Jun 2011) Log Message: ----------- Created a new structure for OSM (doesn't support multiple lights yet). Modified Paths: -------------- CS/branches/soc2011/selfshadow/data/shader-snippets/lighting/lightfuncs.cginc CS/branches/soc2011/selfshadow/data/shader-snippets/lighting/lighting-tools.inc CS/branches/soc2011/selfshadow/data/shader-snippets/lighting/shadow-osm.cginc CS/branches/soc2011/selfshadow/data/shader-snippets/shadow/shadow-osm.xml Modified: CS/branches/soc2011/selfshadow/data/shader-snippets/lighting/lightfuncs.cginc =================================================================== --- CS/branches/soc2011/selfshadow/data/shader-snippets/lighting/lightfuncs.cginc 2011-06-27 12:24:57 UTC (rev 36573) +++ CS/branches/soc2011/selfshadow/data/shader-snippets/lighting/lightfuncs.cginc 2011-06-27 13:03:10 UTC (rev 36574) @@ -178,13 +178,22 @@ // Shadow map pixel size + dimensions float4 shadowMapPixels[MAX_LIGHTS]; float4 shadowMapUnscale[MAX_LIGHTS]; - float splitDists[MAX_LIGHTS]; - int shadowMapNumSplits; sampler2D shadowMapNoise; }; LightPropertiesShadowMap lightPropsSM; +struct LightPropertiesOpacityMap +{ + // Transformation from light to shadow map space + float4x4 opacityMapTF[MAX_LIGHTS]; + // Shadow map + sampler2D opacityMap[MAX_LIGHTS]; + float splitDists[MAX_LIGHTS]; + int opacityMapNumSplits; +}; +LightPropertiesOpacityMap lightPropsOM; + // Common interface for all light types interface Light { Modified: CS/branches/soc2011/selfshadow/data/shader-snippets/lighting/lighting-tools.inc =================================================================== --- CS/branches/soc2011/selfshadow/data/shader-snippets/lighting/lighting-tools.inc 2011-06-27 12:24:57 UTC (rev 36573) +++ CS/branches/soc2011/selfshadow/data/shader-snippets/lighting/lighting-tools.inc 2011-06-27 13:03:10 UTC (rev 36574) @@ -48,11 +48,16 @@ destination="lightPropsSM.shadowMapPixels" /> <variablemap variable="light shadow map unscale" destination="lightPropsSM.shadowMapUnscale" /> + <?Endtemplate?> + + <?Template Lighting_OpacityMap_Variablemaps?> + <variablemap variable="light shadow map projection" + destination="lightPropsOM.opacityMapTF" /> <variablemap variable="light numSplits" - destination="lightPropsSM.shadowMapNumSplits" /> + destination="lightPropsOM.opacityMapNumSplits" /> <variablemap variable="light splitDists" - destination="lightPropsSM.splitDists" /> - <?Endtemplate?> + destination="lightPropsOM.splitDists" /> + <?Endtemplate?> <?SEndIf?> </include> Modified: CS/branches/soc2011/selfshadow/data/shader-snippets/lighting/shadow-osm.cginc =================================================================== --- CS/branches/soc2011/selfshadow/data/shader-snippets/lighting/shadow-osm.cginc 2011-06-27 12:24:57 UTC (rev 36573) +++ CS/branches/soc2011/selfshadow/data/shader-snippets/lighting/shadow-osm.cginc 2011-06-27 13:03:10 UTC (rev 36574) @@ -41,7 +41,7 @@ float4 view_pos = mul(lightTransformInv, surfPositionWorld); // Transform position in light space into "shadow map space" float4 shadowMapCoords; - shadowMapTF = lightPropsSM.shadowMapTF[lightNum]; + shadowMapTF = lightPropsOM.opacityMapTF[lightNum]; /* CS' render-to-texture Y-flips render targets (so the upper left gets rendered to 0,0), we need to unflip here again. */ float4x4 flipY; @@ -71,7 +71,7 @@ void Init (int lightNum, float4 vp_shadowMapCoords, float vp_gradient) { shadowMapCoords = vp_shadowMapCoords; - shadowMap = lightPropsSM.shadowMap[lightNum]; + shadowMap = lightPropsOM.opacityMap[lightNum]; gradient = vp_gradient; // Project SM coordinates @@ -89,21 +89,21 @@ return 0; if (i == 0) - return tex2D(lightPropsSM.shadowMap[0], position).a; + return tex2D(lightPropsOM.opacityMap[0], position).a; if (i == 1) - return tex2D(lightPropsSM.shadowMap[1], position).a; + return tex2D(lightPropsOM.opacityMap[1], position).a; if (i == 2) - return tex2D(lightPropsSM.shadowMap[2], position).a; + return tex2D(lightPropsOM.opacityMap[2], position).a; if (i == 3) - return tex2D(lightPropsSM.shadowMap[3], position).a; + return tex2D(lightPropsOM.opacityMap[3], position).a; if (i == 4) - return tex2D(lightPropsSM.shadowMap[4], position).a; + return tex2D(lightPropsOM.opacityMap[4], position).a; if (i == 5) - return tex2D(lightPropsSM.shadowMap[5], position).a; + return tex2D(lightPropsOM.opacityMap[5], position).a; if (i == 6) - return tex2D(lightPropsSM.shadowMap[6], position).a; + return tex2D(lightPropsOM.opacityMap[6], position).a; if (i == 7) - return tex2D(lightPropsSM.shadowMap[7], position).a; + return tex2D(lightPropsOM.opacityMap[7], position).a; return 0; } @@ -113,14 +113,14 @@ float3 shadowMapCoordsBiased = (float3(0.5)*shadowMapCoordsProj.xyz) + float3(0.5); half inLight = 1; - int numSplits = lightPropsSM.shadowMapNumSplits; + int numSplits = lightPropsOM.opacityMapNumSplits; float previousSplit = 0, nextSplit; for (int i = 0 ; i <= numSplits ; i ++) { - previousSplit = lightPropsSM.splitDists[i]; - nextSplit = lightPropsSM.splitDists[i + 1]; + previousSplit = lightPropsOM.splitDists[i]; + nextSplit = lightPropsOM.splitDists[i + 1]; if (gradient < nextSplit || i == numSplits) { @@ -130,14 +130,14 @@ flipY[2] = float4 (0, 0, 1, 0); flipY[3] = float4 (0, 0, 0, 1); - float4x4 shadowMapTFPrev = mul (flipY, lightPropsSM.shadowMapTF[i]); + float4x4 shadowMapTFPrev = mul (flipY, lightPropsOM.opacityMapTF[i]); float4 shadowMapCoordsPrev = mul (shadowMapTFPrev, shadowMapCoords); float4 shadowMapCoordsProjPrev = shadowMapCoordsPrev; shadowMapCoordsProjPrev.xyz /= shadowMapCoordsProjPrev.w; float3 shadowMapCoordsBiasedPrev = (float3(0.5)*shadowMapCoordsProjPrev.xyz) + float3(0.5); - float4x4 shadowMapTFNext = mul (flipY, lightPropsSM.shadowMapTF[i + 1]); + float4x4 shadowMapTFNext = mul (flipY, lightPropsOM.opacityMapTF[i + 1]); float4 shadowMapCoordsNext = mul (shadowMapTFNext, shadowMapCoords); float4 shadowMapCoordsProjNext = shadowMapCoordsNext; shadowMapCoordsProjNext.xyz /= shadowMapCoordsProjNext.w; Modified: CS/branches/soc2011/selfshadow/data/shader-snippets/shadow/shadow-osm.xml =================================================================== --- CS/branches/soc2011/selfshadow/data/shader-snippets/shadow/shadow-osm.xml 2011-06-27 12:24:57 UTC (rev 36573) +++ CS/branches/soc2011/selfshadow/data/shader-snippets/shadow/shadow-osm.xml 2011-06-27 13:03:10 UTC (rev 36574) @@ -24,14 +24,14 @@ <?Include /shader-snippets/lighting/lighting-tools.inc ?> <?Generate L 0 7?> - <texture name="light shadow map[$L$]" destination="lightPropsSM.shadowMap[$L$]" + <texture name="light shadow map[$L$]" destination="lightPropsOM.opacityMap[$L$]" comparemode="rToTexture" comparefunc="lequal" /> <?Endgenerate?> <texture name="tex shadow noise" destination="lightPropsSM.shadowMapNoise" /> </block> <block location="cg:variablemap"> - <?Lighting_ShadowMap_Variablemaps?> + <?Lighting_OpacityMap_Variablemaps?> </block> <block location="cg:definitions"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |