Jump to content
  • Advertisement
Sign in to follow this  
leemw

VSM help

This topic is 3162 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

LInk : http://gamepro.tistory.com/575 VSM CODE!!!!!!!!!!!!!!!!!!!!!! float VSMMINVARIANCE = 0.000001; // Minimum variance for VSM float ChebyshevUpperBound(float2 Moments, float distToLight, float MinVariance) { float p = (distToLight <= Moments.x); float Variance = min(max(Moments.y - (Moments.x*Moments.x) + MinVariance, 0.0),1.0f); float d = Moments.x - distToLight; float p_max = Variance / (Variance + d * d); return max(p, p_max); }; float VSM_Filter( float4 texcoord, float fragDepth ) { float shadowContrib = 1.0; float2 shadowuv = texcoord.xy / texcoord.w; if( texcoord.z > 0.0f ) { float2 moments = tex2D(shadowPCFSampler, shadowuv).xy; float distToLight = texcoord.z - 0.0001; shadowContrib = ChebyshevUpperBound(moments,distToLight, VSMMINVARIANCE); } return shadowContrib; } VSM Depth COde struct SHADOWDEPTHVSMOUTPUT { float4 pos : POSITION; float2 uv : TEXCOORD0; float detph : TEXCOORD1; }; SHADOWDEPTHVSMOUTPUT ShadowVSMDepthMeshVS( MESH_VERTEX vertex ) { SHADOWDEPTHVSMOUTPUT output = (SHADOWDEPTHVSMOUTPUT)0; float4 position = float4( vertex.position * SCALE , 1.0f ) ; float4 worldPosition = mul( position , LIGHTVIEW ); float4 wvpPosition = mul( position , WOLRDVIEWPROJ ); output.pos = wvpPosition; output.uv = vertex.uv1; output.detph = wvpPosition.z; return output; } float4 ShadowVSMDepthPS( SHADOWDEPTHVSMOUTPUT In ) : COLOR0 { float4 textureColor = tex2D(ldSampler, In.uv); float depth = In.detph; return float4(depth, depth * depth, 0.0f , textureColor.a); } technique ShadowVSMDepthMesh { pass P0 { VertexShader = compile vs_1_1 ShadowVSMDepthMeshVS( ); PixelShader = compile ps_2_0 ShadowVSMDepthPS(); } } I want to create a link like Lispsm VSM came to look at the above Please let us know what your problem is entitled Code of

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!