Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions mplot/VisualDefaultShaders.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ namespace mplot
"uniform float alpha;\n";
const char* defaultVtxShader_instance_uniforms =
"uniform mat4 s_matrix;\n" // scaling matrix
"uniform int instance_count = 0;\n"
"uniform int instance_start = -1;\n"
"uniform int instparam_count = 0;\n";
"uniform int instance_count;\n"
"uniform int instance_start;\n"
"uniform int instparam_count;\n";
const char* defaultVtxShader_part1b =
"layout(location = 0) in vec4 position;\n"
"layout(location = 1) in vec4 normalin;\n"
Expand Down Expand Up @@ -50,7 +50,11 @@ namespace mplot
"{\n"
" if (instance_count > 0) {\n"
" int ipos_i = instance_start * 3 + gl_InstanceID * 3;\n"
" vec4 iposv = { ipos[ipos_i], ipos[ipos_i + 1], ipos[ipos_i + 2], 0 };\n"
" vec4 iposv;\n"
" iposv[0] = ipos[ipos_i];\n"
" iposv[1] = ipos[ipos_i + 1];\n"
" iposv[2] = ipos[ipos_i + 2];\n"
" iposv[3] = 0.0;\n"
" if (instparam_count > 0) {\n"
" int idx = gl_InstanceID % instparam_count;\n"
" int ippos_i = instance_start * 5;\n"
Expand Down
12 changes: 8 additions & 4 deletions shaders/Visual_instancing.vert.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ uniform mat4 m_matrix;
uniform mat4 v_matrix;
uniform mat4 p_matrix;
uniform float alpha;
uniform int instance_count = 0;
uniform int instance_start = -1;
uniform int instparam_count = 0;
uniform int instance_count;
uniform int instance_start;
uniform int instparam_count;
layout(location = 0) in vec4 position;
layout(location = 1) in vec4 normalin;
layout(location = 2) in vec3 color;
Expand All @@ -21,7 +21,11 @@ void main()
{
if (instance_count > 0) {
int ipos_i = instance_start * 3 + gl_InstanceID * 3;
vec4 iposv = { ipos[ipos_i], ipos[ipos_i + 1], ipos[ipos_i + 2], 0 };
vec4 iposv;
iposv[0] = ipos[ipos_i];
iposv[1] = ipos[ipos_i + 1];
iposv[2] = ipos[ipos_i + 2];
iposv[3] = 0.0;
if (instparam_count > 0) {
int idx = gl_InstanceID % instparam_count;
int ippos_i = instance_start * 5;
Expand Down
Loading