question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Import occlusion map

See original GitHub issue

@julienduroure I’m curious if you would be willing to modify the importer to preserve an occlusion map using an empty custom node. For example, when occlusion is combined with metal/rough, perhaps the importer could produce something similar to this:

image

I think I’ve worked out the code for creating and using a node group like this. This is what I have so far:

    # Put this definition somewhere common, it will likely change to "glTF Settings" or similar.
    gltf_node_group_name = 'glTF Metallic Roughness'

    # The following code runs per-material for materials with occlusion.

    # Check if the custom node group already exists
    if gltf_node_group_name in bpy.data.node_groups:
        gltf_node_group = bpy.data.node_groups[gltf_node_group_name]
    else:
        # Create a new node grouping
        gltf_node_group = bpy.data.node_groups.new(gltf_node_group_name, 'ShaderNodeTree')
        gltf_node_group.inputs.new("NodeSocketFloat", "Occlusion")
        gltf_node_group.nodes.new('NodeGroupOutput')
        gltf_group_input = gltf_node_group.nodes.new('NodeGroupInput')
        gltf_group_input.location = -200, 0

    # Place a new node grouping in the current material
    gltf_settings_node = bpy.data.materials[material_idx].node_tree.nodes.new('ShaderNodeGroup')

    # Set the newly placed node grouping to be the glTF grouping
    gltf_settings_node.node_tree = gltf_node_group
    gltf_settings_node.width = 220

From there you would connect the R channel of the occlusion image texture to the one socket on the new custom node.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
donmccurdycommented, Feb 23, 2019

+1 for renaming this node to glTF Settings or glTF Export.

1reaction
juliendurourecommented, Apr 1, 2019

@emackey @donmccurdy I made a first draft on branch import_ao_node

Read more comments on GitHub >

github_iconTop Results From Across the Web

Occlusion Map - Unity - Manual
An occlusion map is a greyscale image, with white indicating areas that should receive full indirect lighting, and black indicating no indirect lighting....
Read more >
Can't import occlusion map in Mixer 2021 - Quixel
Can't import occlusion map in Mixer 2021. Completed. Follow. Johan M. 2 years ago. The option used to be there but with the...
Read more >
unity - How to import a texture to be used as occlusion map?
I've been searching around in the manual and the web but still not sure if AO maps should be imported as Lightmaps. texture...
Read more >
How to import texture to be used as Occlusion map?
The same way normal maps need to be imported as "Normal map" in the import settings, how should I setup an Ambient Occlusion...
Read more >
Ambient Occlusion Painting | Substance 3D Painter
The result of this computation is stored in a bitmap named the "Ambient Occlusion" map. This map can be baked in the application...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found