Do I have the wrong approach with meshes?

Hey, I tried to do something with meshes because I want things to be faster and use shaders…
How many meshes should I use?

I tried this but it seems pretty slow, that can’t be right. I’m working on a side scroller and everything near the bottom should have a shader reflection…

Is my approach wrong?



Ship = class()



function Ship:init(x,y)

    self.x = x
    self.y = y
    self.m = mesh()
    self.m.texture=("SpaceCute:Rocketship")
    self.rIdx = self.m:addRect(0, 0, 0, 0)
    self.m:setRect(self.rIdx, 0, 0,64,64)
    
end

function Ship:draw()

pushMatrix()
translate(self.x, self.y)
    self.m.shader = nil
    -- Draw the mesh
        self.m:draw()
    translate(0, -64)
    

    
      self.m.shader = shader("Documents:Myripple")



    -- Configure out custom uniforms for the ripple shader
    self.m.shader.time = ElapsedTime
    self.m.shader.freq = 2
    
    self.m:draw()

    popMatrix()
    
end

function setup()
   myship={}
    for i=0 , 10 do
     myship[i] =  Ship(30+(i*64),250)
    end
    
    
end

-- This function gets called once every frame
function draw()
    -- This sets a dark background color 
    background(0, 0, 0, 255)


    for i=0 , 10 do
        myship[i]:draw()
    end
    
end

Any ideas?

Thanks

The issue is asigning the shader every draw frame. Create a second mesh in each Ship:init with the shader attached.

For something that’s not going to be repeated many times, I just use plain old sprite and save mesh for the background or multiple objects.