Formalize forward lighting contract
This commit is contained in:
@@ -64,6 +64,9 @@ private:
|
||||
Math::Matrix4x4 view = Math::Matrix4x4::Identity();
|
||||
Math::Matrix4x4 model = Math::Matrix4x4::Identity();
|
||||
Math::Matrix4x4 normalMatrix = Math::Matrix4x4::Identity();
|
||||
};
|
||||
|
||||
struct LightingConstants {
|
||||
Math::Vector4 mainLightDirectionAndIntensity = Math::Vector4::Zero();
|
||||
Math::Vector4 mainLightColorAndFlags = Math::Vector4::Zero();
|
||||
};
|
||||
@@ -103,6 +106,7 @@ private:
|
||||
std::vector<OwnedDescriptorSet> staticDescriptorSets;
|
||||
PassResourceBindingLocation perObject = {};
|
||||
PassResourceBindingLocation material = {};
|
||||
PassResourceBindingLocation lighting = {};
|
||||
PassResourceBindingLocation shadowReceiver = {};
|
||||
PassResourceBindingLocation baseColorTexture = {};
|
||||
PassResourceBindingLocation linearClampSampler = {};
|
||||
@@ -200,6 +204,7 @@ private:
|
||||
Core::uint64 objectId,
|
||||
const Resources::Material* material,
|
||||
const MaterialConstantPayloadView& materialConstants,
|
||||
const LightingConstants& lightingConstants,
|
||||
const ShadowReceiverConstants& shadowReceiverConstants,
|
||||
RHI::RHIResourceView* baseColorTextureView,
|
||||
RHI::RHIResourceView* shadowMapTextureView);
|
||||
|
||||
@@ -37,6 +37,7 @@ enum class BuiltinPassResourceSemantic : Core::uint8 {
|
||||
Unknown = 0,
|
||||
PerObject,
|
||||
Material,
|
||||
Lighting,
|
||||
ShadowReceiver,
|
||||
BaseColorTexture,
|
||||
ShadowMapTexture,
|
||||
@@ -60,6 +61,7 @@ struct BuiltinPassResourceBindingPlan {
|
||||
bool usesSamplers = false;
|
||||
PassResourceBindingLocation perObject = {};
|
||||
PassResourceBindingLocation material = {};
|
||||
PassResourceBindingLocation lighting = {};
|
||||
PassResourceBindingLocation shadowReceiver = {};
|
||||
PassResourceBindingLocation baseColorTexture = {};
|
||||
PassResourceBindingLocation linearClampSampler = {};
|
||||
@@ -84,6 +86,7 @@ struct BuiltinPassSetLayoutMetadata {
|
||||
bool shaderVisible = false;
|
||||
bool usesPerObject = false;
|
||||
bool usesMaterial = false;
|
||||
bool usesLighting = false;
|
||||
bool usesShadowReceiver = false;
|
||||
bool usesTexture = false;
|
||||
bool usesBaseColorTexture = false;
|
||||
@@ -209,6 +212,11 @@ inline BuiltinPassResourceSemantic ResolveBuiltinPassResourceSemantic(
|
||||
return BuiltinPassResourceSemantic::Material;
|
||||
}
|
||||
|
||||
if (semantic == Containers::String("lighting") ||
|
||||
semantic == Containers::String("lightingconstants")) {
|
||||
return BuiltinPassResourceSemantic::Lighting;
|
||||
}
|
||||
|
||||
if (semantic == Containers::String("shadowreceiver") ||
|
||||
semantic == Containers::String("shadowreceiverconstants")) {
|
||||
return BuiltinPassResourceSemantic::ShadowReceiver;
|
||||
@@ -242,6 +250,7 @@ inline bool IsBuiltinPassResourceTypeCompatible(
|
||||
switch (semantic) {
|
||||
case BuiltinPassResourceSemantic::PerObject:
|
||||
case BuiltinPassResourceSemantic::Material:
|
||||
case BuiltinPassResourceSemantic::Lighting:
|
||||
case BuiltinPassResourceSemantic::ShadowReceiver:
|
||||
return type == Resources::ShaderResourceType::ConstantBuffer;
|
||||
case BuiltinPassResourceSemantic::BaseColorTexture:
|
||||
@@ -295,6 +304,9 @@ inline bool TryBuildBuiltinPassResourceBindingPlan(
|
||||
case BuiltinPassResourceSemantic::Material:
|
||||
location = &outPlan.material;
|
||||
break;
|
||||
case BuiltinPassResourceSemantic::Lighting:
|
||||
location = &outPlan.lighting;
|
||||
break;
|
||||
case BuiltinPassResourceSemantic::ShadowReceiver:
|
||||
location = &outPlan.shadowReceiver;
|
||||
break;
|
||||
@@ -488,6 +500,9 @@ inline bool TryBuildBuiltinPassSetLayouts(
|
||||
case BuiltinPassResourceSemantic::Material:
|
||||
setLayout.usesMaterial = true;
|
||||
break;
|
||||
case BuiltinPassResourceSemantic::Lighting:
|
||||
setLayout.usesLighting = true;
|
||||
break;
|
||||
case BuiltinPassResourceSemantic::ShadowReceiver:
|
||||
setLayout.usesShadowReceiver = true;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user