Fragment output

I am trying to convert a DirectX shader to OpenGL.

The shader outputs to an 8 bit unsigned integer texture and a half-float RGBA (ie 16 bit) texture.

how do I describe these in the glsl layout command in the fragment shader?

You don’t.

It’s not the shader’s responsibility to say what kind of texture it writes to. All it writes are output values. What decides the format of the values written to the framebuffer images are the framebuffer images themselves.

The only thing you have to decide is what GLSL type you’re writing to. Floating point outputs can be written to either a normalized integer image format or to floating-point formats. Signed integral outputs can be written to signed integral image formats. And unsigned integral outputs can be written to unsigned integral outputs.

If you write a vec4, it could go to an RGB16F texture, an RGBA8 texture, an RGBA16 texture, an RG8_SNORM, or whatever. If you write to an ivec4, then it can go to an RGB8I, RGB16I, an RG8I, an RGBA16I, and so froth, as long as it ends in I. Similarly, if you write to a uvec4, then it can go to an RGB8UI, RG16UI, RGBA8UI, etc.

thanks for that

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