Rajkumar Posted April 15, 2016 Share Posted April 15, 2016 Hi, I would like to setup so that light falls on the mesh, even when mesh is rotated. http://www.babylonjs-playground.com/#1HCFXA#0 Currently, if I rotate the mesh and look at the bottom surface, it is rendered as black, which means there is no light that hits this surface. I think this means light moves along with the camera. is this correct? However, when scene is rotated and a different surface is placed on top, I see a shine. Why is this ? I think I am missing something very basic here. All I want is use a single source of light and illuminate the mesh, no matter how it is rotated. Is this possible ? Regards Rajkumar Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted April 15, 2016 Share Posted April 15, 2016 Hey! something like this: http://www.babylonjs-playground.com/#1HCFXA#2 Rajkumar 1 Quote Link to comment Share on other sites More sharing options...
jerome Posted April 15, 2016 Share Posted April 15, 2016 why do you need to clone the camera position ? naive question, I know, but I'm wondering why ... Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted April 15, 2016 Share Posted April 15, 2016 No need for clone, this is a stupid habit of mine Quote Link to comment Share on other sites More sharing options...
Wingnut Posted April 15, 2016 Share Posted April 15, 2016 Hi rajkumar and others. If I may... http://www.babylonjs-playground.com/#1HCFXA#4 Raj... notice I turned off the light completely, and I am using box.material.emissiveColor (in line 27) so the box material will self-illuminate. This is the perfect way to "illuminate-color" all sides of a box, but notice that it is difficult to see the face edges. We can fix that in a moment. Understand that this is self-illumination, and no shadows can be cast from self-illumination. Shadows need lights to function properly. (I bet you knew that already) If you activate lines 30-33, it activates the edges renderer, which can be used to add lines to the edges. It is a strange way to do that, but it works great. If you turn OFF edges renderer, turn OFF material.emissive color, re-activate the good light choice of the hemisphericLight, and re-activate material.diffuseColor (like this demo), you get nice even lighting. Take notice of line 17. Setting a hemisphericLight.groundColor is the way to distribute more under-the-mesh light, so the mesh bottom is lit, and the sides get brighter. Lastly, notice the two lines in the animate() function (lines 48 and 49). One line rotates the mesh without orbiting the camera. The other line orbits the camera around the mesh without rotating the mesh. I hope some of this helps. Have more questions? Feel free to ask. Party on! Rajkumar 1 Quote Link to comment Share on other sites More sharing options...
Rajkumar Posted April 15, 2016 Author Share Posted April 15, 2016 Thank you very much, The suggestions were very helpful. Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted April 15, 2016 Share Posted April 15, 2016 Good. I forgot to tell you about mesh.showBoundingBox = true/false; http://www.babylonjs-playground.com/#1HCFXA#6 (line 29) That is another way to see face edges (without using the edgesRenderer). There is also material.wireframe = true/false; http://www.babylonjs-playground.com/#1HCFXA#7 Sometimes our friends want "half-wireframe"... and I think the "approved method" is to use TWO boxes atop one another. One box is wireframe, the other is solid: http://www.babylonjs-playground.com/#1HCFXA#8 I wanted to be "thorough". Sometimes people want diagonal lines on their boxes (wireframe) and sometimes they don't want them (edgesRenderer or showBoundingBox). Ok, bye again. Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted April 15, 2016 Share Posted April 15, 2016 I was doing the same thing with scene.beforeCameraRender(), new for 2.3. Is scene.onBeforeRenderObservable new for 2.4? Will beforeCameraRender be appreciated? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted April 16, 2016 Share Posted April 16, 2016 Observable are new for 2.4. you can just use scene.onBeforeRenderObservable.add(callback); But I won't deprecate any older callback properties. Under the hood everything is now an observable but for simplicity sake you can still use the old callbacks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.