aframevr / aframe

:a: Web framework for building virtual reality experiences.
https://aframe.io/
MIT License
16.69k stars 3.98k forks source link

Issue with lights in aframe from blender models #4432

Open Michael-Pascale opened 4 years ago

Michael-Pascale commented 4 years ago

I was making a model in blender for testing in aframe, using all default settings in blender. When I used it in aframe, I noticed that it did not appear to be using the light resources. I confirmed that all the normals were facing the right direction, and that no gltf export flags were different than what should be there (Not using unlit settings). In a separate occasion with a model from elsewhere (an obj file), I used blender to export into a glb and it used the light properly, but the original obj did not. (Not including those files, just mentioning). I am not sure if this is a bug or if I am doing something wrong, but all of the models view correctly in blender, paint3d and 3dviewer on windows 10.

error.zip

donmccurdy commented 4 years ago

Could you describe what you mean by "it did not appear to be using the light resources"? What do you expect to see, and what are you actually seeing? Do you mean for the file to contain a light itself (it doesn't currently), or do you have other lights in the A-Frame scene? Is the model entirely black, or just darker than you expect?

Michael-Pascale commented 4 years ago

image


This is with a default scene in a frame. The left is a simple obj file with an mtl. The right is that same file exported from blender as a glb. I no longer have the demo I had before, but when I made a glb within blender and loaded it into aframe, it looked like the one on the left. I did check the material settings to make sure they matched aframes specs, and the model in the picture is the only one that has successfully worked.

donmccurdy commented 4 years ago

The left is a simple obj file with an mtl.

when I made a glb within blender and loaded it into aframe, it looked like the one on the left.

It sounds like you're saying the OBJ and glTF look the same?

Sorry, I'm not sure what you're asking here. We need enough information to reproduce the problem, to help. Consider loading the model into a viewer like https://gltf-viewer.donmccurdy.com/ — if it looks like the Blender original there, but not in A-Frame, it's probably a matter of getting the lighting right in A-Frame. If it looks wrong there, too, it might be another issue.

Michael-Pascale commented 4 years ago

image

Above is as this particular model looks in blender. I made the model there.

image

Above is the exported glb in aframe. I made no changes to the default scene, which uses a directional light if I am not mistaken.

image This is what the model looks like in your model viewer.

image

This is the validation report that your viewer sent me.

image

I turned the environment lighitng off, and the result looks like this, which is the same as what the default scene in aframe shows.

image

Lastly, the view from the bottom of the model in your viewer. If you need anything else, let me know and I will provide it. I am not sure why it is acting like this. If your environment light is the same as an ambient light value, then the results are that it looks incorrect in both your viewer and aframe.

donmccurdy commented 4 years ago

Thanks, that's helpful. Enabling renderer.colorManagement might be the place to start: see https://aframe.io/docs/1.0.0/components/renderer.html.

donmccurdy commented 4 years ago

If your environment light is the same as an ambient light value

These are quite different – ambient lights won't affect metallic materials. Since the model doesn't appear metallic, you might want to make sure you've set metalness to near 0 in Blender to avoid any weird side effects. Anything metallic requires an environment map, and it takes a bit of work to add those in A-Frame.

Michael-Pascale commented 4 years ago

I turned down all of those settings in blender and did another export. I also changed the settings to match those in the link you sent. Below is what the results were:

image

After messing with some settings, turning off physicallycorrectlights yields:

image


This is closer to what I was expecting the object to look like. It looks like if I use these settings I can get the objects to be lit up, albeit they wont get to use any pbr if I understand this. What could this mean?

donmccurdy commented 4 years ago

It looks like if I use these settings I can get the objects to be lit up, albeit they wont get to use any pbr if I understand this...

I don't know exactly what settings you changed, but disabling physicallyCorrectLights is not equivalent to disabling PBR. physicallyCorrectLights=true simply means that for lights with a distance property (point, spot) the distance attenuation follows inverse square law (i.e. physically-based falloff). Practically, this usually makes things a little darker for the same light intensity value.

PBR refers to much more than just how far the lights shine.

netgfx commented 4 years ago

I think I have the same or similar issue, I'm loading this glb file https://cdn.glitch.com/9565c650-fdb4-4b2f-a1fc-f2e8506c0092%2Fkey.glb?v=1586977089656 However it looks like this (versus the google model viewer) image (6) The "orange" one is from A-Frame.

Code is like this:


<a-scene device-orientation-permission-ui="enabled: false" background="transparent: true"
            cursor="rayOrigin:mouse" >
<a-asset-item id="object" src="./assets/treasure/key.glb"></a-asset-item>

<a-entity gltf-model="#object" position="0 1 -4" scale="1 1 1" rotation="0 0 0" animation="property: rotation; to: 0 360 0; from:0 0 0; easing:linear; loop: true; dur: 10000"  renderer="antialias: true;
                   colorManagement: true;
                   physicallyCorrectLights: true;"></a-entity>

    <a-camera mouse-cursor>
            <a-cursor fuse="true" color="yellow"></a-cursor>
     </a-camera>
</a-scene>
donmccurdy commented 4 years ago

The renderer="colorManagement: true" property would need to be on the scene, it is a scene-wide setting. Same for physicallyCorrectLights and antialiasing.

netgfx commented 4 years ago

Yes it did improve a lot, however still not close to the model-viewer, I wonder what settings does the model-viewer use to show that true golden color, maybe something to do with light? I'm using: <a-entity light="type: ambient; color: #fff"></a-entity> image (7)

donmccurdy commented 4 years ago

Visible color would depend on lighting – grabbing the texture from Blender (below) I don't think A-Frame is wrong. But I'm not sure what model-viewer is doing differently here, it may be the choice of a particular environment map for lighting.

key texture golden yellow
netgfx commented 4 years ago

I see, thanks for the information! I'll try some different settings. I also see (on a different model) that on the model-viewer the object is reflecting more so maybe they are not using an ambient light, or maybe some different more glossy material?

donmccurdy commented 4 years ago

They definitely use IBL (image-based lighting or environment maps), and might also use some ambient or other lights on top of that. But there are multiple ways to do IBL, and a lot depends on the texture itself, so I'm not sure how to reproduce that without inspecting their code.

olivierFalloff commented 3 years ago

Hello I have been using a-frame since 2018 to show my scenographies to the directors I work for (thank you for your fantastic work). Since aframe-v1.1.0.min I have been forced to use the GLTF format but I'm not happy with the lights. Objects seem to emit light like emit. The Gltf format is less beautiful in equivalent light than the collada format. The GLTF format shines, it is heavier and it there is too much aliaising. I cannot find the lighting I had with the collada format. Please give me a way to find my lights with the collada format ...I tried: "collada-model-legacy.js" with "ColladaLoader.js" in another folder but it doesn't work. Do you have a solution?

donmccurdy commented 3 years ago

See https://github.com/aframevr/aframe/issues/3793#issuecomment-779480924.

olivierFalloff commented 3 years ago

Thanks for your reply, I took your advice and found the answer (see the link below). This will allow me to smoothly transition to the promising GLTF format. Thank yoyi again for your VR work. It is a real tool for scenographers and architects ...

https://stackoverflow.com/questions/66196396/how-to-use-a-collada-model-with-aframe-v1-1-0-min