Restore panoramic skybox path for skybox integration
This commit is contained in:
@@ -16,10 +16,17 @@ struct BuiltinForwardMaterialData {
|
||||
Math::Vector4 baseColorFactor = Math::Vector4::One();
|
||||
};
|
||||
|
||||
enum class BuiltinSkyboxTextureMode : Core::uint8 {
|
||||
None = 0,
|
||||
Panoramic = 1,
|
||||
Cubemap = 2
|
||||
};
|
||||
|
||||
struct BuiltinSkyboxMaterialData {
|
||||
Math::Vector4 tint = Math::Vector4::One();
|
||||
float exposure = 1.0f;
|
||||
float rotationDegrees = 0.0f;
|
||||
BuiltinSkyboxTextureMode textureMode = BuiltinSkyboxTextureMode::None;
|
||||
};
|
||||
|
||||
struct MaterialConstantLayoutView {
|
||||
@@ -140,7 +147,64 @@ inline BuiltinForwardMaterialData BuildBuiltinForwardMaterialData(const Resource
|
||||
return data;
|
||||
}
|
||||
|
||||
inline const Resources::Texture* ResolveSkyboxTexture(const Resources::Material* material) {
|
||||
inline bool IsCubemapSkyboxTextureType(Resources::TextureType type) {
|
||||
return type == Resources::TextureType::TextureCube ||
|
||||
type == Resources::TextureType::TextureCubeArray;
|
||||
}
|
||||
|
||||
inline bool IsPanoramicSkyboxTextureType(Resources::TextureType type) {
|
||||
return type == Resources::TextureType::Texture2D ||
|
||||
type == Resources::TextureType::Texture2DArray;
|
||||
}
|
||||
|
||||
inline const Resources::Texture* ResolveSkyboxPanoramicTexture(const Resources::Material* material) {
|
||||
if (material == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (const Resources::ShaderPropertyDesc* property = FindShaderPropertyBySemantic(material, "SkyboxPanoramicTexture")) {
|
||||
const Resources::ResourceHandle<Resources::Texture> textureHandle = material->GetTexture(property->name);
|
||||
if (textureHandle.Get() != nullptr &&
|
||||
textureHandle->IsValid() &&
|
||||
IsPanoramicSkyboxTextureType(textureHandle->GetTextureType())) {
|
||||
return textureHandle.Get();
|
||||
}
|
||||
}
|
||||
|
||||
if (const Resources::ShaderPropertyDesc* property = FindShaderPropertyBySemantic(material, "SkyboxTexture")) {
|
||||
const Resources::ResourceHandle<Resources::Texture> textureHandle = material->GetTexture(property->name);
|
||||
if (textureHandle.Get() != nullptr &&
|
||||
textureHandle->IsValid() &&
|
||||
IsPanoramicSkyboxTextureType(textureHandle->GetTextureType())) {
|
||||
return textureHandle.Get();
|
||||
}
|
||||
}
|
||||
|
||||
static const char* kSkyboxTexturePropertyNames[] = {
|
||||
"_PanoramicTex",
|
||||
"_Tex",
|
||||
"_MainTex",
|
||||
"_SkyboxPanorama",
|
||||
"panoramicTexture",
|
||||
"skyboxPanorama",
|
||||
"skyboxTexture",
|
||||
"texture"
|
||||
};
|
||||
|
||||
for (const char* propertyName : kSkyboxTexturePropertyNames) {
|
||||
const Resources::ResourceHandle<Resources::Texture> textureHandle =
|
||||
material->GetTexture(Containers::String(propertyName));
|
||||
if (textureHandle.Get() != nullptr &&
|
||||
textureHandle->IsValid() &&
|
||||
IsPanoramicSkyboxTextureType(textureHandle->GetTextureType())) {
|
||||
return textureHandle.Get();
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
inline const Resources::Texture* ResolveSkyboxCubemapTexture(const Resources::Material* material) {
|
||||
if (material == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -149,15 +213,13 @@ inline const Resources::Texture* ResolveSkyboxTexture(const Resources::Material*
|
||||
const Resources::ResourceHandle<Resources::Texture> textureHandle = material->GetTexture(property->name);
|
||||
if (textureHandle.Get() != nullptr &&
|
||||
textureHandle->IsValid() &&
|
||||
(textureHandle->GetTextureType() == Resources::TextureType::TextureCube ||
|
||||
textureHandle->GetTextureType() == Resources::TextureType::TextureCubeArray)) {
|
||||
IsCubemapSkyboxTextureType(textureHandle->GetTextureType())) {
|
||||
return textureHandle.Get();
|
||||
}
|
||||
}
|
||||
|
||||
static const char* kSkyboxTexturePropertyNames[] = {
|
||||
"_Tex",
|
||||
"_MainTex",
|
||||
"_Cube",
|
||||
"_SkyboxTexture",
|
||||
"cubemap",
|
||||
@@ -171,8 +233,7 @@ inline const Resources::Texture* ResolveSkyboxTexture(const Resources::Material*
|
||||
material->GetTexture(Containers::String(propertyName));
|
||||
if (textureHandle.Get() != nullptr &&
|
||||
textureHandle->IsValid() &&
|
||||
(textureHandle->GetTextureType() == Resources::TextureType::TextureCube ||
|
||||
textureHandle->GetTextureType() == Resources::TextureType::TextureCubeArray)) {
|
||||
IsCubemapSkyboxTextureType(textureHandle->GetTextureType())) {
|
||||
return textureHandle.Get();
|
||||
}
|
||||
}
|
||||
@@ -180,6 +241,16 @@ inline const Resources::Texture* ResolveSkyboxTexture(const Resources::Material*
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
inline BuiltinSkyboxTextureMode ResolveSkyboxTextureMode(const Resources::Material* material) {
|
||||
if (ResolveSkyboxPanoramicTexture(material) != nullptr) {
|
||||
return BuiltinSkyboxTextureMode::Panoramic;
|
||||
}
|
||||
if (ResolveSkyboxCubemapTexture(material) != nullptr) {
|
||||
return BuiltinSkyboxTextureMode::Cubemap;
|
||||
}
|
||||
return BuiltinSkyboxTextureMode::None;
|
||||
}
|
||||
|
||||
inline Math::Vector4 ResolveSkyboxTint(const Resources::Material* material) {
|
||||
if (material == nullptr) {
|
||||
return Math::Vector4::One();
|
||||
@@ -268,6 +339,7 @@ inline BuiltinSkyboxMaterialData BuildBuiltinSkyboxMaterialData(const Resources:
|
||||
data.tint = ResolveSkyboxTint(material);
|
||||
data.exposure = ResolveSkyboxExposure(material);
|
||||
data.rotationDegrees = ResolveSkyboxRotationDegrees(material);
|
||||
data.textureMode = ResolveSkyboxTextureMode(material);
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
@@ -293,9 +293,11 @@ private:
|
||||
RHI::RHIPipelineState* m_skyboxPipelineState = nullptr;
|
||||
OwnedDescriptorSet m_skyboxEnvironmentSet = {};
|
||||
OwnedDescriptorSet m_skyboxMaterialSet = {};
|
||||
OwnedDescriptorSet m_skyboxTextureSet = {};
|
||||
OwnedDescriptorSet m_skyboxPanoramicTextureSet = {};
|
||||
OwnedDescriptorSet m_skyboxCubemapTextureSet = {};
|
||||
OwnedDescriptorSet m_skyboxSamplerSet = {};
|
||||
RHI::RHIResourceView* m_skyboxBoundTextureView = nullptr;
|
||||
RHI::RHIResourceView* m_skyboxBoundPanoramicTextureView = nullptr;
|
||||
RHI::RHIResourceView* m_skyboxBoundCubemapTextureView = nullptr;
|
||||
RenderPassSequence m_passSequence;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user