Getting better'

This commit is contained in:
Sam Gateau 2018-09-24 22:34:43 -07:00
parent 7cf7eaa7c8
commit 69734ce21b
13 changed files with 33 additions and 49 deletions

View file

@ -226,4 +226,6 @@ void MakeLightingModel::run(const render::RenderContextPointer& renderContext, L
// make sure the enableTexturing flag of the render ARgs is in sync // make sure the enableTexturing flag of the render ARgs is in sync
renderContext->args->_enableTexturing = _lightingModel->isMaterialTexturingEnabled(); renderContext->args->_enableTexturing = _lightingModel->isMaterialTexturingEnabled();
renderContext->args->_enableBlendshape = _lightingModel->isBlendshapeEnabled();
renderContext->args->_enableSkinning = _lightingModel->isSkinningEnabled();
} }

View file

@ -85,32 +85,20 @@ void evalMeshDeformer(vec4 inPosition, out vec4 outPosition
<@endfunc@> <@endfunc@>
<@func declareMeshDeformerActivation(USE_SKINNING, USE_BLENDSHAPE, USE_LIGHTING_MODEL)@> <@func declareMeshDeformerActivation(USE_SKINNING, USE_BLENDSHAPE)@>
const BITFIELD MESH_DEFORMER_BLENDSHAPE_BIT = 0x00000001; const BITFIELD MESH_DEFORMER_BLENDSHAPE_BIT = 0x00000001;
const BITFIELD MESH_DEFORMER_SKINNING_BIT = 0x00000002; const BITFIELD MESH_DEFORMER_SKINNING_BIT = 0x00000002;
<@if USE_LIGHTING_MODEL@>
<@include LightingModel.slh@>
<@endif@>
<@if USE_BLENDSHAPE@> <@if USE_BLENDSHAPE@>
bool meshDeformer_doBlendshape(int meshKey) { bool meshDeformer_doBlendshape(int meshKey) {
<@if USE_LIGHTING_MODEL@>
return ((meshKey & MESH_DEFORMER_BLENDSHAPE_BIT) != 0) & bool(isBlendshapeEnabled());
<@else@>
return ((meshKey & MESH_DEFORMER_BLENDSHAPE_BIT) != 0); return ((meshKey & MESH_DEFORMER_BLENDSHAPE_BIT) != 0);
<@endif@>
} }
<@endif@> <@endif@>
<@if USE_SKINNING@> <@if USE_SKINNING@>
bool meshDeformer_doSkinning(int meshKey) { bool meshDeformer_doSkinning(int meshKey) {
<@if USE_LIGHTING_MODEL@>
return ((meshKey & MESH_DEFORMER_SKINNING_BIT) != 0) & bool(isSkinningEnabled());
<@else@>
return ((meshKey & MESH_DEFORMER_SKINNING_BIT) != 0); return ((meshKey & MESH_DEFORMER_SKINNING_BIT) != 0);
<@endif@>
} }
<@endif@> <@endif@>

View file

@ -243,10 +243,6 @@ ModelMeshPartPayload::ModelMeshPartPayload(ModelPointer model, int meshIndex, in
if (buffer != model->_blendshapeBuffers.end()) { if (buffer != model->_blendshapeBuffers.end()) {
_blendshapeBuffer = buffer->second; _blendshapeBuffer = buffer->second;
} }
if (!_isSkinned) {
qWarning() << "MeshPArt Payload is blendshape but not skinned";
}
} }
} }
@ -356,7 +352,7 @@ void ModelMeshPartPayload::setShapeKey(bool invalidateShapeKey, bool isWireframe
bool hasLightmap = drawMaterialKey.isLightmapMap(); bool hasLightmap = drawMaterialKey.isLightmapMap();
bool isUnlit = drawMaterialKey.isUnlit(); bool isUnlit = drawMaterialKey.isUnlit();
bool isSkinned = _isSkinned; bool isSkinned = _isBlendShaped || _isSkinned;
if (isWireframe) { if (isWireframe) {
isTranslucent = hasTangents = hasLightmap = isSkinned = false; isTranslucent = hasTangents = hasLightmap = isSkinned = false;
@ -424,7 +420,8 @@ void ModelMeshPartPayload::render(RenderArgs* args) {
//Bind the index buffer and vertex buffer and Blend shapes if needed //Bind the index buffer and vertex buffer and Blend shapes if needed
bindMesh(batch); bindMesh(batch);
auto drawcallInfo = (uint16_t) ((_isBlendShaped << 0) | (_isSkinned << 1)); // IF deformed pass the mesh key
auto drawcallInfo = (uint16_t) (((_isBlendShaped && args->_enableBlendshape) << 0) | ((_isSkinned && args->_enableSkinning) << 1));
if (drawcallInfo) { if (drawcallInfo) {
batch.setDrawcallInfo(drawcallInfo); batch.setDrawcallInfo(drawcallInfo);
} }

View file

@ -27,11 +27,6 @@ class Model;
class MeshPartPayload { class MeshPartPayload {
public: public:
struct DrawcallInfo {
uint32_t _geometryKey { 0 };
uint32_t _spare[3];
};
MeshPartPayload() {} MeshPartPayload() {}
MeshPartPayload(const std::shared_ptr<const graphics::Mesh>& mesh, int partIndex, graphics::MaterialPointer material); MeshPartPayload(const std::shared_ptr<const graphics::Mesh>& mesh, int partIndex, graphics::MaterialPointer material);

View file

@ -20,7 +20,7 @@
<@include MeshDeformer.slh@> <@include MeshDeformer.slh@>
<$declareMeshDeformer(1, _SCRIBE_NULL, 1, 0, 1)$> <$declareMeshDeformer(1, _SCRIBE_NULL, 1, 0, 1)$>
<$declareMeshDeformerActivation(1, 1, 1)$> <$declareMeshDeformerActivation(1, 1)$>
<@include LightingModel.slh@> <@include LightingModel.slh@>
@ -37,8 +37,8 @@ void main(void) {
vec4 deformedPosition = vec4(0.0, 0.0, 0.0, 0.0); vec4 deformedPosition = vec4(0.0, 0.0, 0.0, 0.0);
vec3 deformedNormal = vec3(0.0, 0.0, 0.0); vec3 deformedNormal = vec3(0.0, 0.0, 0.0);
evalMeshDeformer(inPosition, deformedPosition, inNormal.xyz, deformedNormal, evalMeshDeformer(inPosition, deformedPosition, inNormal.xyz, deformedNormal,
meshDeformer_doSkinning(_drawcallInfo.y), inSkinClusterIndex, inSkinClusterWeight, meshDeformer_doSkinning(_drawCallInfo.y), inSkinClusterIndex, inSkinClusterWeight,
meshDeformer_doBlendshape(_drawcallInfo.y), gl_VertexID); meshDeformer_doBlendshape(_drawCallInfo.y), gl_VertexID);
// pass along the color // pass along the color
_color.rgb = color_sRGBToLinear(inColor.rgb); _color.rgb = color_sRGBToLinear(inColor.rgb);

View file

@ -20,7 +20,7 @@
<@include MeshDeformer.slh@> <@include MeshDeformer.slh@>
<$declareMeshDeformer(1, _SCRIBE_NULL, 1, 1, 1)$> <$declareMeshDeformer(1, _SCRIBE_NULL, 1, 1, 1)$>
<$declareMeshDeformerActivation(1, 1, 1)$> <$declareMeshDeformerActivation(1, 1)$>
<@include render-utils/ShaderConstants.h@> <@include render-utils/ShaderConstants.h@>
@ -35,8 +35,8 @@ void main(void) {
vec4 deformedPosition = vec4(0.0, 0.0, 0.0, 0.0); vec4 deformedPosition = vec4(0.0, 0.0, 0.0, 0.0);
vec3 deformedNormal = vec3(0.0, 0.0, 0.0); vec3 deformedNormal = vec3(0.0, 0.0, 0.0);
evalMeshDeformer(inPosition, deformedPosition, inNormal.xyz, deformedNormal, evalMeshDeformer(inPosition, deformedPosition, inNormal.xyz, deformedNormal,
meshDeformer_doSkinning(_drawcallInfo.y), inSkinClusterIndex, inSkinClusterWeight, meshDeformer_doSkinning(_drawCallInfo.y), inSkinClusterIndex, inSkinClusterWeight,
meshDeformer_doBlendshape(_drawcallInfo.y), gl_VertexID); meshDeformer_doBlendshape(_drawCallInfo.y), gl_VertexID);
// pass along the color // pass along the color
_color.rgb = color_sRGBToLinear(inColor.rgb); _color.rgb = color_sRGBToLinear(inColor.rgb);

View file

@ -20,7 +20,7 @@
<@include MeshDeformer.slh@> <@include MeshDeformer.slh@>
<$declareMeshDeformer(1, 1, 1, _SCRIBE_NULL, 1)$> <$declareMeshDeformer(1, 1, 1, _SCRIBE_NULL, 1)$>
<$declareMeshDeformerActivation(1, 1, 1)$> <$declareMeshDeformerActivation(1, 1)$>
<@include render-utils/ShaderConstants.h@> <@include render-utils/ShaderConstants.h@>
@ -36,8 +36,8 @@ void main(void) {
vec3 deformedNormal = vec3(0.0, 0.0, 0.0); vec3 deformedNormal = vec3(0.0, 0.0, 0.0);
vec3 deformedTangent = vec3(0.0, 0.0, 0.0); vec3 deformedTangent = vec3(0.0, 0.0, 0.0);
evalMeshDeformer(inPosition, deformedPosition, inNormal.xyz, deformedNormal, inTangent.xyz, deformedTangent, evalMeshDeformer(inPosition, deformedPosition, inNormal.xyz, deformedNormal, inTangent.xyz, deformedTangent,
meshDeformer_doSkinning(_drawcallInfo.y), inSkinClusterIndex, inSkinClusterWeight, meshDeformer_doSkinning(_drawCallInfo.y), inSkinClusterIndex, inSkinClusterWeight,
meshDeformer_doBlendshape(_drawcallInfo.y), gl_VertexID); meshDeformer_doBlendshape(_drawCallInfo.y), gl_VertexID);
// pass along the color // pass along the color
_color.rgb = color_sRGBToLinear(inColor.rgb); _color.rgb = color_sRGBToLinear(inColor.rgb);

View file

@ -21,7 +21,7 @@
<@include MeshDeformer.slh@> <@include MeshDeformer.slh@>
<$declareMeshDeformer(1, 1, 1, 1, 1)$> <$declareMeshDeformer(1, 1, 1, 1, 1)$>
<$declareMeshDeformerActivation(1, 1, 1)$> <$declareMeshDeformerActivation(1, 1)$>
<@include render-utils/ShaderConstants.h@> <@include render-utils/ShaderConstants.h@>
@ -37,8 +37,8 @@ void main(void) {
vec3 deformedNormal = vec3(0.0, 0.0, 0.0); vec3 deformedNormal = vec3(0.0, 0.0, 0.0);
vec3 deformedTangent = vec3(0.0, 0.0, 0.0); vec3 deformedTangent = vec3(0.0, 0.0, 0.0);
evalMeshDeformer(inPosition, deformedPosition, inNormal.xyz, deformedNormal, inTangent.xyz, deformedTangent, evalMeshDeformer(inPosition, deformedPosition, inNormal.xyz, deformedNormal, inTangent.xyz, deformedTangent,
meshDeformer_doSkinning(_drawcallInfo.y), inSkinClusterIndex, inSkinClusterWeight, meshDeformer_doSkinning(_drawCallInfo.y), inSkinClusterIndex, inSkinClusterWeight,
meshDeformer_doBlendshape(_drawcallInfo.y), gl_VertexID); meshDeformer_doBlendshape(_drawCallInfo.y), gl_VertexID);
// pass along the color // pass along the color
_color.rgb = color_sRGBToLinear(inColor.rgb); _color.rgb = color_sRGBToLinear(inColor.rgb);

View file

@ -16,15 +16,15 @@
<@include MeshDeformer.slh@> <@include MeshDeformer.slh@>
<$declareMeshDeformer(_SCRIBE_NULL, _SCRIBE_NULL, 1, _SCRIBE_NULL, 1)$> <$declareMeshDeformer(_SCRIBE_NULL, _SCRIBE_NULL, 1, _SCRIBE_NULL, 1)$>
<$declareMeshDeformerActivation(1, 1, 1)$> <$declareMeshDeformerActivation(1, 1)$>
<@include render-utils/ShaderConstants.h@> <@include render-utils/ShaderConstants.h@>
void main(void) { void main(void) {
vec4 deformedPosition = vec4(0.0, 0.0, 0.0, 0.0); vec4 deformedPosition = vec4(0.0, 0.0, 0.0, 0.0);
evalMeshDeformer(inPosition, deformedPosition, evalMeshDeformer(inPosition, deformedPosition,
meshDeformer_doSkinning(_drawcallInfo.y), inSkinClusterIndex, inSkinClusterWeight, meshDeformer_doSkinning(_drawCallInfo.y), inSkinClusterIndex, inSkinClusterWeight,
meshDeformer_doBlendshape(_drawcallInfo.y), gl_VertexID); meshDeformer_doBlendshape(_drawCallInfo.y), gl_VertexID);
// standard transform // standard transform
TransformCamera cam = getTransformCamera(); TransformCamera cam = getTransformCamera();

View file

@ -16,15 +16,15 @@
<@include MeshDeformer.slh@> <@include MeshDeformer.slh@>
<$declareMeshDeformer(_SCRIBE_NULL, _SCRIBE_NULL, 1, 1, 1)$> <$declareMeshDeformer(_SCRIBE_NULL, _SCRIBE_NULL, 1, 1, 1)$>
<$declareMeshDeformerActivation(1, 1, 1)$> <$declareMeshDeformerActivation(1, 1)$>
<@include render-utils/ShaderConstants.h@> <@include render-utils/ShaderConstants.h@>
void main(void) { void main(void) {
vec4 deformedPosition = vec4(0.0, 0.0, 0.0, 0.0); vec4 deformedPosition = vec4(0.0, 0.0, 0.0, 0.0);
evalMeshDeformer(inPosition, deformedPosition, evalMeshDeformer(inPosition, deformedPosition,
meshDeformer_doSkinning(_drawcallInfo.y), inSkinClusterIndex, inSkinClusterWeight, meshDeformer_doSkinning(_drawCallInfo.y), inSkinClusterIndex, inSkinClusterWeight,
meshDeformer_doBlendshape(_drawcallInfo.y), gl_VertexID); meshDeformer_doBlendshape(_drawCallInfo.y), gl_VertexID);
// standard transform // standard transform
TransformCamera cam = getTransformCamera(); TransformCamera cam = getTransformCamera();

View file

@ -19,7 +19,7 @@
<@include MeshDeformer.slh@> <@include MeshDeformer.slh@>
<$declareMeshDeformer(_SCRIBE_NULL, _SCRIBE_NULL, 1, _SCRIBE_NULL, 1)$> <$declareMeshDeformer(_SCRIBE_NULL, _SCRIBE_NULL, 1, _SCRIBE_NULL, 1)$>
<$declareMeshDeformerActivation(1, 1, 1)$> <$declareMeshDeformerActivation(1, 1)$>
<@include render-utils/ShaderConstants.h@> <@include render-utils/ShaderConstants.h@>
@ -28,8 +28,8 @@ layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _positionWS;
void main(void) { void main(void) {
vec4 deformedPosition = vec4(0.0, 0.0, 0.0, 0.0); vec4 deformedPosition = vec4(0.0, 0.0, 0.0, 0.0);
evalMeshDeformer(inPosition, deformedPosition, evalMeshDeformer(inPosition, deformedPosition,
meshDeformer_doSkinning(_drawcallInfo.y), inSkinClusterIndex, inSkinClusterWeight, meshDeformer_doSkinning(_drawCallInfo.y), inSkinClusterIndex, inSkinClusterWeight,
meshDeformer_doBlendshape(_drawcallInfo.y), gl_VertexID); meshDeformer_doBlendshape(_drawCallInfo.y), gl_VertexID);
// standard transform // standard transform
TransformCamera cam = getTransformCamera(); TransformCamera cam = getTransformCamera();

View file

@ -19,7 +19,7 @@
<@include MeshDeformer.slh@> <@include MeshDeformer.slh@>
<$declareMeshDeformer(_SCRIBE_NULL, _SCRIBE_NULL, 1, 1, 1)$> <$declareMeshDeformer(_SCRIBE_NULL, _SCRIBE_NULL, 1, 1, 1)$>
<$declareMeshDeformerActivation(1, 1, 1)$> <$declareMeshDeformerActivation(1, 1)$>
<@include render-utils/ShaderConstants.h@> <@include render-utils/ShaderConstants.h@>
@ -28,8 +28,8 @@ layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _positionWS;
void main(void) { void main(void) {
vec4 deformedPosition = vec4(0.0, 0.0, 0.0, 0.0); vec4 deformedPosition = vec4(0.0, 0.0, 0.0, 0.0);
evalMeshDeformer(inPosition, deformedPosition, evalMeshDeformer(inPosition, deformedPosition,
meshDeformer_doSkinning(_drawcallInfo.y), inSkinClusterIndex, inSkinClusterWeight, meshDeformer_doSkinning(_drawCallInfo.y), inSkinClusterIndex, inSkinClusterWeight,
meshDeformer_doBlendshape(_drawcallInfo.y), gl_VertexID); meshDeformer_doBlendshape(_drawCallInfo.y), gl_VertexID);
// standard transform // standard transform
TransformCamera cam = getTransformCamera(); TransformCamera cam = getTransformCamera();

View file

@ -121,7 +121,9 @@ namespace render {
uint32_t _globalShapeKey{ 0 }; uint32_t _globalShapeKey{ 0 };
uint32_t _itemShapeKey{ 0 }; uint32_t _itemShapeKey{ 0 };
bool _enableTexturing { true }; bool _enableTexturing{ true };
bool _enableBlendshape{ true };
bool _enableSkinning{ true };
bool _enableFade{ false }; bool _enableFade{ false };