Browse Source

Shaders: make default indentity matrices more explicit in the code.

pull/481/head
Vladimír Vondruš 6 years ago
parent
commit
e7b9ca735e
  1. 5
      src/Magnum/Shaders/DistanceFieldVector.cpp
  2. 5
      src/Magnum/Shaders/Flat.cpp
  3. 8
      src/Magnum/Shaders/MeshVisualizer.cpp
  4. 9
      src/Magnum/Shaders/Phong.cpp
  5. 5
      src/Magnum/Shaders/Vector.cpp
  6. 2
      src/Magnum/Shaders/VertexColor.cpp

5
src/Magnum/Shaders/DistanceFieldVector.cpp

@ -104,8 +104,9 @@ template<UnsignedInt dimensions> DistanceFieldVector<dimensions>::DistanceFieldV
/* Set defaults in OpenGL ES (for desktop they are set in shader code itself) */
#ifdef MAGNUM_TARGET_GLES
setTransformationProjectionMatrix({});
if(flags & Flag::TextureTransformation) setTextureMatrix({});
setTransformationProjectionMatrix(MatrixTypeFor<dimensions, Float>{Math::IdentityInit});
if(flags & Flag::TextureTransformation)
setTextureMatrix(Matrix3{Math::IdentityInit});
setColor(Color4{1.0f}); /* Outline color is zero by default */
setOutlineRange(0.5f, 1.0f);
setSmoothness(0.04f);

5
src/Magnum/Shaders/Flat.cpp

@ -142,8 +142,9 @@ template<UnsignedInt dimensions> Flat<dimensions>::Flat(const Flags flags): _fla
/* Set defaults in OpenGL ES (for desktop they are set in shader code itself) */
#ifdef MAGNUM_TARGET_GLES
setTransformationProjectionMatrix({});
if(flags & Flag::TextureTransformation) setTextureMatrix({});
setTransformationProjectionMatrix(MatrixTypeFor<dimensions, Float>{Math::IdentityInit});
if(flags & Flag::TextureTransformation)
setTextureMatrix(Matrix3{Math::IdentityInit});
setColor(Magnum::Color4{1.0f});
if(flags & Flag::AlphaMask) setAlphaMask(0.5f);
/* Object ID is zero by default */

8
src/Magnum/Shaders/MeshVisualizer.cpp

@ -294,7 +294,7 @@ MeshVisualizer2D::MeshVisualizer2D(const Flags flags): Implementation::MeshVisua
/* Set defaults in OpenGL ES (for desktop they are set in shader code itself) */
#ifdef MAGNUM_TARGET_GLES
setTransformationProjectionMatrix({});
setTransformationProjectionMatrix(Matrix3{Math::IdentityInit});
if(flags & (Flag::Wireframe
#ifndef MAGNUM_TARGET_GLES2
|Flag::InstancedObjectId|Flag::VertexId|Flag::PrimitiveIdFromVertexId
@ -513,8 +513,8 @@ MeshVisualizer3D::MeshVisualizer3D(const Flags flags): Implementation::MeshVisua
/* Set defaults in OpenGL ES (for desktop they are set in shader code itself) */
#ifdef MAGNUM_TARGET_GLES
setTransformationMatrix({});
setProjectionMatrix({});
setTransformationMatrix(Matrix4{Math::IdentityInit});
setProjectionMatrix(Matrix4{Math::IdentityInit});
if(flags & (Flag::Wireframe
#ifndef MAGNUM_TARGET_GLES2
|Flag::InstancedObjectId|Flag::VertexId|Flag::PrimitiveIdFromVertexId
@ -539,7 +539,7 @@ MeshVisualizer3D::MeshVisualizer3D(const Flags flags): Implementation::MeshVisua
#endif
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
if(flags & (Flag::TangentDirection|Flag::BitangentFromTangentDirection|Flag::BitangentDirection|Flag::NormalDirection)) {
setNormalMatrix({});
setNormalMatrix(Matrix3x3{Math::IdentityInit});
setLineWidth(1.0f);
setLineLength(1.0f);
}

9
src/Magnum/Shaders/Phong.cpp

@ -252,8 +252,8 @@ Phong::Phong(const Flags flags, const UnsignedInt lightCount): _flags{flags}, _l
/* Default to fully opaque white so we can see the textures */
if(flags & Flag::AmbientTexture) setAmbientColor(Magnum::Color4{1.0f});
else setAmbientColor(Magnum::Color4{0.0f});
setTransformationMatrix({});
setProjectionMatrix({});
setTransformationMatrix(Matrix4{Math::IdentityInit});
setProjectionMatrix(Matrix4{Math::IdentityInit});
if(lightCount) {
setDiffuseColor(Magnum::Color4{1.0f});
setSpecularColor(Magnum::Color4{1.0f, 0.0f});
@ -266,9 +266,10 @@ Phong::Phong(const Flags flags, const UnsignedInt lightCount): _flags{flags}, _l
setLightSpecularColors(colors);
setLightRanges(Containers::Array<Float>{Containers::DirectInit, lightCount, Constants::inf()});
/* Light position is zero by default */
setNormalMatrix({});
setNormalMatrix(Matrix3x3{Math::IdentityInit});
}
if(flags & Flag::TextureTransformation) setTextureMatrix({});
if(flags & Flag::TextureTransformation)
setTextureMatrix(Matrix3{Math::IdentityInit});
if(flags & Flag::AlphaMask) setAlphaMask(0.5f);
/* Object ID is zero by default */
#endif

5
src/Magnum/Shaders/Vector.cpp

@ -101,8 +101,9 @@ template<UnsignedInt dimensions> Vector<dimensions>::Vector(const Flags flags):
/* Set defaults in OpenGL ES (for desktop they are set in shader code itself) */
#ifdef MAGNUM_TARGET_GLES
setTransformationProjectionMatrix({});
if(flags & Flag::TextureTransformation) setTextureMatrix({});
setTransformationProjectionMatrix(MatrixTypeFor<dimensions, Float>{Math::IdentityInit});
if(flags & Flag::TextureTransformation)
setTextureMatrix(Matrix3{Math::IdentityInit});
setColor(Color4{1.0f}); /* Background color is zero by default */
#endif
}

2
src/Magnum/Shaders/VertexColor.cpp

@ -88,7 +88,7 @@ template<UnsignedInt dimensions> VertexColor<dimensions>::VertexColor() {
/* Set defaults in OpenGL ES (for desktop they are set in shader code itself) */
#ifdef MAGNUM_TARGET_GLES
setTransformationProjectionMatrix(MatrixTypeFor<dimensions, Float>{});
setTransformationProjectionMatrix(MatrixTypeFor<dimensions, Float>{Math::IdentityInit});
#endif
}

Loading…
Cancel
Save