Hi!
I Can't figure out how to use TextureRenderer.
I use textureRenderer.render(Spatial, texture) in the doRender() of Pass.
First of all it seems totally uneffected of context.enforceState(ZBufferState) or context.enforceState(StencilBufferState).
How do I use states with it?
Also it accumulates whatever I render. I have been looking for somewhere to clear it, but haven't fond anything.
public void doRender(Renderer r) {
r.clearStencilBuffer();
TextureState ts = (TextureState) fullScreenQuad.states[RenderState.RS_TEXTURE];
context.enforceState(colorDisabled);
context.enforceState(noStencilTest);
context.enforceState(testWriteDepth);
for (int i = 0; i < spatials.size(); i++) {
spatials.get(i).draw(r);
}
r.renderQueue();
for (int i = 0; i < meshes.size(); i++) {
context.enforceState(testDepth);
context.enforceState(writeStencil);
context.enforceState(frontFaceCull);
shadowVolumes.elementAt(i).draw(r);
r.renderQueue();
context.enforceState(backFaceCull);
context.enforceState(clearStencilOnDepthFail);
shadowVolumes.elementAt(i).draw(r);
r.renderQueue();
context.enforceState(clearStencil);
meshes.elementAt(i).draw(r);
r.renderQueue();
context.enforceState(testWriteDepth);
context.enforceState(testStencil);
shadowVolumes.elementAt(i).draw(r);
r.renderQueue();
}
context.enforceState(colorEnabled);
textureRenderer.render(shadowVolumesNode, texture);
ts.setTexture(texture, 0);
context.enforceState(colorDisabled);
context.enforceState(testWriteDepth);
context.enforceState(colorEnabled);
context.enforceState(testStencilInvert);
context.enforceState(noStencilTest);
for (int i = 0; i < spatials.size(); i++) {
spatials.get(i).draw(r);
}
fullScreenQuad.draw(r);
r.renderQueue();
if (renderShadowVolumes) {
context.enforceState(testDepth);
context.enforceState(wireframeStateEnabled);
context.enforceState(noStencilTest);
for (int i = 0; i < shadowVolumes.size(); i++) {
shadowVolumes.elementAt(i).draw(r);
}
r.renderQueue();
context.enforceState(testWriteDepth);
context.enforceState(testStencilInvert);
context.enforceState(wireframeStateDisabled);
}
}
This is some of my code where I use the TextureRenderer. I'm messing alot with it right now so it probably looks weird.