• Content Count

  • Joined

  • Last visited

  1. I would like to store a variable that was persistent between executions of a vertex shader. I have read a lot of information about SSBO (Shader Storage Buffer Object) but I can't find any working example. My original code would be this: precision highp float; // Attributes attribute vec3 position; // Uniforms uniform mat4 worldViewProjection; uniform float update; // Varying varying vec4 vPosition; float buffer[5000]; void main() { vec4 p = vec4( position, 1. ); vPosition = p; gl_Position = worldViewProjection * p; if (update == 0.0) { vPosition.z = buffer[gl_VertexID]; } else { buffer[gl_VertexID] = vPosition.z; } } The problem is that the array is initialized at each execution. How could I solve this? Thanks in advance.
  2. Thank you, Sebavan. The article is very instructive. I can change the transparency rendering order using the property alphaIndex.
  3. Hi again, I've been trying to load several models with the shader we did. The problem is that at the moment that two models are in the same scene, sometimes one is painted over the other, depending on the position of the camera. You can see it in the example: You can see how the order of the shaders changes by moving the camera from top to bottom. Would there be any way to make a model paint on top of the other, without depending on the position of the camera? Thanks.
  4. Hi, Prime8, I'm trying to work with vertex buffer but I dont get the same results than you: Would you know what the problem is? Thanks.
  5. Thanks Sebavan, I have chosen to implement the first approach. You can see the result here: I hope than someone need something like this, this thread could help him...
  6. Thank you, Sebavan, for your help. I cant use normal information because the barycentric information is different for each vertex depending to de facet to which it belongs. Barycentric information is the vertex coodinates inside each facet, in differents facets the same vertex have diferents coodinates... I dont want to use wireframe of the mesh because I want to draw the wireframe and the model at the same time. Like this:
  7. Here you have a playground: You can see that the sphere color is black.
  8. Hi, I'm trying to develop a shader in Babylon like this: The problem is that always return the barycentric attribute (0, 0, 0). Someone know what could be the problem? My shader code is the following: Thanks.
  9. Has someone worked with Shader Storage Buffer Object (SSBO) in Babylon? Maybe that could be the solution...
  10. I'm trying to do something like this: If I have a buffer between fragments shaders, I could have a record of what has been rendered in each pixel and thus be able to decide what should be painted or not. For example, taking the video as example. If the back part of the cylinder is rendered first, then the back part of the sphere, the front part of the cylinder should be discarded. I don't know if I explain. I don't know how I could implement that with the examples you have given me ... I'm sorry but it's the first time I've worked with shaders. Thanks in advance.
  11. Hi, I have a doubt. Would it be possible to share information between fragment shaders? I would like to have a buffer to share information between the different fragment shaders that affect a pixel of the final rendering of the scene. And in the end of the rendering cycle, clean all that information for the next rendering cycle. Thanks in advance.
  12. I'm working with MorphTargets in Babylon. I would like to save the result mesh of MorphTargets influences, but babylon don't give me the mesh and I don't know the internal calculations than Babylon do to obtain the final result. Does anyone know the internal calculations or how to obtain the final mesh? Thanks in advance.
  13. I,m trying to develop something like this using Babylon.js (The example is implemented in Unity 3D): I suppose this can be implemented using a shader. The user can move a sphere with the inverted normals, and the shader will have to calculate if this sphere is painted depending on its position in the z buffer. Is it possible to do this using babylon ShaderMaterial? Thanks in advance.