About Store Forum Documentation Contact



Post Reply 
Preventing some objects to cast shadows or being lit
Author Message
mokh Offline
Member

Post: #1
Preventing some objects to cast shadows or being lit
Hi there,
I was wondering if there is a way to prevent some object from being lit or to cast shadows. For instance, consider a complex scene which I had baked the lightmap for, it's a waste of time and quality to recalculate light and shadows from static lights for objects like I described. Is there a way to cluster the objects in lighting and shadow casting ? It's very handy and boosts performance and it's quite easy to implement. If there is not such thing in the engine at the moment can you provide me a way to overcome this problem ? I have a very huge map and I will need all the performance boosts I can get.
05-21-2011 07:23 AM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #2
RE: Preventing some objects to cast shadows or being lit
Not sure if it's possible to disable lighting. Perhaps just having a lightmap on the material will do it automatically? I'm not sure, but disabling shadows is easy; you just need to override the drawShadow method of a custom Game::Obj class:

PHP Code:
// If you'll never need shadows on a certain OBJ_TYPE, do this:
void drawShadow() {}

// Or, if you'll optionally need shadows, do this:
void drawShadow()
{
    if (
shadow__super::drawShadow();


In the second code block, shadow is a Bool variable that you must add to your custom class. Simply set it to true/false whenever you need/don't need shadows.
05-21-2011 08:04 PM
Find all posts by this user Quote this message in a reply
mokh Offline
Member

Post: #3
RE: Preventing some objects to cast shadows or being lit
Thank you for your reply,
Maybe I didn't explain it right. My problem is to disable shadow for some of the lights, the solution you've provided will disable the shadow for all the lights. I want to know that if there is a way to check that the shadow is being rendered for which light at the moment, base on my current knowledge I think the engine will draw each object from each light's point of view to caculate the depth and store it in shadow map so I think for each light the drawShadow must be called once, I was wondering if I could find which one of the lights are calculating the shadow map at that very moment.
Another thing I forgot to say is that because my map is huge I have to embedded the map object into terrain and I don't have any access to disable the shadow for those kind of the objects. I wish there would be a way to access that easy.
(This post was last modified: 05-22-2011 06:32 AM by mokh.)
05-22-2011 06:25 AM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #4
RE: Preventing some objects to cast shadows or being lit
You can disable shadows for some lights by setting the param "cast_shadows" to false on each individual light in World Editor, or through code by also setting the Bool member "cast_shadows" to false.

   

Also, if you want custom lighting for a certain object regardless of other lights in the scene, this tutorial is what you want: "EsenthelEngineSDK\Tutorials\Source\Advanced\3 - Mesh, Shaders\Shaders\10 - Custom Light.cpp". However, you'll need a license to compile the shaders and successfully run the tutorial.
05-22-2011 07:17 AM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #5
RE: Preventing some objects to cast shadows or being lit
(05-22-2011 06:25 AM)mokh Wrote:  I was wondering if I could find which one of the lights are calculating the shadow map at that very moment.

Believe it or not, I just so happened to stumble upon a way to do this -- thanks to autocompletion.

PHP Code:
void Render()
{
   
Game::World.draw();
   
   switch (
Renderer())
   {
      case 
RM_SHD_MAP:
      {
         
CurrentLight// access information about current light
         
break;
      }
   }

(This post was last modified: 05-24-2011 09:51 PM by Driklyn.)
05-24-2011 09:49 PM
Find all posts by this user Quote this message in a reply
mokh Offline
Member

Post: #6
RE: Preventing some objects to cast shadows or being lit
Ah, thank you very much, that was just the thing I was looking for.
Can I assign names to lights, or is there something like a userdata member in lights ? After all I should somehow recognize the CurrentLight object.
(This post was last modified: 05-25-2011 05:51 AM by mokh.)
05-25-2011 05:48 AM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #7
RE: Preventing some objects to cast shadows or being lit
No problem. Sorry for the late response. I haven't been on in about 2 days.

You'll need to create your own custom class derived from Game::ObjLightPoint or Game::ObjLightCone and use store a custom parameter that you assigned to the light in World Editor. Then, do the following to access it:

PHP Code:
void Render()
{
   
Game::World.draw();
   
   switch (
Renderer())
   {
      case 
RM_SHD_MAP:
      {
         switch (
CurrentLight.type)
         {
            case 
LIGHT_POINT:
            case 
LIGHT_SQR:
            {
               if (
Game::ObjLightPoint *lightPoint CAST(Game::ObjLightPoint, (Game::ObjLightPoint *)CurrentLight.src))
               {
                  
lightPoint-> // custom variable, "name" for instance
               
}
               
               break;
            }
         }
         
         break;
      }
   }

05-27-2011 07:32 AM
Find all posts by this user Quote this message in a reply
Post Reply