Needle Needle Engine Lightmap add-on - how to lightbake with diffuse colour

Hi, I’ve been trying to lightbake this sample to try out the lightmap needle engine add on in Blender. It works really well, however, I could not manage how to make it light bake with diffuse colours. At the moment it comes out Black and white only.
Any idea how to lightbake with colour with the Lightmapping add on in Blender?

Hi Anna Tomatzidou,

To bake lightmaps with diffuse colors in the Needle Engine, you need to ensure that your materials are set up to handle diffuse color during the baking process. From the provided code excerpts, it looks like you might be missing the integration of the diffuse color in your lightmap baking settings.

To enable color baking, check the following steps:

  1. Material Setup: Ensure your materials have a diffuse texture assigned. The assignLightmapTexture method appears to check the material type and only apply the lightmap if the material is not for transmission (translucent materials).

  2. Shader Configuration: If using custom shaders, ensure their shaders properly handle lightmaps. The lightmap and diffuse color should be multiplied correctly in the fragment shader.

  3. Update the Baking Pass: In your lightmap bake settings, the pass filter should include "DIFFUSE" as part of the pass types to ensure that colors are also baked along with lighting data. You can adjust the pass_filter argument in the bpy.ops.object.bake call to include the diffuse.

Here’s an example update for your existing bake call:

bpy.ops.object.bake(type='COMBINED', 
                    uv_layer="NEEDLE_LightmapUV", 
                    margin_type="EXTEND", 
                    pass_filter={("EMIT"), ("DIRECT"), ("INDIRECT"), ("COLOR"), ("GLOSSY"), ("TRANSMISSION"), ("DIFFUSE")},
                    margin=8, 
                    use_clear=True)

This should include the diffuse color in your lightmap bake, allowing the final output to reflect the colors instead of being grayscale.

You may refer to the details in the lightmap handling section of the code to ensure you’re capturing the full scope of the lighting and material properties (see the documentation).

If you’re still facing issues, please provide more details about your setup or any error messages you encounter.

3 replies left
thread_c3ItbQnFzLLmduTNL01pKVB9
Reply to this message to continue the conversation

How to bake lightmap with diffuse colour using the Lightmapping add on in Blender

Hi Anna Tomatzidou,

To bake lightmaps with diffuse colors using the Needle Engine Lightmapping add-on in Blender, follow these steps:

  1. Enable Lightmapping: In the Needle Object panel, ensure that you have “Lightmapped” turned on for the mesh objects you want to light bake. Also, ensure you have at least one light source in the scene.

  2. Material Setup: Ensure that the materials assigned to your objects have a diffuse color or texture that you want to bake. The lightmap must be set up to blend with the material’s diffuse component.

  3. Bake Settings: In the Lightmapping panel in the Render Properties tab, configure your baking settings.

  4. Baking the Lightmap:

    • Use the Bake option in the Needle Lightmapping panel. Make sure the right passes are included, particularly:
      pass_filter={("EMIT"), ("DIRECT"), ("INDIRECT"), ("COLOR"), /* Add other necessary passes as needed */ }
      
    • To specifically include the diffuse colors, you may need to ensure the baking pass includes ("COLOR").
  5. Execute Bake: After setting the parameters, execute the bake operation. Check the logs for any errors if it doesn’t complete successfully.

  6. UV Setup: Ensure that your second UV channel is set up correctly for lightmaps. If not, you may need to create it before baking.

  7. Check Results: After baking, check your lightmap texture to verify that the diffuse colors have been included correctly.

If you are still facing issues with colors coming out as black and white, ensure that your material node setup in Blender reflects the lightmap and diffuse color integration properly (see the documentation) (see index).

If you need further clarification or run into specific issues during the bake, feel free to ask!

2 replies left
thread_c3ItbQnFzLLmduTNL01pKVB9
Reply to this message to continue the conversation

Hi Anna,

diffuse baking is currently disabled because it will result in wrong colors at runtime/in the web. We have this on our roadmap and improve lightmap baking but I don’t have a concrete ETA for you at the moment I’m afraid