Hi!
I want to do a fragment linked list, but my graphic card doesn’t seems to support opengl 420. (Anyway the mesa driver doesn’t support it yet)
On windows the driver support it but it crash when I want to display something with modern openGL.
So I’m trying to figure out if there’s an alternative with older openGL version.
I want to do something like this :
"#version 130
"
"uniform sampler2D depthBuffer;
"
"uniform sampler2D frameBuffer;
"
"uniform sampler2D texture;
"
"vec4 backgroundColor = vec4(0, 0, 0, 1);
"
"uniform vec3 resolution;
"
"uniform float haveTexture;
"
"in mat4 projMat;
"
"vec4 fragmentList[16];
"
"float depthList[16];
"
"int nbFrags;
"
"void main() {
"
" vec4 texel = texture2D(texture, gl_TexCoord[0].xy);
"
" vec4 colors[2];
"
" colors[1] = texel * gl_Color;
"
" colors[0] = gl_Color;
"
" bool b = (haveTexture == 1);
"
" vec4 color = colors[int(b)];
"
" float z = (gl_FragCoord.w != 1.f) ? (inverse(projMat) * vec4(0, 0, 0, gl_FragCoord.w)).w : gl_FragCoord.z;
"
/*Check the fragment's position in the list depending on its depth.*/
" int pos = 0;
"
" while(pos < nbFrags && z >= depthList[pos]) {
"
" pos++;
"
" }"
/*Move every fragment with are before the current fragment in the list and insert the current fragment.*/
" int i = nbFrags;
"
" while (i > pos) {
"
" depthList[i] = depthList[i-1];
"
" fragmentList[i] = fragmentList[i-1];
"
" i--;
"
" }
"
" depthList[pos] = z;
"
" fragmentList[pos] = color;
"
" vec4 finalColor = backgroundColor;
"
" nbFrags++;
"
/*Apply the alpha blending in order from bottom to top.*/
" for (int i = 0; i < nbFrags; i++) {
"
" finalColor = fragmentList[pos] * fragmentList[pos].a + finalColor * (1 - fragmentList[pos].a);
"
" }
"
" gl_FragColor = finalColor;
"
"}";
But that code doesn’t work, because the variables are not shared between fragment’s layers.