Nacheitor Posted February 27, 2020 Share Posted February 27, 2020 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.