Crazy_Fox2
Member
I was making a shader to simulate the super Nintendo's Mode 7, and it more or less worked, but whenever I squished the image, another sprite would appear along side it as if it was part of that image. The two images are not part of the same sprite and I don't currently call the other sprite anywhere else.
Here is my code for the VSH:
And here is my code for the FSH:
Here is my code for the VSH:
Code:
attribute vec3 in_Position; // (x,y,z)
//attribute vec3 in_Normal; // (x,y,z) unused in this shader.
attribute vec4 in_Colour; // (r,g,b,a)
attribute vec2 in_TextureCoord; // (u,v)
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform vec4 ModeSev; // (H, V, X0, Y0)
uniform vec4 ModeSevTwo; // (A, B, C, D)
void main()
{
vec4 object_space_pos = vec4( in_Position.x, in_Position.y, in_Position.z, 1.0);
gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos;
float CoordAfterX = (in_TextureCoord[0] + ModeSev[0] - ModeSev[2]);
float CoordAfterY = (in_TextureCoord[1] + ModeSev[1] - ModeSev[3]);
float xPos = ((ModeSevTwo[0] * CoordAfterX) + (ModeSevTwo[1] * CoordAfterY));
float yPos = ((ModeSevTwo[2] * CoordAfterX) + (ModeSevTwo[3] * CoordAfterY));
v_vColour = in_Colour;
v_vTexcoord[0] = xPos;
v_vTexcoord[1] = yPos;
}
Code:
//
// Simple passthrough fragment shader
//
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
void main()
{
vec4 texColor = texture2D(gm_BaseTexture, v_vTexcoord);
gl_FragColor = v_vColour * vec4(texColor.r, texColor.g, texColor.b, texColor.a);
}