diff --git a/doc/generated/shaders.cpp b/doc/generated/shaders.cpp index 7907cfa4c..91ce8dbcb 100644 --- a/doc/generated/shaders.cpp +++ b/doc/generated/shaders.cpp @@ -120,6 +120,7 @@ int ShaderVisualizer::exec() { framebuffer.attachRenderbuffer(Framebuffer::ColorAttachment{0}, color); Renderer::enable(Renderer::Feature::DepthTest); + Renderer::setClearColor(0x000000_rgbaf); for(auto fun: {&ShaderVisualizer::phong, &ShaderVisualizer::meshVisualizer, @@ -144,8 +145,8 @@ int ShaderVisualizer::exec() { namespace { const auto Projection = Matrix4::perspectiveProjection(35.0_degf, 1.0f, 0.001f, 100.0f); const auto Transformation = Matrix4::translation(Vector3::zAxis(-5.0f)); - const auto BaseColor = Color3::fromHsv(216.0_degf, 0.85f, 1.0f); - const auto OutlineColor = Color3{0.95f}; + const auto BaseColor = 0x2f83cc_rgbf; + const auto OutlineColor = 0xdcdcdc_rgbf; } std::string ShaderVisualizer::phong() { @@ -154,7 +155,7 @@ std::string ShaderVisualizer::phong() { std::tie(mesh, vertices, indices) = MeshTools::compile(Primitives::UVSphere::solid(16, 32), BufferUsage::StaticDraw); Shaders::Phong shader; - shader.setAmbientColor(Color3(0.025f)) + shader.setAmbientColor(0x22272e_rgbf) .setDiffuseColor(BaseColor) .setShininess(200.0f) .setLightPosition({5.0f, 5.0f, 7.0f}) @@ -209,7 +210,7 @@ std::string ShaderVisualizer::vertexColor() { std::vector colors; colors.reserve(sphere.positions(0).size()); for(Vector3 position: sphere.positions(0)) - colors.push_back(Color3::fromHsv(Math::lerp(240.0_degf, 420.0_degf, Math::max(1.0f - (position - target).length(), 0.0f)), 0.85f, 0.85f)); + colors.push_back(Color3::fromHsv(Math::lerp(240.0_degf, 420.0_degf, Math::max(1.0f - (position - target).length(), 0.0f)), 0.75f, 0.75f)); Buffer vertices, indices; vertices.setData(MeshTools::interleave(sphere.positions(0), colors), BufferUsage::StaticDraw); diff --git a/doc/shaders-distancefieldvector.png b/doc/shaders-distancefieldvector.png index c54d99240..15044a28d 100644 Binary files a/doc/shaders-distancefieldvector.png and b/doc/shaders-distancefieldvector.png differ diff --git a/doc/shaders-flat.png b/doc/shaders-flat.png index 2aa2037ec..bbfe0e66d 100644 Binary files a/doc/shaders-flat.png and b/doc/shaders-flat.png differ diff --git a/doc/shaders-meshvisualizer.png b/doc/shaders-meshvisualizer.png index 896dda575..1a38dafb0 100644 Binary files a/doc/shaders-meshvisualizer.png and b/doc/shaders-meshvisualizer.png differ diff --git a/doc/shaders-phong.png b/doc/shaders-phong.png index 2f1a44a33..185e6d38a 100644 Binary files a/doc/shaders-phong.png and b/doc/shaders-phong.png differ diff --git a/doc/shaders-vector.png b/doc/shaders-vector.png index 9697fdd7a..cd8a01f9e 100644 Binary files a/doc/shaders-vector.png and b/doc/shaders-vector.png differ diff --git a/doc/shaders-vertexcolor.png b/doc/shaders-vertexcolor.png index a865c87e0..9017d2c50 100644 Binary files a/doc/shaders-vertexcolor.png and b/doc/shaders-vertexcolor.png differ diff --git a/src/Magnum/Shaders/DistanceFieldVector.h b/src/Magnum/Shaders/DistanceFieldVector.h index d99f9cc72..4f6bbee2a 100644 --- a/src/Magnum/Shaders/DistanceFieldVector.h +++ b/src/Magnum/Shaders/DistanceFieldVector.h @@ -52,10 +52,11 @@ value passed to @ref setSmoothness(). You need to provide @ref Position and @image html shaders-distancefieldvector.png @image latex shaders-distancefieldvector.png -## Example usage +@section Shaders-DistanceFieldVector-usage Example usage Common mesh setup: -@code + +@code{.cpp} struct Vertex { Vector2 position; Vector2 textureCoordinates; @@ -72,13 +73,14 @@ mesh.addVertexBuffer(vertices, 0, @endcode Common rendering setup: -@code + +@code{.cpp} Matrix3 transformationMatrix, projectionMatrix; Texture2D texture; Shaders::DistanceFieldVector2D shader; -shader.setColor(Color3::fromHSV(216.0_degf, 0.85f, 1.0f)) - .setOutlineColor(Color3{0.95f}) +shader.setColor(0x2f83cc_rgbf) + .setOutlineColor(0xdcdcdc_rgbf) .setOutlineRange(0.6f, 0.4f) .setVectorTexture(texture) .setTransformationProjectionMatrix(projectionMatrix*transformationMatrix); @@ -148,12 +150,12 @@ template class MAGNUM_SHADERS_EXPORT DistanceFieldVector * @return Reference to self (for method chaining) * * Parameter @p start describes where fill ends and possible outline - * starts. Initial value is `0.5f`, larger values will make the vector - * art look thinner, smaller will make it look thicker. + * starts. Initial value is @cpp 0.5f @ce, larger values will make the + * vector art look thinner, smaller will make it look thicker. * * Parameter @p end describes where outline ends. If set to value * larger than @p start the outline is not drawn. Initial value is - * `1.0f`. + * @cpp 1.0f @ce. * * @see @ref setOutlineColor() */ @@ -168,7 +170,7 @@ template class MAGNUM_SHADERS_EXPORT DistanceFieldVector * * Larger values will make edges look less aliased (but blurry), * smaller values will make them look more crisp (but possibly - * aliased). Initial value is `0.04f`. + * aliased). Initial value is @cpp 0.04f @ce. */ DistanceFieldVector& setSmoothness(Float value) { AbstractShaderProgram::setUniform(_smoothnessUniform, value); diff --git a/src/Magnum/Shaders/Flat.h b/src/Magnum/Shaders/Flat.h index 34187c63f..b61ad1be7 100644 --- a/src/Magnum/Shaders/Flat.h +++ b/src/Magnum/Shaders/Flat.h @@ -62,12 +62,13 @@ For coloring the texture based on intensity you can use the @ref Vector shader. @image html shaders-flat.png @image latex shaders-flat.png -## Example usage +@section Shaders-Flat-usage Example usage -### Colored mesh +@subsection Shaders-Flat-usage-colored Colored mesh Common mesh setup: -@code + +@code{.cpp} struct Vertex { Vector3 position; }; @@ -81,21 +82,23 @@ mesh.addVertexBuffer(vertices, 0, Shaders::Flat3D::Position{}); @endcode Common rendering setup: -@code + +@code{.cpp} Matrix4 transformationMatrix = Matrix4::translation(Vector3::zAxis(-5.0f)); Matrix4 projectionMatrix = Matrix4::perspectiveProjection(35.0_degf, 1.0f, 0.001f, 100.0f); Shaders::Flat3D shader; -shader.setColor(Color3::fromHSV(216.0_degf, 0.85f, 1.0f)) +shader.setColor(0x2f83cc_rgbf) .setTransformationProjectionMatrix(projectionMatrix*transformationMatrix); mesh.draw(shader); @endcode -### Textured mesh +@subsection Shaders-Flat-usage-textured Textured mesh Common mesh setup: -@code + +@code{.cpp} struct Vertex { Vector3 position; Vector2 textureCoordinates; @@ -112,7 +115,8 @@ mesh.addVertexBuffer(vertices, 0, @endcode Common rendering setup: -@code + +@code{.cpp} Matrix4 transformationMatrix, projectionMatrix; Texture2D texture; @@ -198,8 +202,9 @@ template class MAGNUM_SHADERS_EXPORT Flat: public Abstra * @brief Set color * @return Reference to self (for method chaining) * - * If @ref Flag::Textured is set, default value is `{1.0f, 1.0f, 1.0f}` - * and the color will be multiplied with texture. + * If @ref Flag::Textured is set, default value is + * @cpp 0xffffffff_rgbaf @ce and the color will be multiplied with + * texture. * @see @ref setTexture() */ Flat& setColor(const Color4& color){ diff --git a/src/Magnum/Shaders/Generic.h b/src/Magnum/Shaders/Generic.h index 98dc633ae..542a8067f 100644 --- a/src/Magnum/Shaders/Generic.h +++ b/src/Magnum/Shaders/Generic.h @@ -83,7 +83,7 @@ template struct Generic { constexpr explicit Color(Components components, DataType dataType = DataType::Float, DataOptions dataOptions = {}); #ifdef MAGNUM_BUILD_DEPRECATED - /** @copybrief Color(Components, DataType, DataOptions) + /** @brief @copybrief Color(Components, DataType, DataOptions) * @deprecated Use @ref Color(Components, DataType, DataOptions) instead. */ CORRADE_DEPRECATED("use Color(Components, DataType, DataOptions) instead") constexpr explicit Color(DataType dataType = DataType::Float, DataOptions dataOptions = {}); diff --git a/src/Magnum/Shaders/MeshVisualizer.h b/src/Magnum/Shaders/MeshVisualizer.h index 5c43ad575..c389e134b 100644 --- a/src/Magnum/Shaders/MeshVisualizer.h +++ b/src/Magnum/Shaders/MeshVisualizer.h @@ -47,7 +47,7 @@ Uses geometry shader to visualize wireframe of 3D meshes. You need to provide @image html shaders-meshvisualizer.png @image latex shaders-meshvisualizer.png -## Wireframe visualization +@section Shaders-MeshVisualizer-wireframe Wireframe visualization Wireframe visualization is done by enabling @ref Flag::Wireframe. It is done either using geometry shaders or with help of additional vertex information. @@ -71,12 +71,13 @@ you have OpenGL < 3.1 or OpenGL ES 2.0, you need to provide also If using geometry shaders on OpenGL ES, @extension{NV,shader_noperspective_interpolation} is optionally used for improving line appearance. -## Example usage +@section Shaders-MeshVisualizer-usage Example usage -### Wireframe visualization with geometry shader (desktop GL) +@subsection Shaders-MeshVisualizer-usage-wireframe-geom Wireframe visualization with geometry shader (desktop GL) Common mesh setup: -@code + +@code{.cpp} struct Vertex { Vector3 position; }; @@ -90,24 +91,26 @@ mesh.addVertexBuffer(vertices, 0, Shaders::MeshVisualizer::Position{}); @endcode Common rendering setup: -@code + +@code{.cpp} Matrix4 transformationMatrix = Matrix4::translation(Vector3::zAxis(-5.0f)); Matrix4 projectionMatrix = Matrix4::perspectiveProjection(35.0_degf, 1.0f, 0.001f, 100.0f); Shaders::MeshVisualizer shader{Shaders::MeshVisualizer::Wireframe}; -shader.setColor(Color3::fromHSV(216.0_degf, 0.85f, 1.0f)) - .setWireframeColor(Color3{0.95f}) +shader.setColor(0x2f83cc_rgbf) + .setWireframeColor(0xdcdcdc_rgbf) .setViewportSize(defaultFramebuffer.viewport().size()) .setTransformationProjectionMatrix(projectionMatrix*transformationMatrix); mesh.draw(shader); @endcode -### Wireframe visualization without geometry shader on older hardware +@subsection Shaders-MeshVisualizer-usage-wireframe-no-geom-old Wireframe visualization without geometry shader on older hardware You need to provide also the @ref VertexIndex attribute. Mesh setup *in addition to the above*: -@code + +@code{.cpp} constexpr std::size_t vertexCount = std::extent::value; Float vertexIndex[vertexCount]; std::iota(vertexIndex, vertexIndex + vertexCount, 0.0f); @@ -119,22 +122,24 @@ mesh.addVertexBuffer(vertexIndices, 0, Shaders::MeshVisualizer::VertexIndex{}); @endcode Rendering setup: -@code + +@code{.cpp} Matrix4 transformationMatrix, projectionMatrix; Shaders::MeshVisualizer shader{Shaders::MeshVisualizer::Wireframe| Shaders::MeshVisualizer::NoGeometryShader}; -shader.setColor(Color3::fromHSV(216.0_degf, 0.85f, 1.0f)) - .setWireframeColor(Color3{0.95f}) +shader.setColor(0x2f83cc_rgbf) + .setWireframeColor(0xdcdcdc_rgbf) .setTransformationProjectionMatrix(projectionMatrix*transformationMatrix); mesh.draw(shader); @endcode -### Wireframe visualization of indexed meshes without geometry shader +@subsection Shaders-MeshVisualizer-usage-wireframe-no-geom Wireframe visualization of indexed meshes without geometry shader The vertices must be converted to non-indexed array. Mesh setup: -@code + +@code{.cpp} std::vector indices{ ... }; std::vector indexedPositions{ ... }; @@ -165,10 +170,10 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizer: public AbstractShaderProgram { * * @ref Magnum::Float "Float", used only in OpenGL < 3.1 and OpenGL ES * 2.0 if @ref Flag::Wireframe is enabled. This attribute (modulo 3) - * specifies index of given vertex in triangle, i.e. `0` for first, `1` - * for second, `2` for third. In OpenGL 3.1, OpenGL ES 3.0 and newer - * this value is provided by the shader itself, so the attribute is not - * needed. + * specifies index of given vertex in triangle, i.e. @cpp 0.0f @ce for + * first, @cpp 1.0f @ce for second, @cpp 2.0f @ce for third. In OpenGL + * 3.1, OpenGL ES 3.0 and newer this value is provided by the shader + * itself, so the attribute is not needed. */ typedef Attribute<3, Float> VertexIndex; @@ -267,8 +272,8 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizer: public AbstractShaderProgram { * @brief Set wireframe width * @return Reference to self (for method chaining) * - * Initial value is `1.0f`. Has effect only if @ref Flag::Wireframe is - * enabled. + * Initial value is @cpp 1.0f @ce. Has effect only if @ref Flag::Wireframe + * is enabled. */ MeshVisualizer& setWireframeWidth(Float width) { if(_flags & Flag::Wireframe) setUniform(_wireframeWidthUniform, width); @@ -279,8 +284,8 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizer: public AbstractShaderProgram { * @brief Set line smoothness * @return Reference to self (for method chaining) * - * Initial value is `2.0f`. Has effect only if @ref Flag::Wireframe is - * enabled. + * Initial value is @cpp 2.0f @ce. Has effect only if @ref Flag::Wireframe + * is enabled. */ MeshVisualizer& setSmoothness(Float smoothness); diff --git a/src/Magnum/Shaders/Phong.h b/src/Magnum/Shaders/Phong.h index 60952423c..1a0d58653 100644 --- a/src/Magnum/Shaders/Phong.h +++ b/src/Magnum/Shaders/Phong.h @@ -55,12 +55,13 @@ enabled textures. @image html shaders-phong.png @image latex shaders-phong.png -## Example usage +@section Shaders-Phong-usage Example usage -### Colored mesh +@subsection Shaders-Phong-usage-colored Colored mesh Common mesh setup: -@code + +@code{.cpp} struct Vertex { Vector3 position; Vector3 normal; @@ -77,12 +78,13 @@ mesh.addVertexBuffer(vertices, 0, @endcode Common rendering setup: -@code + +@code{.cpp} Matrix4 transformationMatrix = Matrix4::translation(Vector3::zAxis(-5.0f)); Matrix4 projectionMatrix = Matrix4::perspectiveProjection(35.0_degf, 1.0f, 0.001f, 100.0f); Shaders::Phong shader; -shader.setDiffuseColor(Color4::fromHSV(216.0_degf, 0.85f, 1.0f)) +shader.setDiffuseColor(0x2f83cc_rgbf) .setShininess(200.0f) .setLightPosition({5.0f, 5.0f, 7.0f}) .setTransformationMatrix(transformationMatrix) @@ -92,10 +94,11 @@ shader.setDiffuseColor(Color4::fromHSV(216.0_degf, 0.85f, 1.0f)) mesh.draw(shader); @endcode -### Diffuse and specular texture +@subsection Shaders-Phong-usage-texture Diffuse and specular texture Common mesh setup: -@code + +@code{.cpp} struct Vertex { Vector3 position; Vector3 normal; @@ -114,7 +117,8 @@ mesh.addVertexBuffer(vertices, 0, @endcode Common rendering setup: -@code + +@code{.cpp} Matrix4 transformationMatrix, projectionMatrix; Texture2D diffuseTexture, specularTexture; @@ -129,14 +133,15 @@ shader.setTextures(nullptr, &diffuseTexture, &specularTexture) mesh.draw(shader); @endcode -### Alpha-masked drawing +@subsection Shaders-Phong-usage-alpha Alpha-masked drawing For general alpha-masked drawing you need to provide ambient texture with alpha channel and set alpha channel of diffuse/specular color to `0.0f` so only ambient alpha will be taken into account. If you have diffuse texture combined with the alpha mask, you can use that texture for both ambient and diffuse part and then separate the alpha like this: -@code + +@code{.cpp} Shaders::Phong shader{Shaders::Phong::AmbientTexture| Shaders::Phong::DiffuseTexture}; shader.setTextures(&diffuseAlphaTexture, &diffuseAlphaTexture, nullptr) @@ -216,8 +221,8 @@ class MAGNUM_SHADERS_EXPORT Phong: public AbstractShaderProgram { * @return Reference to self (for method chaining) * * If @ref Flag::AmbientTexture is set, default value is - * `{1.0f, 1.0f, 1.0f, 1.0f}` and the color will be multiplied with - * ambient texture, otherwise default value is `{0.0f, 0.0f, 0.0f, 1.0f}`. + * @cpp 0xffffffff_rgbaf @ce and the color will be multiplied with + * ambient texture, otherwise default value is @cpp 0x000000ff_rgbaf @ce. * @see @ref setAmbientTexture() */ Phong& setAmbientColor(const Color4& color) { @@ -239,7 +244,7 @@ class MAGNUM_SHADERS_EXPORT Phong: public AbstractShaderProgram { * @return Reference to self (for method chaining) * * If @ref Flag::DiffuseTexture is set, default value is - * `{1.0f, 1.0f, 1.0f, 1.0f}` and the color will be multiplied with + * @cpp 0xffffffff_rgbaf @ce and the color will be multiplied with * diffuse texture. * @see @ref setDiffuseTexture() */ @@ -261,9 +266,8 @@ class MAGNUM_SHADERS_EXPORT Phong: public AbstractShaderProgram { * @brief Set specular color * @return Reference to self (for method chaining) * - * Default value is `{1.0f, 1.0f, 1.0f, 1.0f}`. Color will be - * multiplied with specular texture if @ref Flag::SpecularTexture is - * set. + * Default value is @cpp 0xffffffff_rgbaf @ce. Color will be multiplied + * with specular texture if @ref Flag::SpecularTexture is set. * @see @ref setSpecularTexture() */ Phong& setSpecularColor(const Color4& color) { @@ -297,7 +301,7 @@ class MAGNUM_SHADERS_EXPORT Phong: public AbstractShaderProgram { * @return Reference to self (for method chaining) * * The larger value, the harder surface (smaller specular highlight). - * If not set, default value is `80.0f`. + * If not set, default value is @cpp 80.0f @ce. */ Phong& setShininess(Float shininess) { setUniform(_shininessUniform, shininess); @@ -347,7 +351,7 @@ class MAGNUM_SHADERS_EXPORT Phong: public AbstractShaderProgram { * @brief Set light color * @return Reference to self (for method chaining) * - * If not set, default value is `{1.0f, 1.0f, 1.0f, 1.0f}`. + * If not set, default value is @cpp 0xffffffff_rgbaf @ce. */ Phong& setLightColor(const Color4& color) { setUniform(_lightColorUniform, color); diff --git a/src/Magnum/Shaders/Shaders.h b/src/Magnum/Shaders/Shaders.h index af67901ce..099603c20 100644 --- a/src/Magnum/Shaders/Shaders.h +++ b/src/Magnum/Shaders/Shaders.h @@ -26,7 +26,7 @@ */ /** @file - * @brief Forward declarations for @ref Magnum::Shaders namespace + * @brief Forward declarations for the @ref Magnum::Shaders namespace */ #include "Magnum/Types.h" diff --git a/src/Magnum/Shaders/Vector.h b/src/Magnum/Shaders/Vector.h index b073acde6..b6a534666 100644 --- a/src/Magnum/Shaders/Vector.h +++ b/src/Magnum/Shaders/Vector.h @@ -51,10 +51,11 @@ attributes in your triangle mesh and call at least @image html shaders-vector.png @image latex shaders-vector.png -## Example usage +@section Shaders-Vector-usage Example usage Common mesh setup: -@code + +@code{.cpp} struct Vertex { Vector2 position; Vector2 textureCoordinates; @@ -71,12 +72,13 @@ mesh.addVertexBuffer(vertices, 0, @endcode Common rendering setup: -@code + +@code{.cpp} Matrix3 transformationMatrix, projectionMatrix; Texture2D texture; Shaders::Vector2D shader; -shader.setColor(Color3::fromHSV(216.0_degf, 0.85f, 1.0f)) +shader.setColor(0x2f83cc_rgbf) .setVectorTexture(texture) .setTransformationProjectionMatrix(projectionMatrix*transformationMatrix); diff --git a/src/Magnum/Shaders/VertexColor.h b/src/Magnum/Shaders/VertexColor.h index 73348c715..e08eda3ad 100644 --- a/src/Magnum/Shaders/VertexColor.h +++ b/src/Magnum/Shaders/VertexColor.h @@ -49,13 +49,14 @@ attributes in your triangle mesh and call at least @image html shaders-vertexcolor.png @image latex shaders-vertexcolor.png -## Example usage +@section Shaders-VertexColor-example Example usage Common mesh setup. Note the explicit specification of components for the color -attribute -- the shader accepts four-component color attribute but, similarly +attribute --- the shader accepts four-component color attribute but, similarly to all other attributes, it's possible to supply also three-component colors if alpha is not important. -@code + +@code{.cpp} struct Vertex { Vector3 position; Color3 color; @@ -72,7 +73,8 @@ mesh.addVertexBuffer(vertices, 0, @endcode Common rendering setup: -@code + +@code{.cpp} Matrix4 transformationMatrix = Matrix4::translation(Vector3::zAxis(-5.0f)); Matrix4 projectionMatrix = Matrix4::perspectiveProjection(35.0_degf, 1.0f, 0.001f, 100.0f); diff --git a/src/Magnum/Shapes/Shapes.h b/src/Magnum/Shapes/Shapes.h index 97b821a7e..81f1adf1b 100644 --- a/src/Magnum/Shapes/Shapes.h +++ b/src/Magnum/Shapes/Shapes.h @@ -26,7 +26,7 @@ */ /** @file - * @brief Forward declarations for @ref Magnum::Shapes namespace + * @brief Forward declarations for the @ref Magnum::Shapes namespace */ #include "Magnum/Types.h"