diff --git a/PBR/interface/GLTF_PBR_Renderer.hpp b/PBR/interface/GLTF_PBR_Renderer.hpp index 6cc09ecd..d7bab3d8 100644 --- a/PBR/interface/GLTF_PBR_Renderer.hpp +++ b/PBR/interface/GLTF_PBR_Renderer.hpp @@ -259,7 +259,7 @@ class GLTF_PBR_Renderer : public PBR_Renderer const float3* PosBias = nullptr; const float4x4* SkinPreTransform = nullptr; // #if USE_JOINTS && USE_SKIN_PRE_TRANSFORM const float4x4* PrevSkinPreTransform = nullptr; // #if USE_JOINTS && USE_SKIN_PRE_TRANSFORM && COMPUTE_MOTION_VECTORS - const float4* BaseColorFactor = nullptr; + const float4* FallbackColor = nullptr; const void* CustomData = nullptr; size_t CustomDataSize = 0; }; diff --git a/PBR/src/GLTF_PBR_Renderer.cpp b/PBR/src/GLTF_PBR_Renderer.cpp index ad00db5c..e526255c 100644 --- a/PBR/src/GLTF_PBR_Renderer.cpp +++ b/PBR/src/GLTF_PBR_Renderer.cpp @@ -766,7 +766,7 @@ void* GLTF_PBR_Renderer::WritePBRPrimitiveShaderAttribs(void* // float4x4 PrevSkinPreTransform; // #if USE_JOINTS && USE_SKIN_PRE_TRANSFORM && COMPUTE_MOTION_VECTORS // } Transforms; // - // float4 BaseColorFactor; + // float4 FallbackColor; // UserDefined CustomData; //}; @@ -841,9 +841,9 @@ void* GLTF_PBR_Renderer::WritePBRPrimitiveShaderAttribs(void* } { - const float4& BaseColorFactor = AttribsData.BaseColorFactor != nullptr ? *AttribsData.BaseColorFactor : float4{1, 1, 1, 1}; - memcpy(pDstPtr, &BaseColorFactor, sizeof(BaseColorFactor)); - pDstPtr += sizeof(BaseColorFactor); + const float4& FallbackColor = AttribsData.FallbackColor != nullptr ? *AttribsData.FallbackColor : float4{1, 1, 1, 1}; + memcpy(pDstPtr, &FallbackColor, sizeof(FallbackColor)); + pDstPtr += sizeof(FallbackColor); } { diff --git a/PBR/src/PBR_Renderer.cpp b/PBR/src/PBR_Renderer.cpp index 67812878..6ea32501 100644 --- a/PBR/src/PBR_Renderer.cpp +++ b/PBR/src/PBR_Renderer.cpp @@ -2033,7 +2033,7 @@ Uint32 PBR_Renderer::GetPBRPrimitiveAttribsSize(PSO_FLAGS Flags, Uint32 CustomDa // float4x4 PrevSkinPreTransform; // #if USE_JOINTS && USE_SKIN_PRE_TRANSFORM && COMPUTE_MOTION_VECTORS // } Transforms; // - // float4 BaseColorFactor; + // float4 FallbackColor; // UserDefined CustomData; //}; @@ -2046,7 +2046,7 @@ Uint32 PBR_Renderer::GetPBRPrimitiveAttribsSize(PSO_FLAGS Flags, Uint32 CustomDa (UseSkinPreTransform ? sizeof(float4x4) : 0) + // Transforms.SkinPreTransform (UsePrevSkinPreTransform ? sizeof(float4x4) : 0) + // Transforms.PrevSkinPreTransform - sizeof(float4) + // BaseColorFactor + sizeof(float4) + // FallbackColor CustomDataSize); } diff --git a/Shaders/PBR/private/PBR_Textures.fxh b/Shaders/PBR/private/PBR_Textures.fxh index 7bd4b999..05f6ee3f 100644 --- a/Shaders/PBR/private/PBR_Textures.fxh +++ b/Shaders/PBR/private/PBR_Textures.fxh @@ -430,9 +430,10 @@ float4 SampleTexture(Texture2DArray Tex, float4 GetBaseColor(VSOutput VSOut, PBRMaterialShaderInfo Material, - float MipBias) + float MipBias, + float4 DefaultValue) { - float4 BaseColor = float4(1.0, 1.0, 1.0, 1.0); + float4 BaseColor = DefaultValue; # if USE_COLOR_MAP { @@ -441,7 +442,7 @@ float4 GetBaseColor(VSOutput VSOut, VSOut, Material.Textures[BaseColorTextureAttribId], MipBias, - float4(1.0, 1.0, 1.0, 1.0)); + DefaultValue); BaseColor = float4(TO_LINEAR(BaseColor.rgb), BaseColor.a); } # endif diff --git a/Shaders/PBR/private/RenderPBR.psh b/Shaders/PBR/private/RenderPBR.psh index 35866589..78374e27 100644 --- a/Shaders/PBR/private/RenderPBR.psh +++ b/Shaders/PBR/private/RenderPBR.psh @@ -378,8 +378,7 @@ float4 GetLoadingAnimationColor(float3 WorldPos, float Factor) PSOutput main(in VSOutput VSOut, in bool IsFrontFace : SV_IsFrontFace) { - float4 BaseColor = GetBaseColor(VSOut, g_Material, g_Frame.Renderer.MipBias); - BaseColor *= PRIMITIVE.BaseColorFactor; + float4 BaseColor = GetBaseColor(VSOut, g_Material, g_Frame.Renderer.MipBias, PRIMITIVE.FallbackColor); #if USE_VERTEX_NORMALS float3 MeshNormal = VSOut.Normal; diff --git a/Shaders/PBR/private/RenderPBR_Structures.fxh b/Shaders/PBR/private/RenderPBR_Structures.fxh index 1830397b..d1d5d6be 100644 --- a/Shaders/PBR/private/RenderPBR_Structures.fxh +++ b/Shaders/PBR/private/RenderPBR_Structures.fxh @@ -31,7 +31,7 @@ struct PBRPrimitiveAttribs { GLTFNodeShaderTransforms Transforms; - float4 BaseColorFactor; + float4 FallbackColor; float4 CustomData; }; #ifdef CHECK_STRUCT_ALIGNMENT