Can I use something like gl_FragData

I have implemented a GLSL noise function created by Stefan Gustavson.
For my texture I am currently using 4 noise calls of essentially the same noise. For example I need blocks of noise values for each row:

noise(vec2(floor(MCposition.y / BrickMortar.y)))

And each square area:

noise(floor(position / BrickMortar))

I can see it being more efficient if I just read from a noise textured generated by the CPU where I only need 4 texture calls. Apart from that is there any other way of using some form of buffer so I can read previously generated noise values from the GLSL noise function?
I tried reading about gl_FragData but not sure how it works.

When you have several draw-buffers, let’s say 4,
gl_FragColor = someColor;
is equal to
gl_FragData[0]=someColor; gl_FragData[1]=someColor;
gl_FragData[2]=someColor; gl_FragData[3]=someColor;

To draw in 4 buffers at once, here’s usually how you enter into a FBO and set-up draw-buffers:
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, myFrameBuffer);

GLenum bufs[4];
bufs[0] = GL_COLOR_ATTACHMENT0_EXT;
bufs[1] = GL_COLOR_ATTACHMENT1_EXT;
bufs[2] = GL_COLOR_ATTACHMENT2_EXT;
bufs[3] = GL_COLOR_ATTACHMENT3_EXT;
glDrawBuffers(4,bufs);

(that FBO should have 4 attached color-textures with the same size and format)

Just a N.B., you cannot use gl_FragColor and gl_FragData together in the same shader. (which makes sense).

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.