<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.xna.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Direct3D 10 </title><link>http://forums.xna.com/forums/29.aspx</link><description>Only questions about the Direct3D 10 API are permitted here.</description><dc:language>en</dc:language><generator>CommunityServer 2007.1 (Build: 0.0)</generator><item><title>Shadow mapping issue</title><link>http://forums.xna.com/forums/thread/188528.aspx</link><pubDate>Thu, 11 Jun 2009 08:07:35 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:188528</guid><dc:creator>Jman</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/188528.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=29&amp;PostID=188528</wfw:commentRss><description>I am trying to get a simple depth shadow mapping algorithm incorporated into my surface lighting shader (2x2 percentage closer filtering). My engine performs an initial depth-only pass, rendering from the light&amp;#39;s perspective, then uses the depth map as a shader resource for the next lighting pass. The scene that I have set up is just the classic teapot model with
a directional light. What I&amp;#39;m getting is the model looks split through
the center along a plane perpendicular to the direction of the light.
The side facing the light receives the regular surface lighting. The
other side is totally black. There is no shadow casting occurring, only
the split between surface lighting and black. No shadow-casting between different parts of the model occurs. As far as I can tell, the shader code for the PCF function is ok (I followed the Direct3D9 sample for shadow mapping):&lt;br /&gt;
&lt;br /&gt;
#define DEPTH_MAP_SIZE 800 // size in texels (assume a 1:1 aspect ratio)&lt;br /&gt;
&lt;br /&gt;
#define SHADOW_EPSILON 0.00005f&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
SamplerState SamShadow&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp; Filter = MIN_MAG_MIP_POINT;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; AddressU = Clamp;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; AddressV = Clamp;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
float PCF_Filter( Texture2D txDepthMap, float3 coords ) // coords.xy = light&amp;#39;s projection space (x,y), coords.z = light&amp;#39;s proj space z / w&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp; float2 texelPos = coords.xy * DEPTH_MAP_SIZE;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; float2 lerps = frac( texelPos );&lt;br /&gt;
&amp;nbsp;&amp;nbsp; float offset = 1.0f/DEPTH_MAP_SIZE;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; float sourceDepths[4];&lt;br /&gt;
&amp;nbsp;&amp;nbsp; sourceDepths[0] = txDepthMap.Sample( SamShadow, coords.xy ) + SHADOW_EPSILON;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; sourceDepths[1] = txDepthMap.Sample( SamShadow, coords.xy + float2(offset,0)) + SHADOW_EPSILON;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; sourceDepths[2] = txDepthMap.Sample( SamShadow, coords.xy + float2(0,offset)) + SHADOW_EPSILON;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; sourceDepths[3] = txDepthMap.Sample( SamShadow, coords.xy + float2(offset,offset)) + SHADOW_EPSILON;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; float sourceValues[4];&lt;br /&gt;
&amp;nbsp;&amp;nbsp; sourceValues[0] = (sourceDepths[0] &amp;lt; coords.z)? 0.0f : 1.0f;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; sourceValues[1] = (sourceDepths[1] &amp;lt; coords.z)? 0.0f : 1.0f;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; sourceValues[2] = (sourceDepths[2] &amp;lt; coords.z)? 0.0f : 1.0f;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; sourceValues[3] = (sourceDepths[3] &amp;lt; coords.z)? 0.0f : 1.0f;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; //iterpolate the source values&lt;br /&gt;
&amp;nbsp;&amp;nbsp; float lightAmount = lerp( lerp(sourceValues[0], sourceValues[1], lerps.x),&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lerp(sourceValues[2], sourceValues[3], lerps.x),&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lerps.y );&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; return lightAmount;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In my BRDF lighting function, lightAmount is multiplied by the final pixel color (r,g,b) right before fresnel reflectivity is applied. Is this an issue with the light projection space depth values? Or am I overlooking something? Plz help!&lt;br /&gt;</description></item></channel></rss>