katana opscript – Override albedo colors with gray

Its usually handy to have an interactive filter that does a middle gray default material. But sometimes you want to see the materials in gray, while keeping all the other features as spec, roughness, metalness, etc.

Here are 2 opscripts to do so: The first one takes care of networked materials as in materialPath.material.nodes

The second one takes care of simple materials like materialPath.material.prmanBxdfParam

camera_03_night_v003.jpg
local material = Interface.GetAttr('material.nodes')
if (material ~= nil) then
    local len_of_children = material:getNumberOfChildren()
    if (len_of_children > 0) then
        for i=0, len_of_children do
            local shading_node = material:getChildByIndex(i)
            if (shading_node ~= nil) then
                local type = shading_node:getChildByName('type'):getValue()
                if (type == 'PxrSurface') then
                    local image_node_attr = 'material.nodes.' .. shading_node:getChildByName('name'):getValue()
                    Interface.SetAttr(image_node_attr .. '.parameters.diffuseColor.i0', FloatAttribute(.18))
                    Interface.SetAttr(image_node_attr .. '.parameters.diffuseColor.i1', FloatAttribute(.18))
                    Interface.SetAttr(image_node_attr .. '.parameters.diffuseColor.i2', FloatAttribute(.18))
                    Interface.SetAttr(image_node_attr .. '.connections.diffuseColor', StringAttribute(""))
                end
                if (type == 'PxrMarschnerHair') then
                    local image_node_attr = 'material.nodes.' .. shading_node:getChildByName('name'):getValue()
                    Interface.SetAttr(image_node_attr .. '.parameters.diffuseColor.i0', FloatAttribute(.18))
                    Interface.SetAttr(image_node_attr .. '.parameters.diffuseColor.i1', FloatAttribute(.18))
                    Interface.SetAttr(image_node_attr .. '.parameters.diffuseColor.i2', FloatAttribute(.18))
                    Interface.SetAttr(image_node_attr .. '.connections.diffuseColor', StringAttribute(""))
                end
            end
        end
    end
end

local material = Interface.GetAttr('material.prmanBxdfParams')
if (material ~= nil) then
    Interface.SetAttr("material.prmanBxdfParams.diffuseColor.i0", FloatAttribute(.18))
    Interface.SetAttr("material.prmanBxdfParams.diffuseColor.i1", FloatAttribute(.18))
    Interface.SetAttr("material.prmanBxdfParams.diffuseColor.i2", FloatAttribute(.18))
end
Previous
Previous

RHEL and CentOS 8 nvidia-prime setup

Next
Next

Substance high dpi and UI size issue – scale factor