Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


AlexB last won the day on August 16 2014

AlexB had the most liked content!

About AlexB

  • Rank
    Advanced Member

Recent Profile Visitors

1074 profile views
  1. This seems to be working, but only intermittently. Sometimes I will see my texture, but then I change some arbitrary code someone else and it'll stop working. It seems as though there is a race condition somewhere. When I inspect the scene using Spector, I don't always see the uniforms. I know for a fact that the material creator method is happening before the uniform setting method. I can also re-trigger the setter function so I don't think it's a race condition in my code.
  2. I'm having a really hard time figuring this out. I'm creating this material. this.material = new BABYLON.ShaderMaterial( part.url, this.viewService.scene, { vertex: '/shaders/v', fragment: '/shaders/f', }, { needAlphaBlending: true, needAlphaTesting: true, defines: [ '#extension GL_OES_standard_derivatives : enable', '#define IS_CLOWN_PASS 0', '#define IS_TRANSLUCENT false', '#define IS_METAL false', ], attributes: ['position',
  3. Can you give an example of how to use a uniform buffer object with Babylon? Our user base will all be on WebGL2 browsers.
  4. I notice that there's a setTextureArray method, but I don't see any corresponding methods for vec2s, vec3s, etc. As an example, if I want something like: (Typescript) const offsets: Vector2[] = [ new Vector2(1, 1), new Vector2(2, 1), new Vector2(3, 1), new Vector2(4, 1), ] And I want to be able to use this in my shader, like this: (GLSL) uniform offsets vec2[4]; for (int i = 0; i < 4; i++) { vec3 tex = texture2D(sampler, uv * offsets[i]); // do something awesome here } I don't see any easy way to do it. Any clues?
  5. https://github.com/BabylonJS/Babylon.js/issues/4520
  6. I was hoping that adding support for structures would be faster than re-wiring my shader, but I think it'll be faster to just use arrays. But I'd still love to have support for structs at some point. They make the shaders way more readable, IMO. Thanks for your help!
  7. It turns out this is a harder problem than I thought. There is no low level method on the GL object to set structures, so what the ThreeJS implementation is doing is looping through a structure and discovering each type in a recursive loop. Then it applies each struct property one by one. I'm not sure I have time to figure it out. I got a good start on it if anyone wants to give it a try. I can push up a branch.
  8. Gotcha. I'll look into adding support for that. Would it just affect ShaderMaterial and the _checkUniform method? I don't quite understand all your code yet. It's changed a lot since I last used it 🙂
  9. I was referring to this bit of code in ShaderMaterial where it lists all the uniform types: private _textureArrays: { [name: string]: Texture[] } = {}; private _floats: { [name: string]: number } = {}; private _ints: { [name: string]: number } = {}; private _floatsArrays: { [name: string]: number[] } = {}; private _colors3: { [name: string]: Color3 } = {}; private _colors3Arrays: { [name: string]: number[] } = {}; private _colors4: { [name: string]: Color4 } = {}; private _vectors2: { [name: string]: Vector2 } = {}; private _vectors3: { [name: string]: Vector3 } = {}; priva
  10. @Deltakosh am I right that Babylon does not support GLSL struct objects?
  11. So by defines, you mean having conditional code in the same shader, but omitting one by setting a flag? #ifdef HAS_METALROUGHNESSMAP uniform sampler2D u_MetallicRoughnessSampler; #endif
  12. Update: I have a shader loading using the ShadersStore array. BABYLON.Effect.ShadersStore[`${part.url}FragmentShader`] = ` precision highp float; varying vec2 vUV; struct Color { vec3 color } Color myColor; void main(void) { gl_FragColor = vec4(1., 0., 0., 1.); } `; This works, and I can update the fragment shader. But it appears that Babylon doesn't support GLSL structures? Is there a way to access the shader uniforms directly?
  13. I think I'll be posting a lot as we port from ThreeJS over to Babylon, so apologies. Our application allows user input to affect the appears of a 3D object. A user can change out a material on an object. Sometimes, this means that the uniforms should change. For instance, we may want to use a structure like: struct Graphic { vec2 flip; vec2 offset; float rotation; vec2 scale; sampler2D texture; sampler2D normal; }; However, if the graphic does not have a normal texture, we don't need that texture slot so I'll write the structure on the
  • Create New...