Tag Info

New answers tagged

1

Try setting the texture's minification filter to GL_NEAREST or GL_LINEAR after glTexImage2D(): glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); The OpenGL default is to use mipmaps and you didn't send any which makes the texture incomplete and will disable that texture ...


2

The value 127 / 255 is an integer division and always has the value zero. You want vec3(127.0 / 255.0, 0.0, 0.0) instead.


2

By default the output variable (outputColor) is bound to location 0. For a fragment shader this specifies the color value to be used for that fragment for the framebuffer object in position 0. You can bind the output variable to different locations in the application code using glBindFragDataLocation() or in the shader like this layout(location = 0) out ...


0

If you are computing the half-vector in the Vertex Shader and passing it to the Fragment Shader as an interpolated output, there is no guarantee that the normalized vector will remain unit length after being interpolated thru the triangle. So you should at least re-normalize it in the Fragment Shader.


3

It looks like you're applying way too much noise. You want to multiply the noise value by a small factor so it has a very small amplitude, corresponding to just a few pixels of distortion. Right now you're distorting it so much that every pixel is being sent to a completely different location in the texture, just making a hash of the whole thing. Also, ...


2

You're multiplying your vertex position and normal by the view matrix, change it to only use the model matrix. vec4 pos4 = model * vec4(vertex_position, 1.0); Change the normal_matrix to just be the inverse transpose of the model matrix only. glm::mat4 normal_matrix = glm::transpose(glm::inverse(modelMatrix));


0

In a forward a rendering approach (aka the built-in simple methods like you describe), it is correct to say that the scene must be rendered once per light. To achieve better performance with multiple lights, you need to use specialized rendering approaches via shaders that can accumulate multiple lights in one pass. The most popular of these techniques is ...


2

I've had the same problem several times and haven't found a way to specify a default color that would be used when a texture is not used. I've ended up creating 1x1 pixel fully white, black and transparent textures that are globally available. This does the job pretty well and is easy to use, although I don't like the unnecessary texture accesses in the ...


0

Here is where it comes the shader/material distinction. The shader is a GPU program that produces some lighting/shading effect. In your case you need to build a material system (albeit a simple one) where multiple materials can use the same shader, but pass different values for each material, that's one reason we have uniforms. Another point is, if some ...


0

Your problem seems trivial, so maybe I'm missing something. As you say that you want to compute the UVs for each fragment, I'm assuming that you are interested in the UVs of the fragment itself. Are you assigning UVs to your vertices or are computing them procedurally? In the first case, you will need to assign the UVs of each vertex in a varying ...



Top 50 recent answers are included