MackeyK24 Posted March 1, 2017 Share Posted March 1, 2017 Hey @Deltakosh, @Sebavan or @RaananW can i pick you guys brains for a sec... I am trying to use the Simple Material with lighting support. But for some reason the 'BACK-SIDE' of the lighted surface is really black. This is the simple code i use to create a SimpleMaterial: var tester:BABYLON.AbstractMesh = this.scene.getMeshByName("Tester Cube 3"); var material:BABYLON.SimpleMaterial = new BABYLON.SimpleMaterial("simpleMaterial", this.scene); material.diffuseColor = BABYLON.Color3.White(); material.diffuseTexture = new BABYLON.Texture("/scenes/amiga.png", this.scene); tester.material = material; But take a look a t the Cube on the LEFT... That is using the BABYLON.SimpleMaterial and the Cube on the right with looks perfect is using a standard shader and material. Why is the back side too black when i thought SimpleMaterial supports the basic lighting workflow??? Note the Beautiful shadows ... One is BAKED using Lightmaps and the Other is realtime ... But the look beautiful Quote Link to comment Share on other sites More sharing options...
Sebavan Posted March 1, 2017 Share Posted March 1, 2017 Check the ambient value, this does not exist on a simple mat. I guess you might have some in the standard Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted March 1, 2017 Author Share Posted March 1, 2017 3 hours ago, Sebavan said: Check the ambient value, this does not exist on a simple mat. I guess you might have some in the standard No Ambient values in Simple Material... Should i COPY/IMPLEMENT Ambient from default shader... Do i need the the AmbientTexture or would a base ambient color do?? I tried something like this already, where i tried to use a white hard coded baseAmbientColor of white... I DONT multiply baseAmbientColor.rgb *= LEVEL cause LEVEL is always 1 on texture by default... i think... Anyways i tried to include a white baseAmbientColor in the final composition but looks like the picture above... Black on backside: void main(void) { #include<clipPlaneFragment> vec3 viewDirectionW = normalize(vEyePosition - vPositionW); // Base color vec4 baseColor = vec4(1., 1., 1., 1.); vec3 diffuseColor = _Color.rgb; // Alpha float alpha = _Color.a; #ifdef _MainTexDef baseColor = texture2D(_MainTex, _MainTexUV); #ifdef ALPHATEST if (baseColor.a < 0.4) discard; #endif baseColor.rgb *= _MainTexInfos.y; #endif #ifdef VERTEXCOLOR baseColor.rgb *= vColor.rgb; #endif // Ambient color vec3 baseAmbientColor = vec3(1., 1., 1.); // Normal #ifdef NORMAL vec3 normalW = normalize(vNormalW); #else vec3 normalW = vec3(1.0, 1.0, 1.0); #endif // Lighting vec3 diffuseBase = vec3(0., 0., 0.); lightingInfo info; float shadow = 1.; float glossiness = 0.; #include<lightFragment>[0..maxSimultaneousLights] #ifdef VERTEXALPHA alpha *= vColor.a; #endif // Final Composition vec3 finalDiffuse = clamp(diffuseBase * diffuseColor + vAmbientColor, 0.0, 1.0) * baseColor.rgb; vec4 color = vec4(finalDiffuse * baseAmbientColor, alpha); #include<fogFragment> gl_FragColor = color; } #endif //FRAGMENT-END Here is my who;e shader file with VERTEX and FRAGMENT sections: AmigaShader.shader Quote Link to comment Share on other sites More sharing options...
RaananW Posted March 1, 2017 Share Posted March 1, 2017 Might be a shadow issue as well? I assume the shadow generated is the left one. Can you try disabling the shadow and see what happens? Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted March 1, 2017 Author Share Posted March 1, 2017 42 minutes ago, RaananW said: Might be a shadow issue as well? I assume the shadow generated is the left one. Can you try disabling the shadow and see what happens? Without static or realtime shadow... I think @Sebavan is right about the ambient but I'm not too sure how to best include AMBIENT support in the simple shader... But here is shot with out ANY shadows: Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 1, 2017 Share Posted March 1, 2017 This is because the simplematerial is only about diffuse. It is not really intended to be used. It is here mostly for educational purposes. If you want you can as @Sebavan mentioned add code for ambient lightning Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted March 1, 2017 Author Share Posted March 1, 2017 1 hour ago, Deltakosh said: This is because the simplematerial is only about diffuse. It is not really intended to be used. It is here mostly for educational purposes. If you want you can as @Sebavan mentioned add code for ambient lightning Found and Fixed issue... First of all my Toolkit uses a new BABYLON.UniversalMateral for use as general purpose CYOS type deal... The UnivseralShader is basically a copy of Standard Material merged with the Custom property map features from the shader material with the component life cycle to control you shader from tiny little shader controller scripts (just like the mesh, light and camera scripts from toolkit)... I can now pickup the entire standard (default.fx) shader pipeline for all unity supported material property like _MainTex, _BumpMap etc... that map to the UniversalMaterial diffuse bump etc... PLUS all the custom property map features from the shader material.. so can easily add runtime properties using UniversalMaterial.setfloat setTexture etc... Now i am picking up everything from standard shader pipeline ... Also Unity was using a very dark Ambient Specular Color... Had to change because babylon we want color like white for HemisphericLight specular color... Fixed that too... Now is working great so far Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 1, 2017 Share Posted March 1, 2017 Did I mention documentation lately? Sebavan 1 Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted March 1, 2017 Author Share Posted March 1, 2017 7 hours ago, Deltakosh said: This is because the simplematerial is only about diffuse. It is not really intended to be used. It is here mostly for educational purposes. If you want you can as @Sebavan mentioned add code for ambient lightning hey @Deltakosh After fixing lighting issues and use Ambient Light (Hemispheric Light) diffuse color to white the lighting shows up on cubes but as a side affect since the ambient diffuse color is white the shadows LIGHTEN up quite a bit... If i go darker ambient diffuse color the shadows are richer nut dark on cubes... Should the Shadow color take into ambient diffuse since we have shadow generator to control the darkness of shadow... Should the shadow part AFTER the ambient part in the shader fragment section??? take a look at the very light shadows now with ambient diffuse color set to white: Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 2, 2017 Share Posted March 2, 2017 I would say that this is expected as the ambient is here to add light even when there is no light (So even in the shadow part). 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.