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 »

vrld wrote:
Jasoco wrote:The reason OpenGL triangles work is because they're receiving XYZ coordinates.
Sorry, but this is not true. Texture has (almost) nothing to do with perspective.
In addition of screen coordinates, you provide texture coordinates that define how the texture is mapped onto the polygon.

Shameless plug: There is a good chance that there will be support for textured polygons in LÖVE 0.9.
Well, Mr. Smartypants. If I'd known that, I'd be coding in OpenGL. :P

I wish I could play with 0.9.0 now though. Any idea what year it might be coming out? :joker:

Haha, I'm in a sarcastic mood today. Must be the flu virus going through my head right now.
User avatar
Ref
Party member
Posts: 702
Joined: Wed May 02, 2012 11:05 pm

Re: Textured Polygons for All!

Post by Ref »

xXxMoNkEyMaNxXx wrote:This is exactly what I was trying to say. How do you want me to implement it?
Sorry about previous response and delayed clarification but am busy getting ready for a trip.
Will try to describe what I would like by giving a simple example:
Take an equilateral triangle (tr1,tr2,tr3).
Take a piece of a texture (defined by tx1, tx2, tx3) that is exactly the same size and put it on the triangle.
Now distort the triangle my moving one or more of the vertices and have the same piece of texture (same vertices tx1, tx2, tx3) distort to fit the new shape (just like what happens with the textured quad but with one less point).
User avatar
slime
Solid Snayke
Posts: 3166
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Textured Polygons for All!

Post by slime »

Jasoco wrote:I wish I could play with 0.9.0 now though. Any idea what year it might be coming out? :joker:
Hopefully next week.

I hope no one takes me seriously :O
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 »

slime wrote:
Jasoco wrote:I wish I could play with 0.9.0 now though. Any idea what year it might be coming out? :joker:
Hopefully next week.

I hope no one takes me seriously :O
I want to take you seriously. But it's way too unbelievable. 0.8.1 would be only slightly more believable.
User avatar
slime
Solid Snayke
Posts: 3166
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Textured Polygons for All!

Post by slime »

"Hopefully next week" in Valve Time is 9 months later, according to the wiki link. Maybe I should have said "today's update" instead. :P

In all seriousness though, you can try out what's currently in the 0.9.0 changes yourself by compiling the source code from the "minor" branch (or the "default" branch, which has many more changes including vertex shader support and doesn't break API compatibility yet).

The 'Geometry' textured polygon implementation hasn't been merged into the official LÖVE repository yet - you can get it here.
Last edited by slime on Fri Feb 15, 2013 10:34 pm, edited 6 times in total.
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Textured Polygons for All!

Post by Nixola »

Heh, I think he knows
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
Codex
Party member
Posts: 106
Joined: Tue Mar 06, 2012 6:49 am

Re: Textured Polygons for All!

Post by Codex »

I've been keeping my eye on this lib for an idea for a 3D game possibly. Something along the lines of a voxel cube based game, minecraft-like, but with a huge twist that I won't disclose just yet.

I read somewhere that to transverse the z-axis in lua hampers performance quite a bit, so I had an idea. Why not use a 2D array and store the z-axis information as a number?

IE.

z-axis is 10 cubes long. Let's say that you can only insert 3 different cube types. (air, dirt, grass) -- assuming a minecraft like example
air = 1,
dirt = 2,
grass = 3,

So at map[y][x] = num

Code: Select all

num = 1
  [x][y][1] = 1 -- air
  [x][y][2-10] = 1 -- rest of blocks are air 
num = 2
  [x][y][1] = 2 -- dirt
  [x][y][2-10] = 1 -- rest of blocks are air 
num = 3
  [x][y][1] = 3 -- grass
  [x][y][2-10] = 1 -- rest of blocks are air 
num = 4
  [x][y][1] = 1 -- air
  [x][y][2] = 2 -- dirt 
  [x][y][3-10] = 1 -- rest of blocks are air
num = 5
  [x][y][1] = 2 -- dirt
  [x][y][2] = 2 -- dirt
  [x][y][3-10] = 1 -- rest of blocks are air
num = 6
  [x][y][1] = 3 -- grass
  [x][y][2] = 2 -- dirt
  [x][y][3-10] = 1 -- rest of blocks are air
Hopefully you can see the pattern here.

so you have 59049 (3^10) range of possibilities. Insert some fancy math division to determine what block type on a z-axis location is, and whoolah!

Code: Select all

[x][y][1] = (num % 3) + 1
[x][y][2] = math.floor( (num % 9)/3) + 1
[x][y][3] = math.floor( (num % 81)/3) + 1
...

-- or this basically,

[x][y][z] = math.floor( (num % 3^z)/3) + 1   -- unless [z] = 1 then omit the math.floor part


I'm not sure if this would be any faster than just using a z-axis table to look up this information. The math algorithm you use to break up the z-axis can be localized (since it will be called repeatedly) and be a little faster. So the question comes down to which way is faster to access the Z-axis: looking up a third [z] axis table or using a bit of math on a 2D array to figure out your [z] info? Not sure how to test this... Also the number of block types and the size of the z-axis have a limit. (25 block types with a 10-size z-axis OR 5 block types with a 20-size z-axis --- approaches the Lua rounding error limit)

hmmm... on second thought if you turned into a string that limit would be MUCH bigger, but I imagine it would require more math.

:crazy:
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 »

I think that the most efficient way to store voxel data is in chunks. It does mean a 2D (or 3D, if you want infinite height) table of chunks, which are of course already 3D tables (but of constant size, so may be stored as a 1D table).

For clarification: by z-axis, do you mean up? It's always made more sense to me that up would be the y-axis. :brows:
User avatar
Ref
Party member
Posts: 702
Joined: Wed May 02, 2012 11:05 pm

Re: Textured Polygons for All!

Post by Ref »

While waiting for xXxMonkEyMaNxXx to come up with textured triangles ... Ahm........
Attachments
TexturedCube.love
Texture applied to a cube.
(612.49 KiB) Downloaded 164 times
User avatar
Codex
Party member
Posts: 106
Joined: Tue Mar 06, 2012 6:49 am

Re: Textured Polygons for All!

Post by Codex »

xXxMoNkEyMaNxXx wrote:
For clarification: by z-axis, do you mean up? It's always made more sense to me that up would be the y-axis. :brows:
Yes I do mean up, but I've always thought "up" referenced in 3D as the z-axis was the standard.
Ref wrote:While waiting for xXxMonkEyMaNxXx to come up with textured triangles ... Ahm........
Nice! :ultrashocked:
Post Reply

Who is online

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