|
|
|
@ -694,28 +694,6 @@ vert.addSource(Utility::format( |
|
|
|
/* [GenericGL-custom-preprocessor] */ |
|
|
|
/* [GenericGL-custom-preprocessor] */ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
GL::Mesh mesh; |
|
|
|
|
|
|
|
/* [PhongGL-usage-instancing] */ |
|
|
|
|
|
|
|
struct { |
|
|
|
|
|
|
|
Matrix4 transformation; |
|
|
|
|
|
|
|
Matrix3x3 normal; |
|
|
|
|
|
|
|
} instanceData[] { |
|
|
|
|
|
|
|
{Matrix4::translation({1.0f, 2.0f, 0.0f})*Matrix4::rotationX(90.0_degf), {}}, |
|
|
|
|
|
|
|
{Matrix4::translation({2.0f, 1.0f, 0.0f})*Matrix4::rotationY(90.0_degf), {}}, |
|
|
|
|
|
|
|
{Matrix4::translation({3.0f, 0.0f, 1.0f})*Matrix4::rotationZ(90.0_degf), {}}, |
|
|
|
|
|
|
|
// ...
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
for(auto& instance: instanceData) |
|
|
|
|
|
|
|
instance.normal = instance.transformation.normalMatrix(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mesh.setInstanceCount(Containers::arraySize(instanceData)) |
|
|
|
|
|
|
|
.addVertexBufferInstanced(GL::Buffer{instanceData}, 1, 0, |
|
|
|
|
|
|
|
Shaders::PhongGL::TransformationMatrix{}, |
|
|
|
|
|
|
|
Shaders::PhongGL::NormalMatrix{}); |
|
|
|
|
|
|
|
/* [PhongGL-usage-instancing] */ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
GL::Mesh mesh; |
|
|
|
GL::Mesh mesh; |
|
|
|
/* [MeshVisualizerGL2D-usage-instancing] */ |
|
|
|
/* [MeshVisualizerGL2D-usage-instancing] */ |
|
|
|
@ -1064,6 +1042,28 @@ shader.bindTextures(&diffuseAlphaTexture, &diffuseAlphaTexture, nullptr, nullptr |
|
|
|
/* [PhongGL-usage-alpha] */ |
|
|
|
/* [PhongGL-usage-alpha] */ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
GL::Mesh mesh; |
|
|
|
|
|
|
|
/* [PhongGL-usage-instancing] */ |
|
|
|
|
|
|
|
struct { |
|
|
|
|
|
|
|
Matrix4 transformation; |
|
|
|
|
|
|
|
Matrix3x3 normal; |
|
|
|
|
|
|
|
} instanceData[] { |
|
|
|
|
|
|
|
{Matrix4::translation({1.0f, 2.0f, 0.0f})*Matrix4::rotationX(90.0_degf), {}}, |
|
|
|
|
|
|
|
{Matrix4::translation({2.0f, 1.0f, 0.0f})*Matrix4::rotationY(90.0_degf), {}}, |
|
|
|
|
|
|
|
{Matrix4::translation({3.0f, 0.0f, 1.0f})*Matrix4::rotationZ(90.0_degf), {}}, |
|
|
|
|
|
|
|
// ...
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
for(auto& instance: instanceData) |
|
|
|
|
|
|
|
instance.normal = instance.transformation.normalMatrix(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mesh.setInstanceCount(Containers::arraySize(instanceData)) |
|
|
|
|
|
|
|
.addVertexBufferInstanced(GL::Buffer{instanceData}, 1, 0, |
|
|
|
|
|
|
|
Shaders::PhongGL::TransformationMatrix{}, |
|
|
|
|
|
|
|
Shaders::PhongGL::NormalMatrix{}); |
|
|
|
|
|
|
|
/* [PhongGL-usage-instancing] */ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#ifndef MAGNUM_TARGET_GLES2 |
|
|
|
#ifndef MAGNUM_TARGET_GLES2 |
|
|
|
{ |
|
|
|
{ |
|
|
|
GL::Mesh mesh; |
|
|
|
GL::Mesh mesh; |
|
|
|
|