Search code examples
autodesk-forgeautodesk-viewer

Custom lighting environments and shaders in Forge Viewer


Some models, especially ones produced through photogrammetry, don't look that good with any of the lighting presets the viewer can offer. They're often quite dark and surfaces are "shiny". What options do I have in modifying the shading? I'd just like to have a uniformly lit model.

I know I can replace the shader material on the model fragments but then I will lose the model textures. As far as I know I can't combine shaders in three.js. Is there a way to introduce my own custom lighting environment?


Solution

  • Unfortunately there's no official way of customizing the environment: How to add custom environment map for background in autodesk forge?.

    I think you could hack your way out of this, though, for example, by switching to one of the "simpler" environment presets, and finding an angle where the photogrammetry output is lit reasonably well:

    viewer.impl.matman().setEnvRotation(angle);
    viewer.impl.renderer().setEnvRotation(angle);
    

    While doing that, you could also play with the exposure settings:

    viewer.impl.matman().setEnvExposure(exposure);
    viewer.impl.renderer().setEnvExposure(exposure);