Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Gerard Wensink

Pages: [1]
1
Graphics / Add clipping texture with shader
« on: May 26, 2018, 11:38:18 am »
Hello. I draw sprites using a shader, AFTERWARDS i want to clip the resulting texture. (Cutting of top,bottom,left and/or right, by making it transparant or so).

I can do it by drawing the sprite with the shader in a texture, then clip the texture, then draw it on to the renderwindow, but i use a lot of these sprites, and things get slow.

This is my shader witch i use on lots of 64x72 pixel sprites:

uniform float wave_phase;
uniform vec2 wave_amplitude;

void main()
{
    vec4 vertex = gl_Vertex;
    vertex.x += (cos(gl_Vertex.y * 0.02 + wave_phase * 3.8)  + sin(gl_Vertex.y * 0.02 + wave_phase * 6.3) * 0.3) * wave_amplitude.x;
    vertex.y += (sin(gl_Vertex.x * 0.02 + wave_phase * 2.4)  + cos(gl_Vertex.x * 0.02 + wave_phase * 5.2) * 0.3) * wave_amplitude.y;

    gl_Position = gl_ModelViewProjectionMatrix * vertex;
    gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
    gl_FrontColor = gl_Color;
}

Somebody have any idea how to clip the resulting texture? Like with 4 parameters for clipping the top,bottom, left and/or right of the texture?

Thanks in advance.

See example video: Clipping is now done before the shader changes size/position, then clipping is not correct.
I want the sprites to go under the viaduct properly cut off.




2
SFML projects / PACMAN / MAZE / MULTIPLAYER / NETWORK
« on: March 19, 2018, 06:31:57 pm »
Pacman game devellopment. Check it out at:
https://github.com/crazybytes/PACMAN

Pages: [1]
anything