It is currently Sat Aug 22, 2020 1:53 pm


All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Custom Shadow mapping
PostPosted: Fri Apr 06, 2012 12:02 am 

Joined: Wed Feb 29, 2012 12:35 am
Posts: 25
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.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Custom Shadow mapping
PostPosted: Fri Apr 06, 2012 12:20 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
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.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Custom Shadow mapping
PostPosted: Fri Apr 06, 2012 4:29 pm 

Joined: Fri Apr 06, 2012 3:11 pm
Posts: 3
Looks like it's have depth bias issues as well.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Custom Shadow mapping
PostPosted: Sat Apr 07, 2012 2:01 am 

Joined: Wed Feb 29, 2012 12:35 am
Posts: 25
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 :)


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Custom Shadow mapping
PostPosted: Sun Apr 08, 2012 8:47 am 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
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.


Top
Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Theme created StylerBB.net