Scene texture maps resize policy

Discussion related to the LuxCore functionality, implementations and API.
User avatar
Dade
Developer
Posts: 5324
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Scene texture maps resize policy

Post by Dade » Tue May 11, 2021 7:57 am

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.
Support LuxCoreRender project with salts and bounties

User avatar
Sharlybg
Donor
Posts: 2779
Joined: Mon Dec 04, 2017 10:11 pm
Location: Ivory Coast

Re: Scene texture maps resize policy

Post by Sharlybg » Tue May 11, 2021 10:19 am

Can't wait to test it.
Support LuxCoreRender project with salts and bounties

Portfolio : https://www.behance.net/DRAVIA

User avatar
Dade
Developer
Posts: 5324
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: Scene texture maps resize policy

Post by Dade » Wed May 12, 2021 1:43 pm

Added some example and comparison between policies int he first post.
Support LuxCoreRender project with salts and bounties

juangea
Donor
Posts: 297
Joined: Thu Jan 02, 2020 6:23 pm

Re: Scene texture maps resize policy

Post by juangea » Thu May 13, 2021 1:35 pm

This is amazing :)

I’m eager to see other policies :)

User avatar
TAO
Developer
Posts: 661
Joined: Sun Mar 24, 2019 4:49 pm
Location: France
Contact:

Re: Scene texture maps resize policy

Post by TAO » Thu May 13, 2021 1:41 pm

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.
Omid Ghotbi (TAO)
Latest build Download link👇👇
https://github.com/LuxCoreRender/MaxToLux/releases
Last update information
https://forums.luxcorerender.org/viewto ... 590#p30154

juangea
Donor
Posts: 297
Joined: Thu Jan 02, 2020 6:23 pm

Re: Scene texture maps resize policy

Post by juangea » Mon May 17, 2021 4:18 pm

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 :)

Harvester
Donor
Posts: 41
Joined: Thu Jan 25, 2018 8:06 pm

Re: Scene texture maps resize policy

Post by Harvester » Sun May 23, 2021 12:38 pm

This is very promising. Well done, Davide!

User avatar
B.Y.O.B.
Developer
Posts: 4077
Joined: Mon Dec 04, 2017 10:08 pm
Location: Germany
Contact:

Re: Scene texture maps resize policy

Post by B.Y.O.B. » Tue Jun 15, 2021 10:40 am

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.

juangea
Donor
Posts: 297
Joined: Thu Jan 02, 2020 6:23 pm

Re: Scene texture maps resize policy

Post by juangea » Tue Jun 15, 2021 12:01 pm

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 :)

User avatar
Dade
Developer
Posts: 5324
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: Scene texture maps resize policy

Post by Dade » Tue Jun 15, 2021 1:06 pm

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.
Support LuxCoreRender project with salts and bounties

Post Reply