I am coding my own rendering engine. I am currently working on the ground. I create a landscape with glDrawArraysInstanced. The terrain is made of many "pieces". Each piece is one quad, which is also one example of a draw call. Each quad is then tessellated in tessellation shaders. For my shader inputs, I use VBOs , instanced VBOs (using the vertex attribute attribute) and texture buffers . This is a simple example of one of my shaders:
#version 410 core
layout (location = 0) in vec3 perVertexVector;
layout (location = 1) in vec3 perInstanceVector;
uniform samplerBuffer someTextureBuffer;
out vec3 outputVector;
void main()
{
outputVector = something...whatever...;
}
, . 60-70 FPS. , VBO . - , 120-160 FPS! ( !). , instanced.
instanced ( ):
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBufferData(GL_ARRAY_BUFFER, size, buffer, GL_DYNAMIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), (GLvoid*)0);
glEnableVertexAttribArray(0);
glVertexAttribDivisor(0, 1);
:
glBindTexture(GL_TEXTURE_BUFFER, textureVBO);
glTexBuffer(GL_TEXTURE_BUFFER, GL_RGB32F, VBO);
, - , . ... , , , , , .
, .
(glDrawArraysInstanced) . , FBO . ( ), , 90 FPS, 60 FPS, .
!, , , . , ( 120-150 )!
, - - , , , , .
:
, instanced?
EDIT:
:
, , , glsl:
layout (location = 1) in vec3 perInstanceVector;
outputVector = perInstanceVector;
:
uniform samplerBuffer textureBuffer;
outputVector = texelFetch(textureBuffer, gl_InstanceID).xyz
, , .