Textured Polygons for All!

Showcase your libraries, tools and other projects that help your fellow love users.
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 »

I don't get it. I can't get it to work in my project even when I copy everything important directly! All I get is a colored box of the color I setColor to. When I modify your code it works fine. But moving everything important into my project just results in a non-textured box. I've tried everything! This is frustrating!

Is there something I am missing? It makes no sense! I have combed over your code top to bottom and have replicated it exactly. No image. At all.

And before you ask, no, my computer is not old. It supports everything. The demo works perfectly. But the code refuses to move out of its natural habitat.

Edit: Now it's kind of working, but the texture edge pixels are bleeding off into infinity. Does the texture need to be surrounded by empty pixels?

Yeah. This definitely isn't ready for primetime yet. It seems that this thing completely takes over the rendering process overwriting anything else.
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 »

@Jasoco
I'm working on Polygons with parallel edges. I bet that's what was messing your project up, as the only time nothing shows up is when at least one pair of edges is parallel. I am almost done coding, then I'll move on to testing.

It did'nt in any way take over the rendering process, but did you already use pixel effects? If you did, texture.preload(true) was like love.graphics.setPixelEffect(monkey's pixel effect), but you don't have to worry about that anymore.

I'm almost done, hold on a few minutes!

EDIT: I'm done! Can I note that there is four times as much code required to account for all cases of parallel edges!?

Here is a special version just for you that doesn't need a preload function.


@Ref
Just... no. The beauty of this is that you don't have to do anything, it draws the polygon for you. Please use this as a module, the latest versions should not cause silly artifacts with silly 'fixes'.
Edit Aug 2019: "Please use this as a module" lol no please disassemble the code and assimilate it into your own if that suits you better, just keep my name in there
Last edited by xXxMoNkEyMaNxXx on Tue Aug 27, 2019 5:33 am, edited 1 time in total.
User avatar
Ref
Party member
Posts: 702
Joined: Wed May 02, 2012 11:05 pm

Re: Textured Polygons for All! [Parallel Edges Fixed]

Post by Ref »

I share Jasoco's frustrations.
Your 'effect' now works quite well - thanks so much - great work.
I have found that to use it, I had to strip out your supporting functions as they prevented much of what I wanted to do.
The problems I initially had related to useing fractional vertices coordinates. Once I use math.floor on them, the problems went away.

Minor points:

Really don't appreciate why you chose to use the left hand rule (clock wise point order) rather than the conventional right hand rule. Not a big deal but does require code rewriting. (currently looking for simple test to confirm my points meet your requirements)

Surprised that your function 'quad' didn't cleanup after itself - didn't end the PixelEffect().

Don't really see the need for 'preload' as gr.setPixelEffect( tex.effect ) & gr.setPixelEffect( ) work just fine and are documented.

Currently trying to see how I can convert 'po' and 'rep' to texture.x, texture.y, texture.width & texture.height so I can distribute texture over multiple quads.
Thanks again for your excellent work!!!!!
Attachments
textured_quad_test2.love
Texturizing with a stripped down pixel effect
(48.18 KiB) Downloaded 190 times
User avatar
markgo
Party member
Posts: 190
Joined: Sat Jan 05, 2013 12:21 am
Location: USA

Re: Textured Polygons for All! [Parallel Edges Fixed]

Post by markgo »

Whoa this is pretty nice, but I'm confused as to the significance of this. So does this mean one can apply texture to 3d polygons? Pretty cool stretching the quad in different directions. I noticed that the image on the quad gets heavily distorted when your view is parallel to its plane. That's not that big of a deal though.
User avatar
Ref
Party member
Posts: 702
Joined: Wed May 02, 2012 11:05 pm

Re: Textured Polygons for All! [Parallel Edges Fixed]

Post by Ref »

markgo wrote:So does this mean one can apply texture to 3d polygons? .
Darn! You guessed where I am heading.
User avatar
vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

Re: Textured Polygons for All! [Parallel Edges Fixed]

Post by vrld »

I took a look at infinity!
interesting.jpg
interesting.jpg (105.82 KiB) Viewed 3373 times
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine
User avatar
xXxMoNkEyMaNxXx
Party member
Posts: 206
Joined: Thu Jan 10, 2013 6:16 am
Location: Canada

Re: Textured Polygons for All! [Parallel Edges Fixed]

Post by xXxMoNkEyMaNxXx »

@markgo
It is heavily distorted because the image would look like that if you were viewing it on a surface at that angle.

@Ref
I've updated my effect to assume edges are parallel if they are nearly parallel, because the math degrades, and that's why you see the fuzziness and such. Please tell me what I would have to do so you could use it straight out of the box, because you're doing it all wrong. You send every single variable to it every single time, instead of only changing the ones that need to be changed.
Also, with the order of vertices, which vertex would you like it to start at for ccw?
I took a look at infinity!
I was doing that for a while when I added the repetition options :D
Last edited by xXxMoNkEyMaNxXx on Mon Jan 21, 2013 7:33 pm, edited 1 time in total.
User avatar
Ref
Party member
Posts: 702
Joined: Wed May 02, 2012 11:05 pm

Re: Textured Polygons for All! [Parallel Edges Fixed]

Post by Ref »

How unkind - all wrong?
Just very inefficient - only a first look-see.
Optimization later, if needed.
So far, pretty happy with what I've got.
Will see just how far I can push it.
For texturing, wouldn't triangles be more efficient as I believe OpenGL uses triangles internally.
User avatar
xXxMoNkEyMaNxXx
Party member
Posts: 206
Joined: Thu Jan 10, 2013 6:16 am
Location: Canada

Re: Textured Polygons for All! [Parallel Edges Fixed]

Post by xXxMoNkEyMaNxXx »

It's obviously not "all wrong", but it hurts my "must be efficient" OCD-ness. How can I make it so that you can use it right out of the box? I want it to just work, and not have potential problems that didn't exist before :/

With the order of vertices, which vertex would you like it to start at for ccw? Like top right etc.
User avatar
Ref
Party member
Posts: 702
Joined: Wed May 02, 2012 11:05 pm

Re: Textured Polygons for All! [Parallel Edges Fixed]

Post by Ref »

Why do you want to take all the fun out of it?
The reason I sent all the stuff each frame was that I was too lasy to create a separate effect for the second object.
The second object (rotating square) had all the vertices changes each frame sooo had to re-send.
Thanks again for you great effect!!!!
Just like to mess things up and see how they fall out.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 0 guests