Change import settings for textures from script

Forums: Change import settings for textures from script
Generic forum to discuss Octane Render, post ideas and suggest improvements.
Forum rules
Please add your OS and Hardware Configuration in your signature, it makes it easier for us to help you analyze problems. Example: Win 7 64 | Geforce GTX680 | i7 3770 | 16GB

Change import settings for textures from script

Postby jalley » Thu Jun 15, 2023 7:49 am

jalley Thu Jun 15, 2023 7:49 am
Hi, I'm trying to change the import settings of every texture in my Orbx scenes to optimize my rendering through Lua coding. The problem is that when I try to access the attribute A_TYPE, which is the attribute that stores that information according to the documentation, nothing happens. I can read the value inside that attribute, but I cannot set it. Is there a way to achieve this through code?
jalley
Licensed Customer
Licensed Customer
 
Posts: 28
Joined: Thu Aug 31, 2017 6:00 pm

Re: Change import settings for textures from script

Postby jobigoud » Thu Jun 15, 2023 8:16 am

jobigoud Thu Jun 15, 2023 8:16 am
The type is used to interpret the data in the buffer so I don't think you can change this arbitrarily, it needs to be compatible with what's already in the buffer, unless you are also changing the buffer.
There is also a A_RELOAD attribute that you may need to use to trigger reloading the texture. (set it to TRUE once and it will auto-reset to false after evaluation).
PS: there is a forum dedicated to Lua scripting under "Resources and Sharing".
User avatar
jobigoud
OctaneRender Team
OctaneRender Team
 
Posts: 230
Joined: Sat Aug 15, 2015 1:28 pm

Re: Change import settings for textures from script

Postby jalley » Thu Jun 15, 2023 8:32 am

jalley Thu Jun 15, 2023 8:32 am
I want to change the import setting because by default every texture is loaded as 32-bit RGBA, and that looks like a waste of resources. I want to change all my textures to an 8-bit RGBA BC7 format. Maybe not all my textures are compatible with this format, but it is enough for me if the ones that could be converted are actually converted because they are the vast majority. I already tried the reload and evaluate but still nothing happens.

Code: Select all
textures = rootGraph:findNodes(octane.NT_TEX_IMAGE, true)
texture = textures[1]
if(texture ~= nil) then
    print("Found")
    texture:setAttribute(octane.A_TYPE,10)
    texture:setAttribute(octane.A_RELOAD,true)
    texture:evaluate()
    print(texture:getAttribute(octane.A_TYPE))
end
jalley
Licensed Customer
Licensed Customer
 
Posts: 28
Joined: Thu Aug 31, 2017 6:00 pm

Re: Change import settings for textures from script

Postby jobigoud » Thu Jun 15, 2023 10:23 am

jobigoud Thu Jun 15, 2023 10:23 am
Try changing the A_CHANNEL_FORMAT attribute instead. That's what corresponds to the "Import type" combo box in the import settings dialog.

i.e: texture:setAttribute(octane.A_CHANNEL_FORMAT, octane.imageChannelType.BC7_UNORM)
User avatar
jobigoud
OctaneRender Team
OctaneRender Team
 
Posts: 230
Joined: Sat Aug 15, 2015 1:28 pm

Re: Change import settings for textures from script

Postby jalley » Thu Jun 15, 2023 1:48 pm

jalley Thu Jun 15, 2023 1:48 pm
It worked! Thank you!
jalley
Licensed Customer
Licensed Customer
 
Posts: 28
Joined: Thu Aug 31, 2017 6:00 pm

Return to General Discussion


Who is online

Users browsing this forum: No registered users and 13 guests

Sun May 12, 2024 6:49 pm [ UTC ]