Page 7 of 91

Re: "Questions that don't deserve their own thread" thread

Posted: Tue Aug 12, 2014 6:15 pm
by Ranguna259
I was wondering if there was a better way to draw a grid that is compatible with translation and scalling than this(use arrow keys and mouse wheel). Do you guys know of any better way ?

Re: "Questions that don't deserve their own thread" thread

Posted: Wed Aug 13, 2014 6:37 am
by Whatthefuck
I noticed that regardless of how large a quad's size is in the repeating mode, it doesn't seem to use more memory. Do quads have culling optimization?

Re: "Questions that don't deserve their own thread" thread

Posted: Wed Aug 13, 2014 7:59 am
by Plu
Ranguna259 wrote:I was wondering if there was a better way to draw a grid that is compatible with translation and scalling than this(use arrow keys and mouse wheel). Do you guys know of any better way ?
Probably. The idea is to draw a grid with lines, which are red if they're outside the 0,0 viewport and blue otherwise, with a scaling factor?

That's all?

Re: "Questions that don't deserve their own thread" thread

Posted: Wed Aug 13, 2014 2:27 pm
by Ranguna259
That's what the code already does, but it loops around 3 times throught all lines, it might get laggy, but if this is the best way then I might write this on the loveblog, if no one minds :P

Re: "Questions that don't deserve their own thread" thread

Posted: Wed Aug 13, 2014 2:55 pm
by slime
Whatthefuck wrote:I noticed that regardless of how large a quad's size is in the repeating mode, it doesn't seem to use more memory.
A Quad only has information about the position, size, and texture coordinates of the vertices drawn when you do love.graphics.draw(texture, quad, ...). The actual Quad object always has a constant size of ~80 bytes.

The repeating is done by the GPU when it draws the image to the screen (in the pixel shader stage in this example: http://data.simonschreibt.de/gat049/pip ... rview.webm ).
Whatthefuck wrote:Do quads have culling optimization?
GPUs don't rasterize pixels that aren't inside the screen, although I'm not sure if that's what you mean.

Re: "Questions that don't deserve their own thread" thread

Posted: Thu Aug 14, 2014 6:36 am
by Whatthefuck
slime wrote:
Whatthefuck wrote:I noticed that regardless of how large a quad's size is in the repeating mode, it doesn't seem to use more memory.
A Quad only has information about the position, size, and texture coordinates of the vertices drawn when you do love.graphics.draw(texture, quad, ...). The actual Quad object always has a constant size of ~80 bytes.

The repeating is done by the GPU when it draws the image to the screen (in the pixel shader stage in this example: http://data.simonschreibt.de/gat049/pip ... rview.webm ).
Whatthefuck wrote:Do quads have culling optimization?
GPUs don't rasterize pixels that aren't inside the screen, although I'm not sure if that's what you mean.
So basically I can have a huge quad that is meant for parallax scrolling and if the majority of it is off-screen it won't impact the performance at all?

Re: "Questions that don't deserve their own thread" thread

Posted: Thu Aug 14, 2014 7:38 am
by Plu
You'll still have to keep that huge image in memory, so that will impact performance somewhat (mostly in how much memory it'll take up).

Re: "Questions that don't deserve their own thread" thread

Posted: Thu Aug 14, 2014 7:54 am
by slime
Whatthefuck wrote:So basically I can have a huge quad that is meant for parallax scrolling and if the majority of it is off-screen it won't impact the performance at all?
If the quad is big but the image is not, yes (otherwise the image will be taking up a lot of space in RAM and VRAM.)

Re: "Questions that don't deserve their own thread" thread

Posted: Thu Aug 14, 2014 8:20 am
by Wojak
Ranguna259 wrote:That's what the code already does, but it loops around 3 times throught all lines, it might get laggy, but if this is the best way then I might write this on the loveblog, if no one minds :P
If you want just translation (no scaling), you know the exact grid size and no fancy color stuff I would recommend generating it with imageData and SpriteBatch and draw it all with one cal...

but if you want all the fancy stuff You may stil consider improving the performance bay not using love.graphic.line...

in love.load:

Code: Select all

line = love.image.newImageData(1,1)
line:setPixel(0,0,255,255,255,255)
line = love.graphics.newImage(line)
love.graphics.line = function(x,y,x1,y1)
	if x == 0 then
		love.graphics.draw( line, x, y, 0, x1, 1)
	else
		love.graphics.draw( line, x, y, 0, 1, y1)
	end
end

Re: "Questions that don't deserve their own thread" thread

Posted: Thu Aug 14, 2014 1:50 pm
by Ranguna259
Wojak wrote:

Code: Select all

line = love.image.newImageData(1,1)
line:setPixel(0,0,255,255,255,255)
line = love.graphics.newImage(line)
love.graphics.line = function(x,y,x1,y1)
	if x == 0 then
		love.graphics.draw( line, x, y, 0, x1, 1)
	else
		love.graphics.draw( line, x, y, 0, 1, y1)
	end
end
Are you saying that drawing a pixel and scalling it to look like a line would be faster then using the actual love.graphics.line() function ?
And since this removes the scalling compatibility then it would be no longer an optimization but rather a downgrade :P
Regarding the color fancy stuff, I just used colors to make the tutorial a little easier to understand.