[osg-users] Projective texture mapping
Sebastian Messerschmidt
sebastian.messerschmidt at gmx.de
Mon Sep 28 01:15:09 PDT 2015
Hi Michael,
> Hi,
>
> I am trying to set up projective texture mapping in OpenSceneGraph. As a first attempt, I modified the osgspotlight example code by basically inserting my own spot light image. This works, but the texture is projected onto all geometry of the scene in the direction of the projection (it goes through meshes). A back projection is also produced.
That's quite normal with projective texturing. In order to eliminate the
back-projection there where are some historical approaches, such as
using a special texture with some white part being wrapped around so
multiplicative texturing won't affect the backside.
But nowadays you should use pixel shaders and remove any fragment which
homogeneous coordinate contains an negative q (in the vec4 texcoord
s,t,r,q) to remove them.
As for the projection to unwanted surfaces: This cannot be solved
directly, but if you know which objects/drawables are affected, you can
simply control via stateset (by turning TexGen on/off or by using a
uniform or even the brand new shader-define mechanism) which of them
should use the projection. Another (potentially costly approach) is to
render the scene from the view of the projector and create essentially
something like an inverse "shadow map", which can be either used for
direct texturing or controlling which parts are subject to projective
texturing in a second pass.
>
> How can you implement projective texture mapping in OSG as is done by a real projector?
In simple words: There is no ready-to use example or implementation. You
will need to do some of this on your own.
There are some examples for the steps you need to take however.
Cheers
Sebastian
>
> Thank you!
>
> Cheers,
>
> Michael
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=65226#65226
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
More information about the osg-users
mailing list