Jump to content

Playing with shader


Hartha
 Share

Recommended Posts

@Pryme8 and @Arte, Thank you guys very mush, very helpful answers, I have to update the amount "y", but it seems not to work when I put 

mat.Fragment_Custom_Diffuse('if( vPositionW.y  >'+ y +' ){ discard; }');

in registerBeforeRender, it just take the first call.
I will look to the implementation to find a solution.

Thank you very much again :).

Link to comment
Share on other sites

just build a custom shader from the default one so you keep all the rendering options, and add the new line of discard set to play off a uniform then just update your uniform on the before render function and you wont have to keep assigning the material.

Link to comment
Share on other sites

@Pryme8 in CustomMaterial class there is a function to add a uniform, but I don't find how to update it, and in the StanderdMaterial class I find how to add and update a uniform but I don't know where to add a discard condition -.-.

Sorry for this but can you provide sample as Arte side ?

Link to comment
Share on other sites

4 hours ago, Hartha said:

@Pryme8 in CustomMaterial class there is a function to add a uniform, but I don't find how to update it, and in the StanderdMaterial class I find how to add and update a uniform but I don't know where to add a discard condition -.-.

Sorry for this but can you provide sample as Arte side ?

hi

customMaterial and standardmaterial both can update uniform with this 

material.getEffect().setFloat() and others uniforms type

 @Hartha

Sample : https://playground.babylonjs.com/#AFRP1L#4

@Deltakosh 

Bug : https://playground.babylonjs.com/#AFRP1L#5

look line 48 ,49 50 

when a new mesh created or ( i think ) new standardMaterial created all set Effect function is freezed :( is this depend to StandardMaterial

** for check you can set any Uniform in standard material 

notice that custom material inherited from standard material

 

Link to comment
Share on other sites

Thanks @NasimiAsl for help, I guess it is not a bug, you can see the log :
babylonjs WebGL: INVALID_OPERATION: uniform1f: location not for current program

it is means that the active shader program  is not the program which obtained the uniform locations from, we need to do something like gl.useProgram or update the uniform when we sure that the current active program is for the material we need to update.

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