First, how transform texutre to projected texture. I don’t know how to apply ProjectedTextureUtil.java ( It’s jme2 ) to jme3.
Second, how map projected texture on spatials that have texture already. In other words, is it can map projected texture on spatial have SimpleTextured.
You’ll have to make your own RenderPorcessor that will compute the projection matrix for the texture, and in the postFrame method render again the “receiver” objects with a forced material.
This material will use a shader, which will be provided with the projection matrix you computed before
You should look at the BasicShadowProcessor and the associated shader (postShadow.vert and .frag), because that’s how shadow maps are projected to the scene.
Yes but, for shadow mapping we use a parallel projection cam, and we crop the matrix around the caster/receiver objects in the post queue, but you don’t need this. you just need to create a camera that will “project” your texture, set the correct position in post queue, and grab its viewProjectionMatrix.
Yes render with forced material, the setForcedMaterial(nul) just removes the forced material from the RenderManager so geometries’ materials are used for render.
Now, I wrote Application.java( it is extended SimpleApplication), ProjectionTextureProcessor.java, ProjectionTexture.j3md, ProjectionTexture.vert and ProjectionTexture.frag.
Application.java is a copy of TestTrrain.java and has ProjectionTextureProcessor. It’s code is this.
ummmm… I added RenderState blendMode modulate. Then with “renderManager.setForcedMaterial(null)” code is not changed before and comment out it, display filled black only. nothing is drawn…