Jump to content

CustomMaterial: updating custom uniforms, custom alpha and precision


zhutq
 Share

Recommended Posts

Hi,

I find CustomMaterial a very powerful way to write my own materials :) I have three questions reguarding it:

1. Is there a way to update custom uniform values after AddUniform?

2. I use Fragment_Custom_Alpha, and compute alpha according to some uniform values. Can I tell the material to enable alpha blending?

3. Can I specify "precision highp float;" for it? I notice that Fragment_Begin is defined after #include<__decl__defaultFragment> , so it's late for precision.

Thank you very much!

 

Link to comment
Share on other sites

hi @zhutq sorry i see it now  @Day72 thanks  too

answer 1 : yes you can update any uniform you most check the material.getEffect() after that be ready you can change it

like any shader material

material.getEffect()

https://www.babylonjs-playground.com/#3WN9C6#1

answer 2 : https://www.babylonjs-playground.com/#3WN9C6

you can make any custom alpha from this

sphere.material.Fragment_Custom_Alpha('result  = sin(vPositionW.x*20.01+vPositionW.z*20.01);');
 or sphere.material.Fragment_Custom_Alpha('alpha  = sin(vPositionW.x*20.01+vPositionW.z*20.01);');
 

answer 3 : it is  same as standard material but for now custommaterial can't   change that if you think that can be useful i can append that

 

documentation under progress ( committed under this week )

Link to comment
Share on other sites

Thank you!

So I need to set alpha < 1 to enable alpha blending. I compute final alpha according to alpha and another value, so I thought it's better to have an additional value to affect needAlphaBlending. But anyway I can indeed achieve what I want :)

I think setting precision will be useful :)

Link to comment
Share on other sites

It's nice to see other CustomMaterial users. This will help to find a possible bug. And with a bit of luck, this will correct the reflection / refraction problem

Have you planned a Nasimi documentation for CustomMaterial? I'm sure there would be more users.

 

Link to comment
Share on other sites

  • 2 months later...

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...