Help! Shadow mapping


I tried to build shadow-mapped app with the help of cinder’s( shadow map sample
and onicore’s(‘only’-video-effect/3407/3).

my code flow is simple
0. generate depth texture using ofxFBOTexture( and i extend it for GL_DEPTH_COMPONENT).

  1. set depth fbo texture to sampler2DShadow variable in .frag shader.
  2. set shadow transform matrix to mat4 variable in .vert shader.
  3. draw scene using shader.
    (my shader is the same as cinder shadowmap sample.)

But the combination of shader and fbo texture are really complicated.
Then i am stuck.
I’m even not sure my code is towards the end or i am totally wrong…

current output is like this

Could anyone give any suggestion?
I Appreciate any help.
And if you know any other oF project using shadow mapping, please let me know.

i attach my project.

Thank you in advance.

Mac OS X 10.6.4
Xcode 3.2.3

Hi all :slight_smile:

I ported VSM shadow map (here) and it seems work.


i do not know it is useful or not, i attach example.


nice work!

it’s strange that you had to supply a full path to the ofDataSetPathRoot() method. One way around it is to add a Copy Files build phase to your target in Xcode and have it actually put the shader files inside the .app bundle. When I do this, I don’t have to use ofDataSetPathRoot at all and it works fine.


Ah, you are right!

Set my shaders to “Copy Files” phase on my Target,
i don’t need ofSetDataPathRoot().


Thank you Aaron!

Thanks alot for this code! Helped alot here!

:’( hm… compiles, loads the shaders, but renders strange output… i’m on OSX 10.6.7 with OF 0.062 / Xcode 4.0 with SDK 10.6 / ATI Radeon HD 4850

any ideas ?

greetings ascorbin

Since I implement this demo on 0061,
you can run this demo on 0061 without problem.
There may be some openGL operation difference between 0061 and 0062,
but I have not figure out it yet… sorry…

yes, you`re right. it works on 061