Page 2 of 15

Re: Textured Polygons for All!

Posted: Mon Jan 21, 2013 4:24 am
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.

Re: Textured Polygons for All!

Posted: Mon Jan 21, 2013 5:16 am
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

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

Posted: Mon Jan 21, 2013 6:25 pm
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!!!!!

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

Posted: Mon Jan 21, 2013 6:48 pm
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.

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

Posted: Mon Jan 21, 2013 6:54 pm
by Ref
markgo wrote:So does this mean one can apply texture to 3d polygons? .
Darn! You guessed where I am heading.

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

Posted: Mon Jan 21, 2013 7:01 pm
by vrld
I took a look at infinity!
interesting.jpg
interesting.jpg (105.82 KiB) Viewed 3377 times

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

Posted: Mon Jan 21, 2013 7:22 pm
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

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

Posted: Mon Jan 21, 2013 7:33 pm
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.

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

Posted: Mon Jan 21, 2013 7:42 pm
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.

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

Posted: Mon Jan 21, 2013 7:51 pm
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.