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
Post Reply
jalley
Licensed Customer
Posts: 28
Joined: Thu Aug 31, 2017 6:00 pm
Contact:

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?
User avatar
jobigoud
OctaneRender Team
Posts: 250
Joined: Sat Aug 15, 2015 1:28 pm

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".
jalley
Licensed Customer
Posts: 28
Joined: Thu Aug 31, 2017 6:00 pm
Contact:

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
User avatar
jobigoud
OctaneRender Team
Posts: 250
Joined: Sat Aug 15, 2015 1:28 pm

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)
jalley
Licensed Customer
Posts: 28
Joined: Thu Aug 31, 2017 6:00 pm
Contact:

It worked! Thank you!
Post Reply

Return to “General Discussion”