Jump to content

Shadows, Lights and Shaders


MarianG
 Share

Recommended Posts

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!

Link to comment
Share on other sites

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#3

If yes, please show me tutorial, or something. Thank again.

 

I really don't like shaders:)

 

.....

And another thing. Can I use multiple lights?

Link to comment
Share on other sites

  • 2 years later...

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...