Jump to content

Why is there no "setBool"(and others) function in the ShaderMaterial-class?


Dinkelborg
 Share

Recommended Posts

OpenGL ES declares the following types as valid within the GLSL language:

  • void
  • bool
  • int
  • float
  • vec2,vec3,vec4
  • bvec2,bvec3,bvec4
  • ivec2,ivec3,ivec4
  • mat2,mat3,mat4
  • sampler2D
  • samplerCube

why does the BABYLON.ShaderMaterial class only have set-functions for 

  • Texture
  • Float, Floats
  • Color3,Color4
  • Vector2,Vector3

and

  • Matrix

I need a boolean uniform in my shader, is there any way I can still set a value for it or could you please add the missing set-functions?

Link to comment
Share on other sites

Both the engine and the Effect class have setBool function, you could use them, no?

 

btw - Javascript has no "integer" class. only number. So everything is a float :-) I guess you could cast the float in your shader after setting it. But I am no shader expert, can't really say how well this will work.

Link to comment
Share on other sites

It's not like I cannot use a float, in fact I did just create a float and made its value 1.0 or 0.0 so that I can check in the shader for it, but that just isn't what floats are made for really... and I think a boolean is cheaper than a float, so if one day anyone wants to create a huge shader that needs - I don't know - 300 booleans it might make a difference if there is 300 float variables instead ...
 

I don't exactly understand how the engine's or effect-class' setBool function would help me set a boolean value in my shaderMaterial... ?



All I'm saying is, that GLSL knows more variable types as there are set-functions in the shaderMaterial-class, if the shaderMaterial class wants to make it easier for the user to set a value for a shader-uniform by automatically finding the uniform-index and handing the value to the shader, then it should do so for all available variable (or uniform) types. Otherwise there is a shortcut for like 5 variable types and if one wants to use one of the other 7 or so that don't have this shortcut, he has to go the long way anyways, so why even bother getting to know the shortcut?

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