Thursday, July 21, 2022
HomeGame Developmentopengl - Flawed leads to Fragment shader when utilizing clamped worth

opengl – Flawed leads to Fragment shader when utilizing clamped worth


I am following a tutorial and I need to clamp all place values of a triangle between 0 and 1 then output them as a colour

that is the code for my vertex shader:

#model 330                                        
                                                    
format (location = 0) in vec3 pos;                  
                                                   
out vec4 vCol;                                      
                                                   
uniform mat4 mannequin;                                
                                                   
void most important(){                                       
    gl_Position = mannequin * vec4(pos, 1.0);           
    vCol = vec4(clamp(pos, 0.0f, 1.0f) 1.0f);       
}

and that is the code for my fragment shader:

#model 330                                        
                                                   
in vec4 vCol;                                      
                                                    
out vec4 colour;                                    
                                                    
void most important(){                                        
    colour = vCol;                                   
}

these are coordinates of my form, which is a triangle (the values which might be going to be clamped):

GLfloat vertices[] = {
    -1.0f, -1.0f, 0.0f,
    1.0f, -1.0f, 0.0f,
    0.0f, 1.0f, 0.0f
};

end result I get is that this (fully black):
enter image description here

end result I ought to get is that this:
enter image description here

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments