Shadows in OF for 3D space

I tweeted about this and got some ideas for addons that might help and I thought I would unpack the conversation a bit more.
I am trying to re-mix/re-configure my METRO animated piece ( ) as an interactive piece for the Oculus Rift, hopefully using OF. Right now I am frustrated with the lack of tools for 3D space, most notably for shadowing and decent lighting models.
The core issue for me seems to be self-shadowing since my project uses complex scans of interiors. and lights connected to the movement of the camera.
I have tried:

  • ofxShadow (which only creates shadows onto a plane)
  • of-ESMShadowMapping (which creates more complex shadows, but only onto other objects, aka no self shadowing) see the image below. Also I am having trouble getting it to account for the colors of the model (vertex colors) which render fine until I turn on the shader.

I know I am spoiled by working with Blender all the time but I am realizing that I havent really seen much in OF using complex 3D models and lighting. I know I am not going to get realtime raytracing or anything like that but knowing I can bake AO and such into the models I just need decent looking lighting that doesnt just pass thru every everything.

In the image, the front box makes a shadow on the model behind and the shadow projects thru the object and keeps on going in addition to the object not self shadowing.

I think (not sure) what you want is shadow volumes. With opengl, all shadows are approximated in different ways, sometime very simple (like object to plane) or via more complicated rendering pathways (ESM). I think what you might be looking for is shadow volumes –

it might help for you to find the type of shadowing you want to use – this presentation is pretty helpful:

wrt to OF, we are not a scene graph or a dedicated 3d engine – the core of OF is designed to be relatively agnostic and help where it can, so we don’t make assumptions about shadows, 3d, etc since many people use the window differently and so many of the different approaches are very different in terms of what they need.

that said, I think you are identifying an area that OF needs improvement on, in terms of addons and generally good research to help make some of the different approaches easier to try.

anyway, happy to help, I think improving shadow options for OF will be a big win.

this is also helpful:

1 Like

Check out ofxSSAO for ambient occlusion.

Also check out (looks like you already found

1 Like

@zach many thanks for the info - you are right that it seems I need Shadow Volumes to do what I was hoping. I have come to rely on OF for so many great projects it is hard to find the edge of the cliff. I would need a few months (or a year?) to get good enuf at C++ to whip up the tools I need. I am either going to have to try other approaches or bend my expectations.
@bakercp Thanks! I will give those a go, but baking the ambient occlusion in blender before importing is easy, im more worried about regular dynamic lighting and the shadows it should be casting…

I think with these things it’s first about identifying the language, ie “shadow volume”, then seeing what exists in the community and if you hit dead ends, trying to find example code to try from elsewhere. My intuition is that it shouldn’t be that hard, but with 3d you can find alot of incongruencies between example code, since there are different coordinate systems, different settings for the camera, etc. I definitely feel like the shadow volume example that’s out there would be a good starting point. I’ll try to take a look when I have a moment…