1
\$\begingroup\$

I want to apply SNORM texture by using GL_TEXTURE_3D as a target, what will be the fragment shader for the same? Also, what should be the data type of texture data?

\$\endgroup\$
1
\$\begingroup\$

When using RGBA_SNORM you should use GL_BYTE with four components per texel to fill it.

It is basically the same as normal UNORM textures only that you get a value between -1.0 and 1.0 when sampling. The signed byte value is mapped -127 -> -1.0 and +127 -> 1.0. -128 is dropped.

Sampler type is sampler3D (Floating-point also covers normalized integer formats).

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ isampler is used for signed integer textures. so i am just confused between sample3D and isampler3D. \$\endgroup\$ – user1737197 Dec 10 '12 at 18:54
  • \$\begingroup\$ can you tell me why can't we use isampler3D here? \$\endgroup\$ – user1737197 Dec 10 '12 at 19:05
  • \$\begingroup\$ The samplers result is not an integer, its a float. If you want an integer you should use an integer texture format instead of a normalised one. Eg GL_RGBA8UI for an unsigned integer between 0 and 255. \$\endgroup\$ – Archy Dec 10 '12 at 19:50
  • \$\begingroup\$ When I use glbyte with sampler3d. Values less than 127 are taken as 0 and renders black for it, works correctly with 127 \$\endgroup\$ – user1737197 Dec 12 '12 at 14:41
  • \$\begingroup\$ Values less than 127 represent negative numbers in a SNORM (signed normalized) texture. Negative numbers get clamped to 0->black when you write them into a unsigned render target eg the back buffer. \$\endgroup\$ – Archy Dec 12 '12 at 14:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.