Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--Address inappropriate bitflag check; add vertexID flag to PBR shader #2090

Merged
merged 1 commit into from
May 1, 2023
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
14 changes: 8 additions & 6 deletions src/esp/gfx/GenericDrawable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 192,14 @@ void GenericDrawable::draw(const Mn::Matrix4& transformationMatrix,
// e.g., semantic mesh has its own per vertex annotation, which has been
// uploaded to GPU so simply pass 0 to the uniform "objectId" in the
// fragment shader
.setObjectId(static_cast<RenderCamera&>(camera).useDrawableIds()
? drawableId_
: ((flags_ & Mn::Shaders::PhongGL::Flag::InstancedObjectId ||
(flags_ & Mn::Shaders::PhongGL::Flag::ObjectIdTexture)))
? 0
: node_.getSemanticId())
.setObjectId(
static_cast<RenderCamera&>(camera).useDrawableIds() ? drawableId_
: ((((flags_ & Mn::Shaders::PhongGL::Flag::InstancedObjectId) ==
Mn::Shaders::PhongGL::Flag::InstancedObjectId) ||
((flags_ & Mn::Shaders::PhongGL::Flag::ObjectIdTexture)) ==
Mn::Shaders::PhongGL::Flag::ObjectIdTexture))
? 0
: node_.getSemanticId())
.setTransformationMatrix(transformationMatrix)
.setProjectionMatrix(camera.projectionMatrix())
.setNormalMatrix(normalMatrix);
Expand Down
5 changes: 3 additions & 2 deletions src/esp/gfx/PbrDrawable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 137,7 @@ void PbrDrawable::setMaterialValuesInternal(
materialData_->attribute<Mn::GL::Texture2D*>("emissiveTexturePointer");
}
if (materialData_->attribute<bool>("hasPerVertexObjectId")) {
flags_ |= PbrShader::Flag::ObjectId;
flags_ |= PbrShader::Flag::InstancedObjectId;
}
if (materialData_->isDoubleSided()) {
flags_ |= PbrShader::Flag::DoubleSided;
Expand Down Expand Up @@ -201,7 201,8 @@ void PbrDrawable::draw(const Mn::Matrix4& transformationMatrix,
// the fragment shader
.setObjectId(static_cast<RenderCamera&>(camera).useDrawableIds()
? drawableId_
: (flags_ & PbrShader::Flag::ObjectId
: ((flags_ & PbrShader::Flag::InstancedObjectId) ==
PbrShader::Flag::InstancedObjectId
? 0
: node_.getSemanticId()))
.setProjectionMatrix(camera.projectionMatrix())
Expand Down
16 changes: 11 additions & 5 deletions src/esp/gfx/PbrShader.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,32 175,38 @@ class PbrShader : public Magnum::GL::AbstractShaderProgram {
PrecomputedTangent = 1 << 10,

/**
* Enable object ID output.
* Enable object ID output for this shader.
*/
ObjectId = 1 << 11,

/**
* Support Instanced object ID. Retrieves a per-instance / per-vertex
* object ID from the @ref ObjectId attribute. If this is false, the shader
* will use the node's semantic ID
*/
InstancedObjectId = (1 << 12) | ObjectId,
/**
* Enable double-sided rendering.
* (Temporarily STOP supporting this functionality. See comments in
* the PbrDrawable::draw() function)
*/
DoubleSided = 1 << 12,
DoubleSided = 1 << 13,

/**
* Enable image based lighting
*/
ImageBasedLighting = 1 << 13,
ImageBasedLighting = 1 << 14,

/**
* render point light shadows using variance shadow map (VSM)
*/
ShadowsVSM = 1 << 14,
ShadowsVSM = 1 << 15,

/**
* Enable shader debug mode. Then developer can set the uniform
* PbrDebugDisplay in the fragment shader for debugging
*/
DebugDisplay = 1 << 15,
DebugDisplay = 1 << 16,
/*
* TODO: alphaMask
*/
Expand Down