## Textured Polygons for All!

xXxMoNkEyMaNxXx
Party member
Posts: 206
Joined: Thu Jan 10, 2013 6:16 am

### Textured Polygons for All!

*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'
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()
end

v2
-Fixed image being rotated one quarter turn ccw.
v3
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!

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!
Last edited by xXxMoNkEyMaNxXx on Tue Feb 12, 2013 7:22 am, edited 20 times in total.

Darky
Citizen
Posts: 65
Joined: Sat Jun 02, 2012 1:41 pm
Contact:

### Re: Textured Polygons for All!

not " for All! "
http://darky-ben.fr/Xut my webcomic (french)

IndieKid
Citizen
Posts: 80
Joined: Sat Dec 22, 2012 7:05 pm
Contact:

### Re: Textured Polygons for All!

That is just what I need!

xXxMoNkEyMaNxXx
Party member
Posts: 206
Joined: Thu Jan 10, 2013 6:16 am

### Re: Textured Polygons for All!

Lol, sorry Darky. Consider finding or getting a machine or GPU that supports pixel effects, the potential is simply amazing.

Ref
Party member
Posts: 674
Joined: Wed May 02, 2012 11:05 pm

### Re: Textured Polygons for All!

Question!
Why is the texture rotated 90 degrees counter clockwise?

xXxMoNkEyMaNxXx
Party member
Posts: 206
Joined: Thu Jan 10, 2013 6:16 am

### Re: Textured Polygons for All!

Ah, I've fixed it.

At least it wasn't mirrored :L
My excuse: The test image was rotationally symmetrical!

Ref
Party member
Posts: 674
Joined: Wed May 02, 2012 11:05 pm

### Re: Textured Polygons for All!

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
Simple test - everyting moved into main.lua

xXxMoNkEyMaNxXx
Party member
Posts: 206
Joined: Thu Jan 10, 2013 6:16 am

### Re: Textured Polygons for All!

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?

Jasoco
Inner party member
Posts: 3629
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

### Re: Textured Polygons for All!

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!

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

### Who is online

Users browsing this forum: No registered users and 4 guests