Page 2 of 91

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

Posted: Wed Jul 16, 2014 9:56 pm
by Ranguna259
Oh I didn't detect his sarcasm :P , I can't create a new file because the images are going to be dynamicly modified, and the 4096x4096 image was just an exemple, I'm not gonna use an image that big (some GPU can't even handle those kind of dimensions).
I don't think that making them smaller in LOVE (using the scale factor) would have any impact in the memory being used.

I tried canvases and I think it worked, , I load 149 images into the game without using canvas:

Code: Select all

for i,v in ipairs(love.filesystem.getDirectoryItems('assets/UI/PNG')) do
	if v:find('.png') then
		thumbs[#thumbs+1] = {love.graphics.newImage('assets/UI/PNG/'..v),love.graphics.newImage('assets/UI/PNG/'..v):getWidth() > love.graphics.getWidth()/5 +2 and
																			(love.graphics.getWidth()/5)/love.graphics.newImage('assets/UI/PNG/'..v):getWidth()
																		or love.graphics.newImage('assets/UI/PNG/'..v):getHeight() > love.graphics.getHeight()/8 +2 and
																			(love.graphics.getHeight()/8)/love.graphics.newImage('assets/UI/PNG/'..v):getHeight()
																		or 1} --calculated scaling factor
	end
end
(if you don't understand the scaling calculator then ignore it, just know that the return value is <= 1)
I then draw all the images to the screen with the calculated scale and task manager says that love is taking 42MB of RAM.

Then I test again using canvas:

Code: Select all

for i,v in ipairs(thumbs) do
	local canvas = love.graphics.newCanvas(v[1]:getWidth()*v[2], v[1]:getWidth()*v[2])
	love.graphics.setCanvas(canvas)
	love.graphics.setColor(255, 255, 255)
		love.graphics.draw(v[1], 0, 0, 0, v[2])
	love.graphics.setCanvas()
	thumbs[i][1] = canvas --replaces old big image with the new small canvas
end
And the memory lowers to 40MB, pretty cool huh ?
slime wrote:For even more RAM/VRAM usage optimization, you could convert the textures to DXT1 or DXT5 (depending on if they're fully opaque or not). DXT-compressed textures stay compressed in RAM and in VRAM, unlike regular image formats.
And how can I compress a PNG into DXT, are there any tools to do this ?

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

Posted: Wed Jul 16, 2014 9:59 pm
by slime
Ranguna259 wrote:And how can I compress a PNG into DXT, are there any tools to do this ?
Yep: viewtopic.php?f=4&t=77364&p=163754#p163754

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

Posted: Wed Jul 16, 2014 10:17 pm
by Ranguna259
Thank you, but dds can't handle power of two.. I'll just alpha the pixels untill it's good, I'll have a problem with this LOVE using (image:getWidth() and image:getHeight()), anyhow this is great for memory optimizations.

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

Posted: Wed Jul 16, 2014 10:26 pm
by slime
Ranguna259 wrote:Thank you, but dds can't handle power of two.. I'll just alpha the pixels untill it's good, I'll have a problem with this LOVE using (image:getWidth() and image:getHeight()), anyhow this is great for memory optimizations.
The DXT formats (in the dds container) handle non-power-of-two image dimensions fine - as long as the system has NPOT support (if love.graphics.isSupported("npot") is true.)

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

Posted: Wed Jul 16, 2014 11:23 pm
by Ranguna259
The problem is that the nvidia app for PS won't save images unless they are power-of-two, I'll just use gimp instead.

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

Posted: Thu Jul 17, 2014 7:38 am
by bartbes
Ranguna259 wrote:
bartbes wrote:Tables that contain no other tables.
Aren't flat tables, tables in strings
I'm fairly sure I wrote that part of the docs, so no. They are tables that contain no other tables.
Ranguna259 wrote:Oh I didn't detect his sarcasm
Probably because that wasn't sarcasm.

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

Posted: Thu Jul 17, 2014 12:56 pm
by Ranguna259
bartbes wrote: I'm fairly sure I wrote that part of the docs, so no. They are tables that contain no other tables.
Ah, thanks for the clarification :megagrin:
bartbes wrote: Probably because that wasn't sarcasm.
Wrong term, is there a term for "asking but actually saying" ?

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

Posted: Thu Jul 17, 2014 1:12 pm
by davisdude
Ranguna259 wrote:Wrong term, is there a term for "asking but actually saying" ?
Implying?

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

Posted: Thu Jul 17, 2014 1:14 pm
by bartbes
Ranguna259 wrote: Wrong term, is there a term for "asking but actually saying" ?
A rhetorical question, I suppose.

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

Posted: Thu Jul 17, 2014 1:26 pm
by Ranguna259
bartbes wrote: A rhetorical question, I suppose.
davisdude wrote: Implying?
Hmmm.. Despite the fact that they differ from each other, both are right.