Tag Info

New answers tagged

0

Do I need to pass a 4D vector with values (x,y,z,w), where w = z? No, you don't need to. And this would even be wrong, w is 1 for positions and 0 for directions. When you want to multiply the vertex with a mat4 usually you convert it to a vec4 on the fly with vec4(your_position, 1.0). In the vertex shader code, do I need to manually divide the x and ...


0

Updated with a minor fix: Yes, the problem was: textCoo -= deltaTextCoord; Due to the fp precision the error accumulated grows to something like 2.7%. Calculating it each loop instead of subtracting a delta fixes a big part of the problem. As for optimization, I am using some techniques, got a reasonable 40fps. See this post, I asked the same ...


0

You don't need the mix calls if start and end are always 0 and 1, respectively. If you want a trapezoid: vec2 dist(vec2 coord){ vec2 pos; pos.y = in_Val_0.x; vec2 trapezoidSize = vec2(0.2, 0.8); //0.2 baseSize; 0.8 topSize; float t = trapezoidSize.x + trapezoidSize.y*coord.y; pos.x = t * in_Val_0.x; return coord * pos; } If you ...


1

No, that's not how shaders work. If you want to use a shader to manipulate a texture, you need to set up a render-to-texture operation. Create a result texture, bind it as the render target, bind your input texture as a regular input texture, and bind the shader you want to execute "once." Render a fullscreen quad mapped with the input texture using the ...


0

no, you cannot stop shaders. That would break the render pipeline and as a result you would break rendering. Doing such a sweep is simply setting the uniforms to the needed values from your application (for ex. incrementing the texture position values on each iteration). Inside your application, you know the size of the underlying object and can stop using ...


0

I had exactly this problem. To verify my operations to the framebuffer, I was drawing the framebuffer texture back to the screen using a simple GL_QUAD. But it was not giving correct output since I was not setting glUseProgram(0) before drawing that quad. So the correct sequence of operations goes something like this: glBindFramebuffer(GL_FRAMEBUFFER, ...


0

You were pretty much looking for the same thing I was, and I also found a solution using GLSL. I answered my own question here - GLSL 2D Silhouette - It's done using libGDX, but the solution should be adaptable to any engine with the same capabilities.


1

I solved it! Here is the process I followed: Render Lower Tiled Map Layers Render Entities Render Upper Tiled Map Layers Render Upper Tiled Map Layers to stencil buffer Render Entities using the stencil buffer with a simple color fragment shader The code. Rendering the upper map layer: // Render the top map layer normally renderer.render(layerIndeces); ...


0

Yes, you should always normalize light computation vectors. dot(N, L) = cos(angle(N, L)) * length(N) * length(L), so, if vectors are normalized max(0.0, dot(N,L)) will get you values in the range of [0,1] which is exacly what you want. 0 being light perpendicular to surface normal, 1 being light pointing exaclyt at the same direction of normal (thus ...


1

You need to check two things: 1.Texture and Shader ETC1 doesn't support alpha. You'd have to use a separate texture read (which you seem to be doing on texture2D(CC_Texture1, v_texCoord2). You can use tools to extract alpha channel from a RGBA texture and use a single texCoord for both samplers. Your code could be something like this: vec3 tex = ...


0

Of course you should normalize it - it isn't the Lambert term if it isn't normalized. Lambert term = max(cos(angle between direction to light and surface normal),0) And (in HLSL-ish pseudocode): dot(A,B) = cos(angle(A,B)) * length(A) * length(B) So to get dot(A,B) = cos(angle(A,B)), length of both vectors must be equal to 1 (which is what normalization ...


0

Of course right after I post this I realize what I did wrong: // Attach then link shaders GLuint shaderProgram; should be // Attach then link shaders GLuint shaderProgram = glCreateProgram();



Top 50 recent answers are included