trying to make fake shadow with RTT texture applied to a mesh

Started by MichaelJPCT, August 20, 2016, 05:34:56 PM

Previous topic - Next topic

MichaelJPCT

i am trying to make fake shadow. my approach is like this:
stick a transparent mesh on an object3D which should be a shadow receiver, but in fact the transparent mesh is the receiver;
render the shadow caster object into a texture and project the texture onto the transparent mesh;
the RTT should have alpha information - the part covered by shadow caster is opaque and black, other part is fully transparent.

now i wonder how to render into the alpha channel of RTT texture - i want to use openGL hardware framebuffer for the RTT task (faster) so the texture should be directly used in GPU (not downloaded for further process).
is setAsShadowMap() meant for this?

EgonOlsen

I'm not sure how this is supposed to work!? Do you have a drawing that illustrates it? Concerning the alpha channel...it might be a better idea to just render into the texture and then apply the projected result with a shader instead of relying on the alpha. setAsShadowMap() makes the texture act as a depth map. This is needed if you want to implement shadow mapping without using the ShadowHelper, but in your case, you don't seem to rely on depth at all, so I guess that you don't need it.

MichaelJPCT

my approach is just using projective texture, except the receiver is a seperate small simple  object3d instead of a large complex object3d.
i found i could clear the alpha channel of rtt by a full window quad mesh with shader: gl_fragcolor=vec4(0,0,0,0)
then i can draw opaque object in the rtt.
using shader to render the receiver without alpha information can work too.