MarianG Posted September 2, 2015 Share Posted September 2, 2015 Hi guys. I have a little problem, and I'm confused )Let me explain what I have to do, and what I did, and please tell me where I wrong. I did a ground with multiple textures, for this, I used a shader. All clear. Now I have to add shadows, but first I tryed to understand how it works lights in shader, and this is almost clear . Here you have a wonderfull playground, where I try to show you what happened to me. The light is draggable. http://www.babylonjs-playground.com/#1TWMLX So I have a light which rays shines the ground, but I want that the darkness of light to be more black.The second problem. The light is on left of the box, but the box is black on left side, and white in the right side. It looks like I have another light in the right of ground.And the water is shines from this light, not from my light.(for this I think I have to add a shader to the water material I think) And the last. For box shadow to be displayed on the ground I read that I need a modelMatrix to sent to shader, a dephtexture, and so on. I make a depthtexture using a rendererTargetTexture, And I put the box in renderingList, but how to sent modelMatrix to that shader? Thank you guys. I wish you a wonderful day! MarianG 1 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 2, 2015 Share Posted September 2, 2015 Hey:) So I fixed your code:http://www.babylonjs-playground.com/#1TWMLX#2 Mainly:- You defined a directional light but your shader assumed it was a point light- glFragColor.alpha has to be 1 here Quote Link to comment Share on other sites More sharing options...
MarianG Posted September 2, 2015 Author Share Posted September 2, 2015 Hi. Thank a lot Deltakosh It was so simple, but... I followed a tutorial, and I was sure that I missed something ) Quote Link to comment Share on other sites More sharing options...
MarianG Posted September 2, 2015 Author Share Posted September 2, 2015 One more little problem. The box shadow is not displayed on the ground. For this I added a shadowGenerator from babylonjs, and it didn't work.So to display the box shadow on the ground, I have to modify the shader again?http://www.babylonjs-playground.com/#1TWMLX#3If yes, please show me tutorial, or something. Thank again. I really don't like shaders:) .....And another thing. Can I use multiple lights? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 2, 2015 Share Posted September 2, 2015 Displaying shadows is hard, let's be honest Here is the part in the "official" shaders that uses the shadows maps: https://github.com/BabylonJS/Babylon.js/blob/master/src/Shaders/default.fragment.fx#L226 And in your case you also need to get the shadow maps from a shadow renderer Quote Link to comment Share on other sites More sharing options...
MarianG Posted September 3, 2015 Author Share Posted September 3, 2015 Hmmmm. I will try anyway to add shadows to the shader, and I'll share the result with you. Thanks. Quote Link to comment Share on other sites More sharing options...
Arte Posted November 22, 2017 Share Posted November 22, 2017 @bulisor Did you manage display shadows on the ground? Quote Link to comment Share on other sites More sharing options...
MarianG Posted November 22, 2017 Author Share Posted November 22, 2017 Hello Arte, .. huh, what old topic . I don't remember exactly. Let me make some search, if I'll not found, we'll make this playground to work, now it seems to be broken. I'll be back Arte 1 Quote Link to comment Share on other sites More sharing options...
MarianG Posted November 23, 2017 Author Share Posted November 23, 2017 I found it. Unfortunately, it's an abandoned project, I can not remember why, but when I tried that, BabylonJS was in the beginning, and there were not so many options. The only reason I started this shader is because I wanted to have more than one texture on the field and I read somewhere how you can play with the rbg channels of a texture. Now you have terrainMaterial that does exactly the same thing I tried before this material exists, so my recommendation is to use this material if you need it instead of trying to make your own shader . If you open a threat and expose your problem, and where do you wanted to use this shader, maybe I can help you more. Arte 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.