genjimijonopo
Member
sorry if this is a repost not sure what im searching for :
As the title says im trying to make a vertex model of a sprite image split into two opposite directions with vertex shader sort of like in fruit ninja.
so in the draw event I send a uniform to the shader with a positive and negative value for both x and y (only x is needed);
I can then move the entire vertex image using the following code in the vertex shader :
////////////
//
// Simple passthrough vertex shader
//
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 vec2 posx[2];
float testitx, testity, testitx1, testity1;
void main()
{
testitx = posx[0].x;
testity = posx[0].y;
testitx1 = posx[1].x;
testity1 = posx[1].y;
vec4 object_space_pos = vec4( in_Position.x + testitx , in_Position.y + testity , in_Position.z, 1.0);
gl_Position = (gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos);
v_vColour = in_Colour;
v_vTexcoord = in_TextureCoord;
}
///
where posx[0] is positive x and posx[1] is negative but the problem im having is i do not know how to declare each individual triangle as a component in the shader. if anyone has any keywords I can search for to close topic thank you.
As the title says im trying to make a vertex model of a sprite image split into two opposite directions with vertex shader sort of like in fruit ninja.
so in the draw event I send a uniform to the shader with a positive and negative value for both x and y (only x is needed);
I can then move the entire vertex image using the following code in the vertex shader :
////////////
//
// Simple passthrough vertex shader
//
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 vec2 posx[2];
float testitx, testity, testitx1, testity1;
void main()
{
testitx = posx[0].x;
testity = posx[0].y;
testitx1 = posx[1].x;
testity1 = posx[1].y;
vec4 object_space_pos = vec4( in_Position.x + testitx , in_Position.y + testity , in_Position.z, 1.0);
gl_Position = (gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos);
v_vColour = in_Colour;
v_vTexcoord = in_TextureCoord;
}
///
where posx[0] is positive x and posx[1] is negative but the problem im having is i do not know how to declare each individual triangle as a component in the shader. if anyone has any keywords I can search for to close topic thank you.