// Point light shadow volume extrude void shadowVolumeExtrudePointLight_vp ( float4 position : POSITION, float wcoord : TEXCOORD0, out float4 oPosition : POSITION, uniform float4x4 worldViewProjMatrix, uniform float4 lightPos // homogenous, object space ) { // extrusion in object space // vertex unmodified if w==1, extruded if w==0 float4 newpos = (wcoord.xxxx * lightPos) + float4(position.xyz - lightPos.xyz, 0); oPosition = mul(worldViewProjMatrix, newpos); } // Directional light extrude void shadowVolumeExtrudeDirLight_vp ( float4 position : POSITION, float wcoord : TEXCOORD0, out float4 oPosition : POSITION, uniform float4x4 worldViewProjMatrix, uniform float4 lightPos // homogenous, object space ) { // extrusion in object space // vertex unmodified if w==1, extruded if w==0 float4 newpos = (wcoord.xxxx * (position + lightPos)) - lightPos; oPosition = mul(worldViewProjMatrix, newpos); } // Point light shadow volume extrude - FINITE void shadowVolumeExtrudePointLightFinite_vp ( float4 position : POSITION, float wcoord : TEXCOORD0, out float4 oPosition : POSITION, uniform float4x4 worldViewProjMatrix, uniform float4 lightPos, // homogenous, object space uniform float extrusionDistance // how far to extrude ) { // extrusion in object space // vertex unmodified if w==1, extruded if w==0 float3 extrusionDir = position.xyz - lightPos.xyz; extrusionDir = normalize(extrusionDir); float4 newpos = float4(position.xyz + ((1 - wcoord.x) * extrusionDistance * extrusionDir), 1); oPosition = mul(worldViewProjMatrix, newpos); } // Directional light extrude - FINITE void shadowVolumeExtrudeDirLightFinite_vp ( float4 position : POSITION, float wcoord : TEXCOORD0, out float4 oPosition : POSITION, uniform float4x4 worldViewProjMatrix, uniform float4 lightPos, // homogenous, object space uniform float extrusionDistance // how far to extrude ) { // extrusion in object space // vertex unmodified if w==1, extruded if w==0 // -ve lightPos is direction float4 newpos = float4(position.xyz - (wcoord.x * extrusionDistance * lightPos.xyz), 1); oPosition = mul(worldViewProjMatrix, newpos); }