In the Heavens - Demo 0.1.16

Show off your games, demos and other (playable) creations.
Rigachupe
Party member
Posts: 100
Joined: Fri Jun 18, 2021 11:21 am

Re: In the Heavens - Demo 0.1.0

Post by Rigachupe »

Bobble68 wrote: Mon May 15, 2023 9:25 pm
Rigachupe wrote: Mon May 15, 2023 6:14 pm
Ah i see... there is this function to do the trick. It should work too with less code i suppose. Did not test it myself.
https://love2d.org/wiki/love.graphics.newMesh

PS:Yes, the 3D hidden inside the example is a preparation for later special light effects and other things. When optimized it should work nicely directly with the modern GPU's.
UnixRoot wrote: Mon May 15, 2023 5:57 pm That's really nice, but isn't your example a little over the top for drawing a textured mesh? I mean, only a few lines of code are missing for it to be a 3D engine. You can draw textured 2D meshes with a far simpler approach.
Are there any good examples of this I can look at? If I'm understanding correctly, I need to make 1 mesh per island, and need to place vertices where the pixels would normally go?
You think about polygon as one big object. But when you triangulate them you get for example 100 triangles that make one polygon. So the whole level would be 3000 triangles. A modern card can handle that. But you can be better. If you show only those triangles that are in the view that could be only 50.

I put here another demo that i remade to just use the love.graphics.newMesh without the 3D stuff and shaders. Papers added in the doc directory of the .zip file.
Attachments
Polygonizer2-230516-0840.zip
(41.89 KiB) Downloaded 658 times
User avatar
Bobble68
Party member
Posts: 162
Joined: Wed Nov 30, 2022 9:16 pm
Contact:

Re: In the Heavens - Demo 0.1.0

Post by Bobble68 »

Rigachupe wrote: Tue May 16, 2023 6:48 am
You think about polygon as one big object. But when you triangulate them you get for example 100 triangles that make one polygon. So the whole level would be 3000 triangles. A modern card can handle that. But you can be better. If you show only those triangles that are in the view that could be only 50.

I put here another demo that i remade to just use the love.graphics.newMesh without the 3D stuff and shaders. Papers added in the doc directory of the .zip file.
The issue isn't drawing textured polygons (though this is definately helpful for that), the trouble is getting the pixellated look I have. I suppose I might be able to use Bresenham's line algorithm to achieve the same thing, but that's just going to make more triangles.
Rigachupe wrote: Tue May 16, 2023 6:48 am If you show only those triangles that are in the view that could be only 50.
Don't meshes always draw all of their triangles?
Dragon
Rigachupe
Party member
Posts: 100
Joined: Fri Jun 18, 2021 11:21 am

Re: In the Heavens - Demo 0.1.0

Post by Rigachupe »

filtering.png
filtering.png (74.96 KiB) Viewed 218976 times
This is the problem solved. If i set nearest filter to image texture it will stay like this. But when you want to get a bigger resolution then you need to set the UV correctly so it spreads widely. For example for each 100 points of x,y coords i set 1 unit of u,v coords. Instead of smaller version when i use 10 points of x,y coords equals 1 unit u,v coords.

The meshes draw all triangles which you put in a mesh. That means. If i have a table of 100 triangles that makes one my polygon i can either split it into smaller tables and then prepare meshes. Or i will have one big mesh for 10 screens which maybe... i do not know... but theoretically will take more time to draw on screen. We are talking here mostly about miliseconds that could lead later to lags caused by drawing alone.

Are you drawing the triangles or polygons pixel by pixel into canvas?
User avatar
Bobble68
Party member
Posts: 162
Joined: Wed Nov 30, 2022 9:16 pm
Contact:

Re: In the Heavens - Demo 0.1.0

Post by Bobble68 »

Rigachupe wrote: Tue May 16, 2023 11:32 am filtering.png
Are you drawing the triangles or polygons pixel by pixel into canvas?
It's a mix, since love struggles with convex polygons so it automatically switches depending on if it's convex or not. The canvases are only drawn on when the polygons are first generated, it just stores them for drawing later
Dragon
pauljessup
Party member
Posts: 356
Joined: Wed Jul 03, 2013 4:06 am

Re: In the Heavens - Demo 0.1.0

Post by pauljessup »

A really beautiful demo, it holds a lot of promise. Have you thought of parallax scrolling clouds?
User avatar
Bobble68
Party member
Posts: 162
Joined: Wed Nov 30, 2022 9:16 pm
Contact:

Re: In the Heavens - Demo 0.1.0

Post by Bobble68 »

pauljessup wrote: Tue May 16, 2023 3:45 pm A really beautiful demo, it holds a lot of promise. Have you thought of parallax scrolling clouds?
Haha they're actually already a thing, just really really faint. They used to be more noticable in older versions, but I made the clouds more transparent to make the sky more blue. Maybe I should bring them back
Dragon
pauljessup
Party member
Posts: 356
Joined: Wed Jul 03, 2013 4:06 am

