Page 1 of 1

Change import settings for textures from script

Posted: Thu Jun 15, 2023 7:49 am
by jalley
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?

Re: Change import settings for textures from script

Posted: Thu Jun 15, 2023 8:16 am
by jobigoud
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".

Re: Change import settings for textures from script

Posted: Thu Jun 15, 2023 8:32 am
by jalley
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

Re: Change import settings for textures from script

Posted: Thu Jun 15, 2023 10:23 am
by jobigoud
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)

Re: Change import settings for textures from script

Posted: Thu Jun 15, 2023 1:48 pm
by jalley
It worked! Thank you!