Hello,
I would like to implement a surface splatting using MRTs. The point is, I have thousands of splats and some of them are affecting the same fragment position. So, I would like to blend their color contributions, but I could not.
I am using 2 render targets. In the 1st pass, I assign 0 to all targets.
gl_FragData[0] = vec4(0.0);
gl_FragData[1] = vec4(0.0);
In the 2nd pass, I send all splats to fragment shader and compute their contributions. Now, I want to add this value to the value which was already written in the target as:
vec4 computedValue; //compute it as you like for each splat
vec4 newValue = texture2D(texture0, vec2(xpos,ypos)) + computedValue;
gl_FragData[0] = newValue;
vec4 computedValue2; //compute it as you like for each splat
vec4 newValue2 = texture2D(texture1, vec2(xpos,ypos)) + computedValue2;
gl_FragData[1] = newValue2;
So, for each new splat, I assume that it is adding up. I have to do this blending at each single frame, in 1 pass for all affecting splats. So, ping-pong does not work for me in which the neccessary data is read in the other pass.
But the result does not seem blended. I am reading from/writing to the same texture. Can it be a problem? The reference papers say that they are using MRTs with additive alpha blending. How can I implement it?
Thanks in advanceā¦