opengl - Sampling unsigned integer texture data in a shader -


I want to render an unsigned integer texture with a piece shider using the following code:

  glTexImage2D (GL_TEXTURE_2D, 0, GL_R8UI, width, height, 0, GL_RED_INTEGER, GL_UNSIGNED_BYTE, data);   

and part of the piece sha ader code:

  # version 330 Uniform UEmpler 2D Tech; Zero main (zero) {vec3 vec_tex; Vec_tex = (textx (tex), TexCoordOut) .r}   

It is written in OpenGL programming guide , if I want to To get an integer in Shader, then I should use an integer sample type, an integer internal format, and an integer external format and type. As the external type, the form of data as GL_UNSIGNED_BYTE , we are the internal code, GL_RED_INTEGER as GL_R8UI I am in shader usampler2d , but when the file file begins to render, there is always a mistake of error for "int" to "uint" . It seems that texture data is stored as int, and unsigned samples can not change it. But I used the GL_R8UI as the internal code, so textual data should be stored as unsigned. Why unsigned samples are only signed signatures? How do I solve this problem? Texture function call is not correct; Second, the value that is in shader by 255.0 (as you can see in GL_R8UI Need to be divided) by dividing the RGBA components and controlling the return and slice color output.

  Uniform UEmpler 2D Tech; Outside the uvecy3outer; Zero main (zero) {uvec3 vec_tex; Vec_tex = Texture (Texcos, TexcoreAut) Output = VC3 (Float (Week_tex. R) / 255, Float (Week_tex. G) / 255, Float (Week_tex.b) / 255)}   / div> 

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -