New answers tagged glsl
I believe that OpenGL's standard clipping volume is [-1, 1] x [-1, 1] x [-1, 1]. You want to clip at [-1, 1] x [-1, 1] x [0, 1]. You can achieve this by transforming the z-coordinate after all transformations have been applied to the vertex position (model, view and projection transforms). In other words, you want to operate on the screen coordinates of the ...
replace your whole if-statement with this: float vstep = step( u_bgColor.r, texColor.r); texColor.a = mix(0.1, u_lightIntensity/10.0, vstep); mix will select either the 1st argument of the mix if vstep == 0, or the 2nd otherwise (which is vstep == 1)
No, glsl can't have parameters in the main function (as well as return values). The doc says: Just like in C/C++, execution of a shader begins with the function main. This function takes no parameters and returns no values.
You have to send the data to the first address of the array, e.g. t glUniform1fv(glGetUniformLocation(_program, "t"), 2, threshold);
You can get this behaviour without a branch using the step function: float blendFactor = step(3.0f, dot(B.rgb, B.rgb)); return lerp(B, A, blendFactor); When B = (1, 1, 1), dot(B, B) = 3.0f, so step returns 1, blendFactor = 1, and the lerp gives a result of A. When B is anything less, dot(B, B) < 3.0f, so step returns 0, blendFactor drops to 0, and the ...
You have a very strange code here. Why do you have glDetachShader(program, vertex_shader); glDetachShader(program, fragment_shader); lines in your shader init code? They should be used when you destroy your shaders. Remove them completely or call them on quit. If it won't help, then I suspect that glDisableVertexAttribArray() resets vertex attribs' ...
Top 50 recent answers are included