Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

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).

share|improve this answer
    
isampler is used for signed integer textures. so i am just confused between sample3D and isampler3D. –  user1737197 Dec 10 '12 at 18:54
    
can you tell me why can't we use isampler3D here? –  user1737197 Dec 10 '12 at 19:05
    
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. –  Archy Dec 10 '12 at 19:50
    
When I use glbyte with sampler3d. Values less than 127 are taken as 0 and renders black for it, works correctly with 127 –  user1737197 Dec 12 '12 at 14:41
    
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. –  Archy Dec 12 '12 at 14:44
show 9 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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