Page 1 of 1

Is it possible to make an animated perspective texture WITHOUT a shader?

Posted: Tue Jul 24, 2018 6:27 am
by molul
I was using xXxMoNkEyMaNxXx's Textured polygon's module to achieve this effect on LÖVE 11.1: https://www.youtube.com/watch?v=AMZxC9aE7wo

This would be the background for a frontend I'm developing for a Rockchip RK3066 board. However, although its renderer info says "OpenGL ES 2.0", even a simple shader like drawing all pixels red affects makes performance drop 10fps (20fps with xXxMoNkEyMaNxXx's's shader, which also doesn't display correctly), so I have to either figure out another way to make it or just forget about it.

I was trying with a mesh, but I get the usual "bad perspective" look:
persp.png
persp.png (60.16 KiB) Viewed 4390 times
I tried adding more vertices but I don't think I'll get a nice look with this.

Before dropping this feature, I'd like to ask for any advice you might have.

Thanks a lot in advance :)

Re: Is it possible to make an animated perspective texture WITHOUT a shader?

Posted: Tue Jul 24, 2018 11:47 am
by Nixola
You could try using a vertex shader instead of a pixel shader; I don't actually know how much they affect performance, but I'd guess much less since the code only runs once per vertex instead of once per pixel

Re: Is it possible to make an animated perspective texture WITHOUT a shader?

Posted: Tue Jul 24, 2018 5:39 pm
by pgimeno
Try the examples in this thread: viewtopic.php?p=219237#p219237 (demo3d3 and rctest3)

Re: Is it possible to make an animated perspective texture WITHOUT a shader?

Posted: Thu Jul 26, 2018 5:22 pm
by molul
Wow... Thank you very much, pgimeno! :O

With your lib I get around 40fps on my app displaying a couple of perspective textures, but more important: it actually works! The other shader just made the screen blink ^^U

I'm having a friend helping me on this project building LÖVE for the Rockchip (he's currently trying to implement triple buffer on SDL hoping to get a performance boost), so we might get to 60fps. Crossing fingers!

-----

[EDIT]
I just noticed that, with vsync disabled, I get ~470fps on my laptop if I don't animate the mesh's UVs, going down to ~300fps if I do, which seems a bit too much, doesn't it?

I'm using this function in love.update (CUIBg is a class for the all elements in the background):

Code: Select all

function CUIBg:UpdatePerspectiveTestUVs(dt)
	local inc = 1.6
	for i = 1, self.rcVertextCount, 1 do
		local x, y, z, u, v, r, g, b, a = self.rc.mesh:getVertex( i )
		v = v - inc * dt
		self.rc.mesh:setVertex( i, { x, y, z, u, v, r, g, b, a } )
	end
end
More precisely, it's the line "self.rc.mesh:setVertex( i, { x, y, z, u, v, r, g, b, a } )" that drops performance so much. "getVertex" doesn't seem to affect.

Am I animating UVs correctly? Is there a more efficient system to animate a mesh's UVs?

Re: Is it possible to make an animated perspective texture WITHOUT a shader?

Posted: Fri Jul 27, 2018 7:16 am
by grump
molul wrote: Thu Jul 26, 2018 5:22 pm Is there a more efficient system to animate a mesh's UVs?
Yes... a vertex shader.

Re: Is it possible to make an animated perspective texture WITHOUT a shader?

Posted: Fri Jul 27, 2018 7:18 am
by molul
I'm currently using pgimeno's lib, which uses a vertex shader drawing a texture on a mesh. Do you mean I should animate the UVs in the very shader instead of on the mesh?