Author Topic: trying to make fake shadow with RTT texture applied to a mesh  (Read 2837 times)

Offline MichaelJPCT

  • float
  • ****
  • Posts: 264
    • View Profile
trying to make fake shadow with RTT texture applied to a mesh
« on: August 20, 2016, 05:34:56 pm »
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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: trying to make fake shadow with RTT texture applied to a mesh
« Reply #1 on: August 21, 2016, 08:57:29 pm »
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.

Offline MichaelJPCT

  • float
  • ****
  • Posts: 264
    • View Profile
Re: trying to make fake shadow with RTT texture applied to a mesh
« Reply #2 on: August 22, 2016, 09:33:21 am »
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.