Good evening every body.
To present my self very fast, i’m a french student and i want become a 3D developer. i supose like you ! Now days, i program since 3 years in OpenGL. So i’m very well with all programable shaders and VBOs. I write this message to submit my suggestion for the next release. Since OpenGL 4.0, the graphic shaders pipe line is :
- Vertex Shader
- Tessellation Control Shader
- Tessellation Evaluation Shader
- Geometry Shader
- Fragment Shader
And i enjoy Tessellation Shaders : there are a very nice new technology ! Well Done !
My suggestion is : add a new shader type like this :
- Buffer Shader <- the new shader
- Vertex Shader
- Tessellation Control Shader
- Tessellation Evaluation Shader
- Geometry Shader
- Fragment Shader
This mysterious shader should be create for programming our own memory access to GL_ARRAY_BUFFERs and GL_ELEMENT_ARRAY_BUFFERs. It should be specialize in unsigned integer computation. I think you will understand why.
example code for GL_PATCH_VERTICES = 3:
// ------------------ BUFFER SHADER
#version 420 // (I supose ??? =D)
uniform layout(location = 0) arrayBuffer VertexBuffer ; // it's a 3 float components array store in the GPU's memory
uniform layout(location = 1) arrayBuffer TextureCoordBuffer ; // it's a 2 float components array store in the GPU's memory
uniform layout(location = 2) arrayBuffer TriangleNormalBuffer ; // it's a 3 float components int array store in the GPU's memory
uniform layout(location = 3) arrayBuffer IdBuffer ; // it's a unsigned int array store in the GPU's memory
out vec4 Vertex ;
out vec2 TextureCoord ;
out vec3 TriangleNormal ;
void main ()
{
// ---------- CALCUL VERTEX MEMORY POSITION
uint VertexPosition = getUint(IdBuffer, gl_PatchId * 3 + gl_VertexId);
// ---------- LOAD VERTEX VECTORS
Vertex = vec4(getVec3(VertexBuffer, VertexPosition * 12), 1.0); // 12 = 3 * sizeof(float) = 3 * 4
TextureCoord = getVec2(TextureCoordBuffer, VertexPosition * 8); // 8 = 2 * sizeof(float) = 2 * 4
// ---------- LOAD FACE VECTORS
TriangleNormal = getVec3(TriangleNormalBuffer, gl_PatchId * 12); // 12 = 3 * sizeof(float) = 3 * 4
// compiler should detect that this previous line doesn't change for each Vertex and execute it only one time per patchs
}
// gl_PatchId is the face drawing number
// gl_VertexId is the vertex drawing number varying from 0 to (GL_PATCH_VERTICES - 1)
And a vertex shader to show inputs.
// ------------------ VERTEX SHADER
#version 420 // (I supose ??? =D)
// ---------- VERTEX SHADER
uniform [...]
in vec4 Vertex ;
in vec2 TextureCoord ;
in vec3 TriangleNormal ;
out [...]
void main ()
{
// classic vertex shader with any differences needed from GLSL 4.1
}
And now 2 new functions for OpenGL API
// ------------------ NEW FUNCTIONS
/*
function to assign each buffer to locations (little like textures)
*/
glBindBufferAtLocation (GLenum target, GLuint buffer, GLuint location);
/*
function to draw with varying gl_PatchId of the buffer shader like :
for ( gl_PatchId = start ; gl_PatchId < (start + count) ; gl_PatchId ++ )
*/
glDrawBufferElements (GLenum mode, GLsizei start, GLsizei count);
or // glDrawBufferElements (GLenum mode, GLuint start, GLuint count);
// ------------------ C PROGRAMM
glUseProgram (BufferShaderId);
glPatchParameteri (GL_PATCH_VERTICES, 3);
glBindBufferAtLocation (GL_ARRAY_BUFFER, VertexBufferId, 0);
glBindBufferAtLocation (GL_ARRAY_BUFFER, TextureCoordBufferId, 1);
glBindBufferAtLocation (GL_ARRAY_BUFFER, TriangleNormalBufferId, 2);
glBindBufferAtLocation (GL_ELEMENT_ARRAY_BUFFER, TriangleIndicesBufferId, 3);
glDrawBufferElements (GL_PATCH, TriangleStartId, TriangleCount);
// may be a GL_PATCH_STRIP ?
Of course all new name i have invented here is only to show how it should work with maximum explicit intentions.
I think this new kind of shader can bring a lot memory size and band-witch optimizations, because in this example, we can separate vertex access and face access, and do lot of other things !
What do you thing about ?
I will be very excited if you like and add my idea to opengl ! Thank you for reading. Please excuse me for my english.