Re: In the Heavens - Demo 0.1.0

Post by pauljessup »

I think so!
Rigachupe
Party member
Posts: 100
Joined: Fri Jun 18, 2021 11:21 am

Re: In the Heavens - Demo 0.1.0

Post by Rigachupe »

I add some observation from my latest gameplay with the editor. The slowdown was visible when i zoomed to a far distance and then back so i would see almost the whole rock where the game starts. Then i moved with arrows to side and when i leave the polygon i only see a sky texture it goes with no problem. But after i enter the polygon in the next bigger rock formation i see a sudden shift with laggy movement.

Then it got unpleasant so i terminated the app with alt+f4. After that i waited a long time for windows to recover back so i do not have any memory information.

After that i suggest for you to try looking at the garbage collectors memory with gcinfo() or better functions to see how it spikes. Another suggestion would be to include a on/off key for collision detection and see if it is causing the lag. Just to be sure.

Hope it helps.
User avatar
Bobble68
Party member
Posts: 162
Joined: Wed Nov 30, 2022 9:16 pm
Contact:

Re: In the Heavens - Demo 0.1.0

Post by Bobble68 »

Rigachupe wrote: Tue May 16, 2023 6:48 am
Bobble68 wrote: Mon May 15, 2023 9:25 pm
Rigachupe wrote: Mon May 15, 2023 6:14 pm
Ah i see... there is this function to do the trick. It should work too with less code i suppose. Did not test it myself.
https://love2d.org/wiki/love.graphics.newMesh

PS:Yes, the 3D hidden inside the example is a preparation for later special light effects and other things. When optimized it should work nicely directly with the modern GPU's.
UnixRoot wrote: Mon May 15, 2023 5:57 pm That's really nice, but isn't your example a little over the top for drawing a textured mesh? I mean, only a few lines of code are missing for it to be a 3D engine. You can draw textured 2D meshes with a far simpler approach.
Are there any good examples of this I can look at? If I'm understanding correctly, I need to make 1 mesh per island, and need to place vertices where the pixels would normally go?
You think about polygon as one big object. But when you triangulate them you get for example 100 triangles that make one polygon. So the whole level would be 3000 triangles. A modern card can handle that. But you can be better. If you show only those triangles that are in the view that could be only 50.

I put here another demo that i remade to just use the love.graphics.newMesh without the 3D stuff and shaders. Papers added in the doc directory of the .zip file.

I'm trying out using meshes to draw the islands (still unsure how to pixelate the edges effectively), but I've got it to work with a repeating texture - issue is, it doesn't like convex shapes. Previously I fixed that by triagulating them if they're convex, but I'm not sure if that's a good idea here. The documentation says that fan mode shouldn't have any trouble with convex shapes, but thats the mode I'm using and it still messes up.
demo.png
demo.png (71.97 KiB) Viewed 218829 times

Code: Select all

local originalPoly = {
  0,0,
  100, 300,
  500,500,
  800,100,
  450,50,
  420,100
}






x = 1

local triangles = love.math.triangulate(originalPoly)

local scale = 5

function love.load()
  love.graphics.setDefaultFilter("nearest", "nearest")
  stone = love.graphics.newImage("stone.png")
  stone:setWrap("repeat")
  love.window.setMode(0,0)
  
  mesh = newTexturedMesh(stone, originalPoly, scale)
  
  
  
end



function newTexturedMesh(texture, vertices, scale)
  
  newVertices = {}
  for i = 1, #vertices, 2 do
    table.insert(newVertices, {originalPoly[i], originalPoly[i+1], originalPoly[i]/texture:getWidth()/scale, originalPoly[i+1]/texture:getHeight()/scale})
  end
    
  local mesh = love.graphics.newMesh(newVertices)
  mesh:setTexture(texture)
  
  return mesh
end


function love.draw()
  math.randomseed(0)
  for i, triangle in ipairs(triangles) do
    love.graphics.setColor(math.random(255)/255, math.random(255)/255, math.random(255)/255)
    love.graphics.polygon("fill", triangle)
    
  end
  
  
  love.graphics.setColor(1,1,1)
  love.graphics.draw(mesh, 1000, 0)
  
end
I'm not sure I have the skill or experience to properly fix this
Dragon
User avatar
darkfrei
Party member
Posts: 1204
Joined: Sat Feb 08, 2020 11:09 pm

Re: In the Heavens - Demo 0.1.0

Post by darkfrei »

Bobble68 wrote: Fri May 19, 2023 2:11 pm
I'm not sure I have the skill or experience to properly fix this
Just make the right mesh
https://en.wikipedia.org/wiki/Triangle_strip

Image

Update: sorry, for the fan mesh the first vertex must be 800,100 and other vertices in clockwise sequence to solve your problem.
Last edited by darkfrei on Fri May 19, 2023 4:01 pm, edited 3 times in total.
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
Post Reply

Who is online

Users browsing this forum: Amazon [Bot] and 2 guests