pissang / claygl

A WebGL graphic library for building scalable Web3D applications
http://claygl.xyz/
BSD 2-Clause "Simplified" License
2.8k stars 302 forks source link

Update normal map with viewer.setMaterial doesn't work if the model doesn't have a normal map in the gltf file. #90

Open aseriousname opened 6 years ago

aseriousname commented 6 years ago

i was converting FBX with fbx2gltf.py and often it doesnt find the textures to put in the .gtlf file.

This isnt a problem for me as I plan to have the user selecting what textures they want to see on the model.

However using clay_viewer.js if the model doesn't have a normal-map in the gltf file when it is loaded you can never change the normal map with viewer.setMaterial. All the other textures (diffuse, emissive, MR etc) will change but normal will not be shown.

If i edit the .gltf and manually add any image as a normal map then when i call viewer.SetMaterial then can successfully change normal maps. So right now I just edit and add a tiny 32x32 png as a normal map then at runtime i can update the normal map to the one i want.

I guess this is because the feature of displaying the normal isn't implemented if it doesn't have a normal map when originally loaded??

Anyway my workaround isn't very complicated but I thought I would mention this as it was tripping me up for a while. Or maybe there's something else i need to call on the viewer to turn normal maps on after load?

aseriousname commented 6 years ago

I'm sorry i meant to put this in the clay-viewer Issues