Hi,
I have modified the FilterPostProcessor to support Multi Target Rendering (MRT). There are 3 targets: default color target, glow map and a water mask (which only contains the water). The problem is that when I enable multisampling, the other 2 render targets (glow map, water mask) contains garbage only. I hope @nehon can help me because he already knows my situation from this thread: [SOLVED] Prevent rendering scene multiple times using MRT
What I am doing wrong? This is the modified frame buffer part in the FilterPostProcessor:
public void reshape(ViewPort vp, int w, int h)
{
...
// antialiasing on filters only supported in opengl 3 due to depth read problem
if (numSamples > 1 && caps.contains(Caps.FrameBufferMultisample))
{
renderFrameBufferMS = new FrameBuffer(width, height, numSamples);
if (caps.contains(Caps.OpenGL32))
{
Texture2D msColor = new Texture2D(width, height, numSamples, fbFormat);
Texture2D msDepth = new Texture2D(width, height, numSamples, Format.Depth);
renderFrameBufferMS.setDepthTexture(msDepth);
renderFrameBufferMS.setColorTexture(msColor);
filterTexture = msColor;
depthTexture = msDepth;
}
else
{
renderFrameBufferMS.setDepthBuffer(Format.Depth);
renderFrameBufferMS.setColorBuffer(fbFormat);
}
}
if (numSamples <= 1 || !caps.contains(Caps.OpenGL32))
{
renderFrameBuffer = new FrameBuffer(width, height, 1);
renderFrameBuffer.setDepthBuffer(Format.Depth);
filterTexture = new Texture2D(width, height, fbFormat);
renderFrameBuffer.setColorTexture(filterTexture);
}
// modification below this line
if (caps.contains(Caps.FrameBufferMRT))
{
if (renderFrameBuffer != null)
{
renderFrameBuffer.setMultiTarget(true);
glowMap = new Texture2D(w, h, Format.RGBA8);
renderFrameBuffer.addColorTexture(glowMap);
waterMaskMap = new Texture2D(w, h, Format.RGB32F);
renderFrameBuffer.addColorTexture(waterMaskMap);
depthMap = new Texture2D(w, h, Format.RGB32F);
renderFrameBuffer.addColorTexture(depthMap);
}
if (renderFrameBufferMS != null && numSamples > 1)
{
renderFrameBufferMS.setMultiTarget(true);
msGlowMap = new Texture2D(w, h, numSamples, Format.RGBA8);
renderFrameBufferMS.addColorTexture(msGlowMap);
msWaterMaskMap = new Texture2D(w, h, numSamples, Format.RGB32F);
renderFrameBufferMS.addColorTexture(msWaterMaskMap);
msDepthMap = new Texture2D(w, h, numSamples, Format.RGB32F);
renderFrameBufferMS.addColorTexture(msDepthMap);
}
}
else
{
throw new UnsupportedOperationException("Multiple Render Targets (MRT) are not supported by the GPU! Currently there is no fallback supported.");
}
...
}
....
public Texture2D getGlowMap()
{
return renderFrameBufferMS != null ? msGlowMap : glowMap;
// return glowMap;
}
public Texture2D getWaterMaskMap()
{
return renderFrameBufferMS != null ? msWaterMaskMap : waterMaskMap;
// return waterMaskMap;
}
public Texture2D getDepthMap()
{
return renderFrameBufferMS != null ? msDepthMap : depthMap;
// return depthMap;
}
the garbage looks like the following when I display the target at the screen (simple post filter). I suppose it shows some random textures from the VRAM such as normal maps, diffuse maps and so on: