Textured Polygons for All!

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
xXxMoNkEyMaNxXx
Party member
Posts: 206
Joined: Thu Jan 10, 2013 6:16 am
Location: Canada

Textured Polygons for All!

Post by xXxMoNkEyMaNxXx »

*It should actually be called textured quadrilaterals, but that's irrelevant.
*You need a GPU that supports pixel effects.
Perspective.lua
The only required file. V8 require'Perspective'
(4.62 KiB) Downloaded 1667 times
After hours of thinking and math, here's what everyone's been waiting for!

Usage:

Code: Select all

local texture=require'Perspective'
function love.draw()
	texture.quad(image,vertex1,vertex2,vertex3,vertex4)
end
Updates:
v2
-Fixed image being rotated one quarter turn ccw.
v3
-Added parallel edge support.
v4
-If image is nil, no image will be drawn.
-If only the vertices are given (e.g. texture.quad(v1,v2,v3,v4) ) the function will behave properly.
v5
-Added tiled textures, see Demo's source code.
v6
-Fixed repeat options to work like expected
-Many small tweaks
v7
-Assume edges are parallel if it's close, otherwise the math would degrade.
-Clear effect after writing image
v8
-Change scaling to image-based instead of polygon-based (More intuitive)

Known issues:
-Does not display properly when using love's built in push and pop stuffs.

I'm so excited to see what people will make with this! :awesome:

Also, please tell me what I should do so you can be comfortable using it straight out of the box.

Controls for Demo:
Click and drag the corners of the image.
Demo v8.love
Try uncommenting in main.lua!
(207 KiB) Downloaded 1669 times
Last edited by xXxMoNkEyMaNxXx on Tue Feb 12, 2013 7:22 am, edited 20 times in total.
User avatar
Darky
Citizen
Posts: 66
Joined: Sat Jun 02, 2012 1:41 pm
Contact:

Re: Textured Polygons for All!

Post by Darky »

not " for All! "
Image
http://darky-ben.fr/Xut my webcomic (french)
User avatar
IndieKid
Citizen
Posts: 80
Joined: Sat Dec 22, 2012 7:05 pm
Contact:

Re: Textured Polygons for All!

Post by IndieKid »

That is just what I need!
User avatar
xXxMoNkEyMaNxXx
Party member
Posts: 206
Joined: Thu Jan 10, 2013 6:16 am
Location: Canada

Re: Textured Polygons for All!

Post by xXxMoNkEyMaNxXx »

Lol, sorry Darky. Consider finding or getting a machine or GPU that supports pixel effects, the potential is simply amazing.
User avatar
Ref
Party member
Posts: 702
Joined: Wed May 02, 2012 11:05 pm

Re: Textured Polygons for All!

Post by Ref »

Question!
Why is the texture rotated 90 degrees counter clockwise?
User avatar
xXxMoNkEyMaNxXx
Party member
Posts: 206
Joined: Thu Jan 10, 2013 6:16 am
Location: Canada

Re: Textured Polygons for All!

Post by xXxMoNkEyMaNxXx »

Ah, I've fixed it.

At least it wasn't mirrored :L
My excuse: The test image was rotationally symmetrical!
User avatar
Ref
Party member
Posts: 702
Joined: Wed May 02, 2012 11:05 pm

Re: Textured Polygons for All!

Post by Ref »

Trying to get your code into a form that I'm comfortable using - so please forgive mess I've made of your code.
It seems that your effect is not too robust for certain geometries.
(I did add someting to keep boundaries from being parallel but still had problems.)
If you have the time, I'd like to know what I'm doing wrong.
Attachments
Quad_Texture_Test.love
Simple test - everyting moved into main.lua
(47.31 KiB) Downloaded 901 times
User avatar
xXxMoNkEyMaNxXx
Party member
Posts: 206
Joined: Thu Jan 10, 2013 6:16 am
Location: Canada

Re: Textured Polygons for All!

Post by xXxMoNkEyMaNxXx »

Oh dear... I'll just add parallel edge support to GLSL. XD I was planning on doing it anyway.
It seems that your effect is not too robust for certain geometries.
Which part are you talking about?
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Textured Polygons for All!

Post by Jasoco »

This could be the greatest thing I have ever asked for. I am going to try and implement this into my game tonight and post the results. Oh boy.

I think Ref was talking about how the points can't go concave or else the image warps to unrecognizable. Which is fine for me. I am curious why Ref's demo has a rotating image that distorts if it's not at a 90º angle.
scutheotaku
Party member
Posts: 235
Joined: Sat Dec 15, 2012 6:54 am

Re: Textured Polygons for All!

Post by scutheotaku »

I don't have much else to say except - excellent work!!!
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests