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

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
molul
Party member
Posts: 264
Joined: Sun Feb 05, 2012 6:51 pm
Location: Valencia, Spain
Contact:

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

Post 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 4219 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 :)
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

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

Post 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
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
pgimeno
Party member
Posts: 3550
Joined: Sun Oct 18, 2015 2:58 pm

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

Post by pgimeno »

Try the examples in this thread: viewtopic.php?p=219237#p219237 (demo3d3 and rctest3)
User avatar
molul
Party member
Posts: 264
Joined: Sun Feb 05, 2012 6:51 pm
Location: Valencia, Spain
Contact:

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

Post 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?
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

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

Post 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.
User avatar
molul
Party member
Posts: 264
Joined: Sun Feb 05, 2012 6:51 pm
Location: Valencia, Spain
Contact:

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

Post 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?
Post Reply

Who is online

Users browsing this forum: No registered users and 114 guests