gryff Posted August 23, 2016 Share Posted August 23, 2016 With a little encouragement from Wingy, I have set up a simple playground that allows me to append a very simple file from my Dropbox. Playground Everything looks fine - right? Well no! The image below is the same file dropped (from my local end of Dropbox) into the Sandbox and you see the sphere is red. The material code in the babylon file is : "materials":[{"name":"ball_plane.red","id":"ball_plane.red","ambient":[1,0,0],"diffuse":[0.8,0,0],"specular":[0.5,0.5,0.5],"emissive":[0,0,0],"specularPower":50,"alpha":1,"backFaceCulling":true,"checkReadyOnlyOnce":false,"maxSimultaneousLights":4}, {"name":"ball_plane.Material","id":"ball_plane.Material","ambient":[0.8,0.8,0.8],"diffuse":[0.8,0.8,0.8],"specular":[0,0,0],"emissive":[0,0,0],"specularPower":50,"alpha":1,"backFaceCulling":true,"checkReadyOnlyOnce":false,"maxSimultaneousLights":4}], You will notice the material named "ball_plane.red" has a diffuse value of [0.8,0,0]. The Playground prints out the diffuse value in the web console - Object { r: 1, g: 1, b: 1 } Any ideas about what I am doing wrong? cheers, gryff Edit : All the links to the PG I posted are now working properly since the update posted below by @Deltakosh - so the issue is resolved. Quote Link to comment Share on other sites More sharing options...
Nabroski Posted August 23, 2016 Share Posted August 23, 2016 I dont know what the bug fix for this will be, but i need currently no lights in my scene, this is awesome! http://www.babylonjs-playground.com/#2BDTWM#2http://www.babylonjs-playground.com/#2BDTWM#3 Best gryff and adam 2 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted August 23, 2016 Share Posted August 23, 2016 Hi guys. @Nabroski... you're a God of Observables, that's for sure. You have a history of Java programming, right? Tiz good. @gryff, I thought you were ONLY going to experiment with pan/LERP-to-target with a cam. (that's all I suggested)... and instead, you find a major bug in... well we can't tell where, yet. BJS - [07:40:04]: importScene of ball_plane.babylon from Blender version: 2.76 (sub 0), exporter version: 5.0.2 Lights: Name: Hemi, type: Hemispheric Materials: Name: ball_plane.red Name: ball_plane.Material TypeError: this._gl is null I just wrote that there to remind me of something. I made #4 and #5 in the PG series. #4 is a copy of Gryff's PG... that prints scene.materials to console. It sometimes shows 3 objects (fresh load), and sometimes 1. #5 is a copy of Nab's PG... that prints scene.materials to console. It does the same (fresh load = 3 mats, reload 1 mat). Perhaps scene.executeWhenReady is not waiting for... something. Over in the "tiled ground from hell" thread, @adam recently turned-on a "normals displayer", and I noticed that he waited about a half second, using a setTimeout... before he called the normals displayer. Well heck, I took a look at that and said... "Hey, why didn't he simply do a scene.executeWhenReady()?" So I tried to replace his setTimeout()... and my attempt failed. Oh no. The only real difference in Nab's scene and Gryff's scene... is the way the "ready?" is being checked. hmm. I thought scene EWR (executeWhenReady)... waited for everything to be ready.... material loads, material.isReady, wingnutsDog.isReady, dinner.isReady, ready.isReady, etc. But... I'm not very bright, so... ya know. Butt still (not a good place to brew moonshine)... I believe this is an issue with scene readiness... and specifically... EWR. (I'm quite the deducer, huh?) Not many people use the .append and callback-less system of loading... as Gryff did here. Nab's scene, at least sometimes, is showing scene.materials.length = 1, too. (#5) But his sphere is red. What the heck? And Nabs (Captain Observable) used scene.onReadyObservable.add(), and observables were added to BJS core... AFTER @JCPalmer taught us about SceneLoader.Append. hmm. So, EWR could have gone broken when observables were added. Just a loose theory. *shrug* I'll keep thinking, but that usually makes things worse. adam, Nabroski and gryff 3 Quote Link to comment Share on other sites More sharing options...
gryff Posted August 23, 2016 Author Share Posted August 23, 2016 1 hour ago, Wingnut said: I thought you were ONLY going to experiment @Wingnut : Well you let me loose Wingy - maybe I should not play with big boys toys And I was trying to be sophisticated using the SceneLoader.Append. I guess I should stick to the Sandbox You may notice the title of the thread is a bit of a parody of the title of a detective novel written 100 years ago. Are you playing Inspector Japp or Hercule Poirot? @Nabroski : TY for the interest Nabs - and the two PGs. Both give me something to think about and experiment with As you say Wingy there does seem to be a difference between Scene ORO and EWR. (gryff goes off to ponder the Mysterious Case of the arcRotate Camera) cheers, gryff Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted August 23, 2016 Share Posted August 23, 2016 No need to "go off", G-man. The issue is right here, right now, stuck on the backside of your monitor glass, lookin' right at ya. http://www.babylonjs-playground.com/#2BDTWM#6 I tried .importMesh... which doesn't use ewr or oro... no joy. Actually, oro/observables could be active on the backside of SceneLoader... I haven't checked. No matter, I suck at painting spheres red. gryff 1 Quote Link to comment Share on other sites More sharing options...
gryff Posted August 23, 2016 Author Share Posted August 23, 2016 @Wingnut : Well Wingy they say bad things happen in 3s. And I have 3 at the moment. Anyway, I went off - and think I've solved one of the others (by changing from BJS version 2.4 to 2.5 (preview version) The third thing will have to wait as I wanted to use the PG to demo the issue and I need colours - although I guess I can l investigate the @Nabroski approach using ORO cheers, gryff Didn't @adam : have a posted here - still have his PG open in a tab I think? Quote Link to comment Share on other sites More sharing options...
adam Posted August 23, 2016 Share Posted August 23, 2016 I didn't think it added much, but here is the PG if you want to mess with it. http://www.babylonjs-playground.com/#I2123 gryff 1 Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted August 23, 2016 Share Posted August 23, 2016 Sorry, really kind of swamped, but if you look at this, you will see the added line before the append: BABYLON.SceneLoader.loggingLevel = BABYLON.SceneLoader.DETAILED_LOGGING; Did not give you red, but may be useful for other problems. It does show red as a material: (debug mode does not enumerate materials) BJS - [16:38:30]: importScene of ball_plane.babylon from Blender version: 2.76 (sub 0), exporter version: 5.0.2 Lights: Name: Hemi, type: Hemispheric Materials: Name: ball_plane.red Name: ball_plane.Material Meshes: Name: Sphere, isInstance: NO, # of submeshes: 1, billboard mode: NONE, freeze wrld mat: NO, n vertices: 482, parent: NONE, flat shading: NO Name: Plane, isInstance: NO, # of submeshes: 1, billboard mode: NONE, freeze wrld mat: NO, n vertices: 4, parent: NONE, flat shading: NO Cameras: Name: Camera, type: UniversalCamera gryff and Wingnut 2 Quote Link to comment Share on other sites More sharing options...
gryff Posted August 24, 2016 Author Share Posted August 24, 2016 @adam : Thanks for reposting that playground - I learn better by looking at people's code and videos than I do at reading text on web pages. I always like reading your coding. @JCPalmer : Thanks for posting that little piece of code. I think I have seen it before somewhere - but had forgotten all about it. Very useful - have to remember to use it. Now an update from me. As @Nabroski : seemed to be having some success by over riding the scene ambientColor , I tried playing around with it but noticed that the colours seemed washed out. Here is a new example with a more complex scene - in terms of materials : 4 Shapes It is still using the scene.EWR but note the code I added at line 18 - a line I got from @Nabroski PG. Remove that line and we are back to all grey. And the image below is the same file in the Sandbox - much richer colours. The added line to the PG is over-riding the scene ambientColor that I export from Blender. - typically : "autoClear":true,"clearColor":[0.0509,0.0509,0.0509],"ambientColor":[0,0,0],"gravity":[0,-9.81,0], So I don't think it is a battle of ORO vs EWR. But I don't have any idea why the PG and the Sandbox are behaving so differently. Both are using, I assume, the same version of BJS - "Babylon.js engine (v2.5-alpha)". I started using that version today on my local server and have had no issues so far. So not BJS - but some code around the PG? cheers, gryff Quote Link to comment Share on other sites More sharing options...
Wingnut Posted August 24, 2016 Share Posted August 24, 2016 Hi Gryff. Just a quick note. If I were you, I would not set scene.ambientColor, nor any material.ambientColor/ambientTexture. These things are not part of your issue. That was Nabs getting his rocks-off with the "Hey, I need no lights" epiphany. (He can use emissiveColor/emissiveTexture on all mesh materials to accomplish the same thing). As best I can remember, ambience is added to diffuseColor... to get a final render color of mesh. Therefore it is a diffuseColor modifier and not a replacement for diffuseColor. That's why you are seeing "washout"... because the ambient colors are being added to your diffuse color... which is still gray in the PG scene, but not-gray in the sandbox. The washout colors is the ambient color... mixed with (added-to) gray. With me? So, if I were you, I would use no ambient colors at all, and stay steadfast on the "Why no diffuseColor in the playground?" -issue. That is "the big kahuna" problem, I suspect. Mind you, ambientColors/Textures are a lot of fun to play-with, and interesting, but it is currently derailing you from the primary problem, me thinks. *shrug* Quote Link to comment Share on other sites More sharing options...
Sebavan Posted August 24, 2016 Share Posted August 24, 2016 Hello, This is a nice bug you just found :-) Basically the serialization system in BJS is using a global list of serializable fields with their metadata like ambientColor could also be called ambient and so on to make the JSON file prettier. Unfortunately, diffuseColor exists in a few different types and in the standard material it is define like: @serializeAsColor3("diffuse") public diffuseColor = new Color3(1, 1, 1); But in the material library you can see the definition like: @serializeAsColor3() public diffuseColor = new Color3(1, 1, 1); So as the custom materials scripts are after the babylon.js they unfortunately cancel the standard material definition and prevent it to load the "diffuse" part of the material in the .babylon file. In the sandbox, there is no custom material scripts so the diffuseColor metadata are not overriden and it can load them. I am really busy currently due to relocation preparation but wil check if somebody around could help with a PR. in the mean time, ou can simply rename diffuse in diffuseColor in your babylon file: http://www.babylonjs-playground.com/#2BDTWM#9 CU, gryff and Wingnut 2 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted August 24, 2016 Share Posted August 24, 2016 Thanks for the info and troubleshooting, @Sebavan! Excellent! I was mistaken, before, when I said ORO was working. It is not. I didn't realize that the sphere.material.ambientColor was set to red. That is why... when Nab's turned on the scene.ambientColor .9 .9 .9 ... the sphere went red. So, I was wrong about ORO working correctly and EWR not working. They are both not working. http://www.babylonjs-playground.com/#2BDTWM#11 My apologies if that caused a goose chase for anyone. Quote Link to comment Share on other sites More sharing options...
gryff Posted August 24, 2016 Author Share Posted August 24, 2016 @Sebavan : No rush on it as far as I am concerned. We all have real lives to lead. But could you post on this thread when it gets fixed, please, please? cheers, gryff Quote Link to comment Share on other sites More sharing options...
Nabroski Posted August 24, 2016 Share Posted August 24, 2016 Quote Link to comment Share on other sites More sharing options...
Sebavan Posted August 24, 2016 Share Posted August 24, 2016 Hello, The pr has been merged in https://github.com/BabylonJS/Babylon.js/pull/1325 and is soon to be deploy on the PG. (DK will probably deploy during the weekend) I ll ping you once done. Wingnut and gryff 2 Quote Link to comment Share on other sites More sharing options...
gryff Posted August 25, 2016 Author Share Posted August 25, 2016 3 hours ago, Sebavan said: I ll ping you once done. @Sebavan : Thank you, sir. A gentleman and a scholar cheers, gryff Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted August 25, 2016 Share Posted August 25, 2016 Done! PG updated Sebavan and gryff 2 Quote Link to comment Share on other sites More sharing options...
gryff Posted August 25, 2016 Author Share Posted August 25, 2016 Well done @Sebavan and @Deltakosh : works like a charm now cheers, gryff GameMonetize 1 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.