Update:
“Projective Texture Mapping” is now available as a jME3 SDK plugin. The source code has also moved to the contributions repository. Don’t expect too much of it. You’ll most likely want to create your own solution if you need something like that, but it might be a good starting point.
The plugin also contains a sample project template to demonstrate the features:
Update:
- Fixed the RC2 incompatibility @haze pointed out (caused by jME3 r9956).
- Fixed a model space vs. world space brainbug (thanks to @the_accidental and @nehon for finding it and providing a solution)
Snapshot: ProjectiveTextureMapping-2012-11-24.zip
Update:
- “(Single)TextureProjectorRenderer” is default again. I said multi would be faster, but that was a mistake.
- Some refactoring:
— “ProjectiveTextureMapping1pass” -> “ProjectiveMultiTextureMapping”
— “TextureProjectorRenderer1pass” -> “MultiTextureProjectorRenderer” - Z-fighting fix “setPolyOffset(-0.1f, -0.1f)” by default
- Different CombineMethods in “MultiTextureProjectorRenderer”
- Bugfixes
- ul and li don’t work btw
Snapshot: ProjectiveTextureMapping-2012-03-15.zip
I wrote a post processor which does Projective Texture Mapping. See also this paper by nVidia. It is related to the thread Projected Texture on this forum.
Features:
- Can project an arbitrary number of textures onto scene geometry
- You can choose which geometry shall be affected (GeometryList)
- Perspective and parallel projection
- Back projection and backside projection fixed
- Fall off distance and fall off power to limit the projection
Video demonstration of latest version (note the rune is just projected onto one geometry):
<!–leave this below youtube link–>
Motivation:
A use case of projected textures are targeting circles and ground effects known from popular MMOs by BlizZzard and Buy-o-ware. It can also be used to simulate the light cone of a flashlight/torch.
<!–leave this below youtube link–>
The code including a test application can be checked out here:
http://code.google.com/p/survivor-jme/source/browse/#svn%2Ftrunk%2FProjectiveTextureMapping
Please note that this is work in progress. It might change frequently and it will surely have bugs.
Future work:
I’m planning to write a shader that can do all in one pass like this:
[java]
uniform vec3 m_ProjectorLocation[NUM_PROJECTORS];
uniform mat4 m_ProjectorViewProjectionMatrix[NUM_PROJECTORS];
for (int i = 0; i < NUM_PROJECTORS; i++)
{
vec3 pl = m_ProjectorLocation<i>;
mat4 pm = m_ProjectorViewProjectionMatrix<i>;
// process an arbitrary number of projectors in a single pass
}
[/java]
I don’t know if this makes sense, though. I can’t yet estimate performance bottlenecks.
I’d also love to see this in the GL1Renderer.</i></i>