Volumes Of Fun
http://www.volumesoffun.com/phpBB3/

Custom Shadow mapping
http://www.volumesoffun.com/phpBB3/viewtopic.php?f=14&t=357
Page 1 of 1

Author:  xelons [ Fri Apr 06, 2012 12:02 am ]
Post subject:  Custom Shadow mapping

Greeting everyone, I have posted this on the ogre forum and would like to open the discussion here as well.

I have recently added per pixel lighting to my game, then tried to implement custom shadow mapping, both are taken from the wiki,
here is a screenshot of the problem:
Image

my terrain is loaded in chunks using 1 mesh for every chunk, I'm trying to achieve self shadowing. Terrain is a procedural voxel terrain powered by polyvox.
my terrain material
Code:
material terrain
 {
     technique
     {
         // Base ambient pass
         pass
         {
 
             vertex_program_ref Ambient
             {
             }
         
          shadow_caster_vertex_program_ref ShadowCasterVP
      {
      }
         }
      
         pass
         {
             // do this for each light
             iteration once_per_light
             scene_blend add 
 
             vertex_program_ref PerPixel_Vert
             {
             }
 
             fragment_program_ref PerPixel_Frag
             {
             }

             shadow_receiver_vertex_program_ref LightingWithShadowMapVP
      {
      }
 
            shadow_receiver_fragment_program_ref LightingWithShadowMapFP
      {
      }

vertex_program_ref LightingVP
      {
      }
 
      fragment_program_ref LightingFP
      {
      }    
         }

     }   
 
 }

Custom shadow mapping shader is taken directly from here http://www.ogre3d.org/tikiwiki/Custom+Shadow+Mapping, per pixel shader is taken directly from here http://www.ogre3d.org/tikiwiki/PerPixel+Lighting+II I use the "perpixel" one.

My createscene shadow code:
Code:

sceneMgr->setShadowTexturePixelFormat(Ogre::PF_FLOAT16_R);
sceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_TEXTURE_ADDITIVE);
sceneMgr->setShadowTextureSelfShadow(true);
sceneMgr->setShadowTextureCasterMaterial("ShadowCaster");
sceneMgr->setShadowTextureReceiverMaterial("ShadowReceiver");



I don't know if there is any simpler method to achieve the self shadowing technique using ogre, any help would be appreciated.

Author:  David Williams [ Fri Apr 06, 2012 12:20 pm ]
Post subject:  Re: Custom Shadow mapping

This is largely an issue with Ogre rather than PolyVox so I can't give much specific help I'm afraid. I do see you have a couple of replies on the Ogre forum though.

But generally speaking, I can tell you that shadows as one of the hardest aspects of working with Ogre (or with realtime 3D graphics in general). I'd really recommend getting your shaders working on the simplest scene you can first (e.g. a cube on a plane) and try to verify each stage of the process using a tool such as PIX or gDebugger. Also, self shadowing is an extra complication, so start off with seperate caster and receiver objects.

Author:  RevenantBob [ Fri Apr 06, 2012 4:29 pm ]
Post subject:  Re: Custom Shadow mapping

Looks like it's have depth bias issues as well.

Author:  xelons [ Sat Apr 07, 2012 2:01 am ]
Post subject:  Re: Custom Shadow mapping

David Williams wrote:
This is largely an issue with Ogre rather than PolyVox so I can't give much specific help I'm afraid. I do see you have a couple of replies on the Ogre forum though.

But generally speaking, I can tell you that shadows as one of the hardest aspects of working with Ogre (or with realtime 3D graphics in general). I'd really recommend getting your shaders working on the simplest scene you can first (e.g. a cube on a plane) and try to verify each stage of the process using a tool such as PIX or gDebugger. Also, self shadowing is an extra complication, so start off with seperate caster and receiver objects.


Thanks for the reply, my scene is actually really that simple, I'm loading the terrain using chunks with 1 mesh representing every chunk, I guess the main problem here is related to shaders, I need to figure out how to use my per pixel lighting to calculate the shadows. The problem is that there is no enough documentation about ogre's self shadowing, especially when using a procedural generated terrain when you really have no other option than making your material cast and receive shadows. I must admit that I'm totally clueless when it comes to shaders so please excuse my blatant ignorance :)

Author:  David Williams [ Sun Apr 08, 2012 8:47 am ]
Post subject:  Re: Custom Shadow mapping

This Wiki article shows how you can integrate shadows (with self shadowing) into your shaders: http://www.ogre3d.org/tikiwiki/Depth+Sh ... e=Cookbook

However, self shadowing is hard so you should really start off without it. Try just having a cube cast onto your terrain or something. Also large receiver objects are hard because they introduce precision problems.

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/