How would I set up this
//
// bug eye vertex shader
//
//This is the current model * view * projection matrix
// Codea sets it automatically
uniform mat4 modelViewProjection;
//This is the current mesh vertex position, color and tex coord
// Set automatically
attribute vec4 position;
attribute vec4 color;
attribute vec2 texCoord;
//This is an output variable that will be passed to the fragment shader
varying lowp vec4 vColor;
varying highp vec2 vTexCoord;
void main()
{
gl_Position = modelViewProjection * position;
//Pass values to our fragment shader
vColor.rgb = color.rgb * color.a;
vColor.a = color.a;
vTexCoord = vec2(texCoord.x, 1.0 - texCoord.y);
}
//
// Ripple fragment shader
//
//This represents the current texture on the mesh
uniform lowp sampler2D texture;
//The interpolated vertex color for this fragment
varying lowp vec4 vColor;
//The interpolated texture coordinate for this fragment
varying highp vec2 vTexCoord;
uniform highp float time;
uniform highp float freq;
void main()
{
highp vec2 tc = vTexCoord.xy;
highp vec2 p = 2.0 * tc;
highp float len = length(tc);
highp vec2 uv = tc+ freq*tan(p*24.0-time*4.0)*0.03;
highp vec4 col = texture2D(texture,uv);
gl_FragColor = vec4(col.rgb * vColor.rgb, col.a);}
Ok got it working but right now it’s only showing half of it like a triangle any help to make it all
This is my finished version but its slow any help
-- minez start
-- Use this function to perform your initial setup
function setup()
-- Create a mesh
myMesh = mesh()
end
-- This function gets called once every frame
function draw()
myMesh.shader = shader("Documents:Codea")
rIdx = myMesh:addRect(0, 0, 0, 0)
-- Set vertices
-- Assign a texture
myMesh.texture = "Documents:minez"
local cw,ch = spriteSize(myMesh.texture)
myMesh:setRect(rIdx, WIDTH/2, HEIGHT/2, cw, ch)
-- Set all vertex colors to white
myMesh:setColors(255,255,255,255)
myMesh.shader.time = ElapsedTime
myMesh.shader.freq = 0.1
-- Draw the mesh
myMesh:draw()
end
I suggest that you do not set up repeatedly (in draw()
) the things that only need to be set up once:
-- minez start -- Use this function to perform your initial setup function setup() -- Create a mesh myMesh = mesh() myMesh.texture = "Documents:minez" local cw,ch = spriteSize(myMesh.texture) myMesh.shader = shader("Documents:Codea") local rIdx = myMesh:addRect(0, 0, 0, 0) myMesh:setRect(rIdx, WIDTH/2, HEIGHT/2, cw, ch) myMesh:setColors(255,255,255,255) myMesh.shader.freq = 0.1 end -- This function gets called once every frame function draw() myMesh.shader.time = ElapsedTime -- Draw the mesh myMesh:draw() end ```
Ok thanks