   Self Shadowing for units not working?
  I am shadow mapping my units onto my terrain currently. I noticed my backside of my units aren't shadowed. So do I need to some how calculate a lookup value into the shadowmap and then apply the same shadowmap I am using on my terrain for my units? Thanks for any suggestions or help.   
Quote:Original post by MARS_999I am shadow mapping my units onto my terrain currently. I noticed my backside of my units aren't shadowed. So do I need to some how calculate a lookup value into the shadowmap and then apply the same shadowmap I am using on my terrain for my units? Thanks for any suggestions or help.The self shadowing should be pretty much automatic with shadow maps. Two suggestions:a) Adjust the depth bias values / face cull settings when rendering into the depth mapb) Are you sure you are drawing the units with the shadow map bound and depth compare enabled? It is possible you might have drawn the terrain with the shadow and forgotten about it when drawing the units [smile]   ;Quote:Original post by deavikQuote:Original post by MARS_999I am shadow mapping my units onto my terrain currently. I noticed my backside of my units aren't shadowed. So do I need to some how calculate a lookup value into the shadowmap and then apply the same shadowmap I am using on my terrain for my units? Thanks for any suggestions or help.The self shadowing should be pretty much automatic with shadow maps. Two suggestions:a) Adjust the depth bias values / face cull settings when rendering into the depth mapb) Are you sure you are drawing the units with the shadow map bound and depth compare enabled? It is possible you might have drawn the terrain with the shadow and forgotten about it when drawing the units [smile]Don't think it's A due to when I render my terrain into the shadowmap I get shadows on the backsides of my hills ect... but they don't look as good as my precomputed lightmap I use to self shadow the terrain...B. The units are being drawn into my shadowmap and I use this to project onto my terrain for shadows. Now if I am understanding you correctly you say I can just render my shadowmap I used to shadow my terrain with my models so I can get a self shadowing effect? What about when I have two units by each other and the one is casting a shadow onto the other unit? As of now this isn't happening.   ;Quote:Original post by MARS_999B. The units are being drawn into my shadowmap and I use this to project onto my terrain for shadows. Now if I am understanding you correctly you say I can just render my shadowmap I used to shadow my terrain with my models so I can get a self shadowing effect?Yes - draw terrain + units when rendering depth from light point-of-view, and draw terrain + units when rendering with color from camera point-of-view. That should account for the self shadowing.My suspicion was that you were projecting the depth map comparison when drawing the terrain, but not projecting it when drawing the units (it can happen - people make silly mistakes! [smile])   ;Quote:Original post by deavikQuote:Original post by MARS_999B. The units are being drawn into my shadowmap and I use this to project onto my terrain for shadows. Now if I am understanding you correctly you say I can just render my shadowmap I used to shadow my terrain with my models so I can get a self shadowing effect?Yes - draw terrain + units when rendering depth from light point-of-view, and draw terrain + units when rendering with color from camera point-of-view. That should account for the self shadowing.My suspicion was that you were projecting the depth map comparison when drawing the terrain, but not projecting it when drawing the units (it can happen - people make silly mistakes! [smile])The first reply I am assuming your saying draw my terrain and units while I render my light POV pass, then when drawing my terrain and units for the final pass I will see my shadows onto the terrain and my terrain will have shadows on the backsides of hills? If this is the case I already have that. My question is more with the models not having the backsides of the actual model in shadow or when the model is close to another model the first model in front of it casts a shadow onto the ground and if the second model is in the first models shadow volume I am not able to darken the second models lighting because its not taking the first models shadowing into consideration. I am not sure I am clear on what is happening...The second reply are you saying that I need to use the shadowmap thats generated from rendering my terrain and units in the light POV pass and use this same shadowmap with the projected texture coordinates on my models to darken the back side of the units and front side of the units? Like the example above I talked about the first and second model where the second one is in the first ones shadow volume and it should be darkened on the front of the model but currently isn't, would using the same shadowmap solve this? Thanks for the help Deavik;Quote:Original post by MARS_999The second reply are you saying that I need to use the shadowmap thats generated from rendering my terrain and units in the light POV pass and use this same shadowmap with the projected texture coordinates on my models to darken the back side of the units and front side of the units? Like the example above I talked about the first and second model where the second one is in the first ones shadow volume and it should be darkened on the front of the model but currently isn't, would using the same shadowmap solve this?To your last question - yes; but I think we are both getting confused on minor issues - the process is pretty simple. I am sure you know all of it - but just stating here for clarity.1. Render terrain, units from light POV with depth write enabled, into depth texture.2. (Optional) Do ambient pass from camera POV, drawing terrain + units.3. Bind depth texture, enable projective texturing so that the 'projector' is at the light POV. Enable depth comparison for fragments.4. Draw terrain + units from camera POV with the conditions of step 3.5. Automatic self shadowing!The point I have been trying to make since the beginning is that in step 4, you might have drawn the units without the conditions of step 3, ie without depth comparison and projection of depth map.If it still doesn't work, there might be a precision issue with the depth map. Why don't you post the depth map and a screenshot of the final result?Quote:Thanks for the help DeavikGlad to help, really [smile].   ;Quote:Original post by deavikQuote:Original post by MARS_999The second reply are you saying that I need to use the shadowmap thats generated from rendering my terrain and units in the light POV pass and use this same shadowmap with the projected texture coordinates on my models to darken the back side of the units and front side of the units? Like the example above I talked about the first and second model where the second one is in the first ones shadow volume and it should be darkened on the front of the model but currently isn't, would using the same shadowmap solve this?To your last question - yes; but I think we are both getting confused on minor issues - the process is pretty simple. I am sure you know all of it - but just stating here for clarity.1. Render terrain, units from light POV with depth write enabled, into depth texture.2. (Optional) Do ambient pass from camera POV, drawing terrain + units.3. Bind depth texture, enable projective texturing so that the 'projector' is at the light POV. Enable depth comparison for fragments.4. Draw terrain + units from camera POV with the conditions of step 3.5. Automatic self shadowing!The point I have been trying to make since the beginning is that in step 4, you might have drawn the units without the conditions of step 3, ie without depth comparison and projection of depth map.If it still doesn't work, there might be a precision issue with the depth map. Why don't you post the depth map and a screenshot of the final result?Quote:Thanks for the help DeavikGlad to help, really [smile].I will try it tonight when I get home, the issue is my units aren't using my depthmap or the projective texture coordinates. Thanks   ;  YES it works! :) WOOT. Thanks for pointing out to me the models needed to be shadowed in the shader also. I forgot that I wasn't loading my shadowmap in the model shader and calculating the projective coords in the model shader. I was only doing it for my terrain. Wow it look neat when you move a building in front of another and its shadow is cast upon it. Now to get back to work. Thanks again Deavik.++   ;  Hmm now the last issue is I think they call it false shadowing? Where you have parts of the object shadowing where it shouldn't be. For the most part it's not something you would see unless you are up close on the models since they are small enough. I tried adjusting my glPolygonOffset() and that works to a point but as most people know already that after a point the shadow detaches from the object and moves away. So does anyone have any ideas? Can I modify the matrix bias? I am using const float MATRIX_BIAS[] = {0.5f, 0.0f, 0.0f, 0.0f,  0.0f, 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.5f, 0.5f, 0.5f, 1.0f};