Sign in to follow this  
Nacheitor

Persistent buffer between vertex shader executions

Recommended Posts

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.

Share this post


Link to post
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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.