Help! Shadow mapping

Hi.

I tried to build shadow-mapped app with the help of cinder’s(http://libcinder.org/) shadow map sample
and onicore’s(http://forum.openframeworks.cc/t/nin-‘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
[attachment=1:1vg37vfo]screen.png[/attachment:1vg37vfo]

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.
[attachment=0:1vg37vfo]oFShadowMap7_forum.zip[/attachment:1vg37vfo]

Thank you in advance.


setup-
Mac OS X 10.6.4
Xcode 3.2.3
of_preRelease_v0061_osxSL_FAT

oFShadowMap7_forum.zip

Hi all :slight_smile:

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

[attachment=1:1zg4dd6q]sm.png[/attachment:1zg4dd6q]

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

cheers

ofxShadowMapUtilExample.zip

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.

-Aaron

Ah, you are right!

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

[attachment=0:nqoam8re]screen.png[/attachment:nqoam8re]

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