@Simeon @John hey guys i’ve been struggling to figure out some FPS issues i’m seeing, i’ve been able to nail it down to mesh, for some reason once there’s a bunch of meshes the fps will yo-yo from 120 to 80
you can try to reproduce the issue with example here,
function setup()
parameter.number("xVal", 0, 100, 5)
parameter.number("yVal", 0, 100, 0)
m = mesh()
m:addRect(WIDTH/2,HEIGHT/2,600,600)
m.texture = asset.builtin.Cargo_Bot.Codea_Icon
m.shader = shader (vert, frag)
numInstances = 100
xValTable = {}
--cam = Camera({})
--gesture = GestureManager(cam)
end
function draw()
background(118, 33, 125)
--cam:drawOrtho()
for i =1, numInstances do
xValTable[i]=xVal*i
end
m.shader.xVal = xValTable
m.shader.yVal = yVal
m:draw(numInstances)
--cam:drawOrthoNoChange()
--FPSOverlay.draw()
end
function touched (t)
--gesture:touchCallback(t)
end
vert=[[
#extension GL_EXT_draw_instanced: enable
uniform mat4 modelViewProjection;
attribute vec4 position;
attribute vec2 texCoord;
varying vec2 vTexCoord;
uniform float xVal[1019]; // set 1020 to trigger render error
uniform float yVal;
varying lowp float index;
void main() {
index = float (gl_InstanceIDEXT);
vTexCoord = texCoord;
float xOffset = ceil(float(xVal[gl_InstanceIDEXT]));
float yOffset = yVal;
vec4 offset = vec4(xOffset, yOffset, 0, 0);
gl_Position = modelViewProjection * (position+offset);
}
]]
frag=[[
#extension GL_EXT_draw_instanced: enable
precision highp float;
uniform sampler2D texture; //diffuse map
varying vec2 vTexCoord;
varying float index;
void main() {
gl_FragColor = texture2D(texture, vTexCoord);
}
]]
one thing i noticed as well it’s that using ortho can have an effect on the FPS, you might notice some commented out lines above, please use the attached dependencies to enable these, OrthoCamera will adjust the zoom, Gesture will handle two finger pinch zooming, FPSOverlay will show the fps timeline
…
what’s EVEN STRANGER is that if i go to screen record the FPS, it will stay at 120 lol!! , so i if the screen recorded is running, Codea will not fall under 120 FPS , but stop recording, let the program simply run and all the sudden the FPS is yo-yo again see attached images
while screen recording- https://codea.io/talk/uploads/editor/8n/6t46rse26s6o.png
normal project playing- https://codea.io/talk/uploads/editor/rs/ysnge4xs1wfk.png
…
i wish i could profile these issues myself and not have to get you guys involved if it’s not necessary, i’m also hoping that Codea4 will just magically make mesh performance better