Page 1 of 5

Scene texture maps resize policy

Posted: Tue May 11, 2021 7:57 am
by Dade
Introduction

I have introduced the concept of scene texture maps resize policy. It allow to resize all the texture maps (i.e. the images used in all texture image map nodes) of scene according some policy. The policy is defined by using few properties in the rendering configuration.

Policy: NONE

The "NONE" policy is the default and it doesn't resize the images at all. It is defined by:

Code: Select all

scene.images.resizepolicy.type = NONE
This is a test scene with "NONE" policy:

none.jpg

Texture image maps memory used:

Code: Select all

[LuxRays][0.524] [Device GeForce RTX 2070 SUPER CUDAIntersect] ImageMaps buffer size: 5376Kbytes
Se other policies for some comparison.


Policy: FIXED

The "FIXED" policy allow to apply a fixed scale to all image maps. For instance, to scale down all image maps by a 50%:

Code: Select all

scene.images.resizepolicy.type = FIXED
# The scale to apply to all image maps size
scene.images.resizepolicy.scale = 0.5
# The minimum size of an image map
scene.images.resizepolicy.minsize = 128
While quite drastic, this policy can be already useful to reduce the GPU memory usage in case you run out of space.

This is a test scene with "FIXED" policy and a scale of 0.5:

fixed.jpg

Texture image maps memory used:

Code: Select all

[LuxRays][0.737] [Device GeForce RTX 2070 SUPER CUDAIntersect] ImageMaps buffer size: 3648Kbytes
Se other policies for some comparison.

More to come

Indeed, this infrastructure was introduced to allow the support of some kind of optimized policy where the image maps are scaled down to the minimum size required by the scene. This will allow, for instance, to have a library of 4K texture maps and use them while it will be up to LuxCore to pick the minimum required resolution for your rendering.

Re: Scene texture maps resize policy

Posted: Tue May 11, 2021 10:19 am
by Sharlybg
Can't wait to test it.

Re: Scene texture maps resize policy

Posted: Wed May 12, 2021 1:43 pm
by Dade
Added some example and comparison between policies int he first post.

Re: Scene texture maps resize policy

Posted: Thu May 13, 2021 1:35 pm
by juangea
This is amazing :)

I’m eager to see other policies :)

Re: Scene texture maps resize policy

Posted: Thu May 13, 2021 1:41 pm
by TAO
Really nice feature, I cant wait to try it. that's amazing to be able to resize all textures with a factor at the sametime.

Re: Scene texture maps resize policy

Posted: Mon May 17, 2021 4:18 pm
by juangea
Other policies would be more amazing, like having the nearest textures at a biggest resolution and the furthes one at a lower one, also hidden textures at the minimum possible resolution for example.

This is all an invention in my mind, and maybe not all what Isaid it's possible, but for sure part of it will be possible, another intersting thing could be as follows:

Why would you want a 4K texture if you are going to render at 1920x1080 for example, it's impossible to see the difference between 4k and 2k in that case, the same goes for tiles textures, why could you need a 4k texture if your texture is tiled 20 times and the actual size in screen is 20 pixels, and we gan go on and on an imagine situations where different policies could be defined, what will be possible? I don't know, but whatever it is it will be awesome for sure :)

Re: Scene texture maps resize policy

Posted: Sun May 23, 2021 12:38 pm
by Harvester
This is very promising. Well done, Davide!

Re: Scene texture maps resize policy

Posted: Tue Jun 15, 2021 10:40 am
by B.Y.O.B.
I have implemented support for this in the Blender addon, but no matter which policy I choose, the memory usage is the same.
The log is also always the same, with messages like this:

Code: Select all

[SDL][216.750] Reading texture map: D:\Projects\LuxCore\LuxCoreTestScenes\scenes\HallBench\textures\Tiles13_col_2.jpg
[SDL][217.094] Mip map available: [4096x4096]
[SDL][217.094] Reading mip map level: 0
Could it be that I have to apply the policy settings somehow before building the scene, or so?
In BlendLuxCore, the luxcore_scene is built first, then the render config is created with renderconfig = pyluxcore.RenderConfig(config_props, luxcore_scene). In the logs it looks like all the image maps are already loaded before this step happens.

Re: Scene texture maps resize policy

Posted: Tue Jun 15, 2021 12:01 pm
by juangea
Regarding the location of the TX files you asked before (I think), IMHO they should be located in the same folder as the original texture, so for example if you have a texture in your protect with the tax files already generated they will be used or regenerated if they are outdated, but we could store the tax files within the library and copy them over for a new project, that will avoid the need of regenerating them.

I’m not sure if it makes sense.

However, when they are generated I think they should be located in the same folder as the texture itself :)

Re: Scene texture maps resize policy

Posted: Tue Jun 15, 2021 1:06 pm
by Dade
B.Y.O.B. wrote: Tue Jun 15, 2021 10:40 am Could it be that I have to apply the policy settings somehow before building the scene, or so?
In BlendLuxCore, the luxcore_scene is built first, then the render config is created with renderconfig = pyluxcore.RenderConfig(config_props, luxcore_scene). In the logs it looks like all the image maps are already loaded before this step happens.
It sounds like you are creating the Scene without a resize policy because the resize policy is (after) defined in the render config.

I think, in your case, you have to pass the Resize policy properties to the scene constructor: https://github.com/LuxCoreRender/LuxCor ... ore.h#L772

See the Scene constructor has now an additional optional argument for them.