uniform GLSL uniform vec 3 positions1000 C std

  • Slides: 13
Download presentation

Обычные uniform-переменные //GLSL uniform vec 3 positions[1000]; //C++ std: : vector<glm: : vec 3>

Обычные uniform-переменные //GLSL uniform vec 3 positions[1000]; //C++ std: : vector<glm: : vec 3> positions; GLint uniform. Loc = gl. Get. Uniform. Location(_program. Id, “positions”); gl. Uniform 3 fv(uniform. Loc, positions. size(), positions. data());

Uniform Buffer Object Группировка обычных юниформ-переменных для удобства struct Light. Info { vec 3

Uniform Buffer Object Группировка обычных юниформ-переменных для удобства struct Light. Info { vec 3 pos; vec 3 La; vec 3 Ld; vec 3 Ls; float a 0; float a 1; float a 2; }; uniform Light. Info light; Юниформ-блок layout(std 140) uniform Light. Info { vec 3 pos; vec 3 La; vec 3 Ld; vec 3 Ls; float a 0; float a 1; float a 2; } light;

Uniform Buffer Object //GLSL layout(std 140) uniform Positions { vec 3 positions[4000]; }; //C++

Uniform Buffer Object //GLSL layout(std 140) uniform Positions { vec 3 positions[4000]; }; //C++ std: : vector<glm: : vec 3> positions; Gluint ubo; gl. Gen. Buffers(1, & ubo); gl. Bind. Buffer(GL_UNIFORM_BUFFER, ubo); gl. Buffer. Data(GL_UNIFORM_BUFFER, размер, указатель, GL_DYNAMIC_DRAW); gl. Bind. Buffer. Base(GL_UNIFORM_BUFFER, 0, ubo); unsigned int ubo. Index = gl. Get. Uniform. Block. Index(_program. Id, "Positions"); gl. Uniform. Block. Binding(_program. Id, ubo. Index, 0); //0 я точка привязки

Shader Storage Buffer Object //GLSL layout(std 430) buffer Positions { vec 3 positions[]; };

Shader Storage Buffer Object //GLSL layout(std 430) buffer Positions { vec 3 positions[]; }; //C++ std: : vector<glm: : vec 3> positions; Gluint ssbo; gl. Gen. Buffers(1, & ssbo); gl. Bind. Buffer(GL_SHADER_STORAGE_BUFFER, ssbo); gl. Buffer. Data(GL_SHADER_STORAGE_BUFFER, размер, указатель, GL_DYNAMIC_DRAW); gl. Bind. Buffer. Base(GL_SHADER_STORAGE_BUFFER, 0, ssbo); unsigned int ssbo. Index = gl. Get. Program. Resource. Index(_program. Id, GL_SHADER_STORAGE_BLOCK, "Positions"); gl. Shader. Storage. Block. Binding(_program. Id, ssbo. Index, 0); //0 я точка привязки

Texture Buffer //GLSL uniform sampler. Buffer tex. Buf; //C++ std: : vector<glm: : vec

Texture Buffer //GLSL uniform sampler. Buffer tex. Buf; //C++ std: : vector<glm: : vec 3> positions; Gluint tbo; gl. Gen. Buffers(1, & tbo); gl. Bind. Buffer(GL_TEXTURE_BUFFER, tbo); gl. Buffer. Data(GL_TEXTURE_BUFFER, размер, указатель, GL_DYNAMIC_DRAW); Gluint tex. Id; gl. Gen. Textures(1, &tex. Id); gl. Bind. Texture(GL_TEXTURE_BUFFER, tex. Id) gl. Tex. Buffer(GL_TEXTURE_BUFFER, GL_RGB 32 F_ARB, tbo);

Vertex Attribute Divisor //GLSL layout(location = 3) in vec 3 model. Pos; //C++ std:

Vertex Attribute Divisor //GLSL layout(location = 3) in vec 3 model. Pos; //C++ std: : vector<glm: : vec 3> positions; Gluint vbo; gl. Gen. Buffers(1, & vbo); gl. Bind. Buffer(GL_ARRAY_BUFFER, vbo); gl. Buffer. Data(GL_ARRAY_BUFFER, размер, указатель, GL_DYNAMIC_DRAW); gl. Bind. Vertex. Array(_vao); gl. Enable. Vertex. Attrib. Array(3); gl. Vertex. Attrib. Pointer(3, 3, GL_FLOAT, GL_FALSE, 0, 0); gl. Vertex. Attrib. Divisor(3, 1);