Restore panoramic skybox path for skybox integration
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
// XC_BUILTIN_SKYBOX_OPENGL_PS
|
||||
#version 430
|
||||
|
||||
layout(binding = 0) uniform samplerCube uSkyboxTexture;
|
||||
layout(binding = 0) uniform sampler2D uSkyboxPanoramicTexture;
|
||||
layout(binding = 1) uniform samplerCube uSkyboxTexture;
|
||||
|
||||
layout(std140, binding = 0) uniform EnvironmentConstants {
|
||||
vec4 gSkyboxTopColor;
|
||||
@@ -47,6 +48,13 @@ vec3 RotateAroundY(vec3 viewRay) {
|
||||
viewRay.x * sinTheta + viewRay.z * cosTheta));
|
||||
}
|
||||
|
||||
vec2 ComputePanoramicUv(vec3 viewRay) {
|
||||
vec3 rotatedRay = RotateAroundY(viewRay);
|
||||
float u = fract(atan(rotatedRay.z, rotatedRay.x) * XC_INV_TWO_PI + 0.5);
|
||||
float v = acos(clamp(rotatedRay.y, -1.0, 1.0)) * XC_INV_PI;
|
||||
return vec2(u, clamp(v, 0.0, 1.0));
|
||||
}
|
||||
|
||||
void main() {
|
||||
float tanHalfFov = gCameraRightAndTanHalfFov.w;
|
||||
float aspect = gCameraUpAndAspect.w;
|
||||
@@ -57,10 +65,14 @@ void main() {
|
||||
vNdc.y * tanHalfFov * gCameraUpAndAspect.xyz);
|
||||
|
||||
vec3 color = EvaluateProceduralSkybox(viewRay);
|
||||
if (gSkyboxRotationAndMode.y > 0.5) {
|
||||
if (gSkyboxRotationAndMode.y > 1.5) {
|
||||
color = texture(uSkyboxTexture, RotateAroundY(viewRay)).rgb *
|
||||
gSkyboxTintAndExposure.rgb *
|
||||
gSkyboxTintAndExposure.w;
|
||||
} else if (gSkyboxRotationAndMode.y > 0.5) {
|
||||
color = texture(uSkyboxPanoramicTexture, ComputePanoramicUv(viewRay)).rgb *
|
||||
gSkyboxTintAndExposure.rgb *
|
||||
gSkyboxTintAndExposure.w;
|
||||
}
|
||||
|
||||
fragColor = vec4(color, 1.0);
|
||||
|
||||
@@ -15,8 +15,9 @@ layout(set = 1, binding = 0, std140) uniform MaterialConstants {
|
||||
vec4 gSkyboxRotationAndMode;
|
||||
};
|
||||
|
||||
layout(set = 2, binding = 0) uniform textureCube uSkyboxTexture;
|
||||
layout(set = 3, binding = 0) uniform sampler uLinearSampler;
|
||||
layout(set = 2, binding = 0) uniform texture2D uSkyboxPanoramicTexture;
|
||||
layout(set = 3, binding = 0) uniform textureCube uSkyboxTexture;
|
||||
layout(set = 4, binding = 0) uniform sampler uLinearSampler;
|
||||
|
||||
layout(location = 0) in vec2 vNdc;
|
||||
|
||||
@@ -48,6 +49,13 @@ vec3 RotateAroundY(vec3 viewRay) {
|
||||
viewRay.x * sinTheta + viewRay.z * cosTheta));
|
||||
}
|
||||
|
||||
vec2 ComputePanoramicUv(vec3 viewRay) {
|
||||
vec3 rotatedRay = RotateAroundY(viewRay);
|
||||
float u = fract(atan(rotatedRay.z, rotatedRay.x) * XC_INV_TWO_PI + 0.5);
|
||||
float v = acos(clamp(rotatedRay.y, -1.0, 1.0)) * XC_INV_PI;
|
||||
return vec2(u, clamp(v, 0.0, 1.0));
|
||||
}
|
||||
|
||||
void main() {
|
||||
float tanHalfFov = gCameraRightAndTanHalfFov.w;
|
||||
float aspect = gCameraUpAndAspect.w;
|
||||
@@ -58,10 +66,14 @@ void main() {
|
||||
vNdc.y * tanHalfFov * gCameraUpAndAspect.xyz);
|
||||
|
||||
vec3 color = EvaluateProceduralSkybox(viewRay);
|
||||
if (gSkyboxRotationAndMode.y > 0.5) {
|
||||
if (gSkyboxRotationAndMode.y > 1.5) {
|
||||
color = texture(samplerCube(uSkyboxTexture, uLinearSampler), RotateAroundY(viewRay)).rgb *
|
||||
gSkyboxTintAndExposure.rgb *
|
||||
gSkyboxTintAndExposure.w;
|
||||
} else if (gSkyboxRotationAndMode.y > 0.5) {
|
||||
color = texture(sampler2D(uSkyboxPanoramicTexture, uLinearSampler), ComputePanoramicUv(viewRay)).rgb *
|
||||
gSkyboxTintAndExposure.rgb *
|
||||
gSkyboxTintAndExposure.w;
|
||||
}
|
||||
|
||||
fragColor = vec4(color, 1.0);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// XC_BUILTIN_SKYBOX_D3D12_PS
|
||||
TextureCube gSkyboxTexture : register(t0);
|
||||
Texture2D gSkyboxPanoramicTexture : register(t0);
|
||||
TextureCube gSkyboxTexture : register(t1);
|
||||
SamplerState gLinearSampler : register(s0);
|
||||
|
||||
cbuffer EnvironmentConstants : register(b0) {
|
||||
@@ -47,6 +48,13 @@ float3 RotateAroundY(float3 viewRay) {
|
||||
viewRay.x * sinTheta + viewRay.z * cosTheta));
|
||||
}
|
||||
|
||||
float2 ComputePanoramicUv(float3 viewRay) {
|
||||
const float3 rotatedRay = RotateAroundY(viewRay);
|
||||
const float u = frac(atan2(rotatedRay.z, rotatedRay.x) * XC_INV_TWO_PI + 0.5f);
|
||||
const float v = acos(clamp(rotatedRay.y, -1.0f, 1.0f)) * XC_INV_PI;
|
||||
return float2(u, saturate(v));
|
||||
}
|
||||
|
||||
float4 MainPS(PSInput input) : SV_Target {
|
||||
const float tanHalfFov = gCameraRightAndTanHalfFov.w;
|
||||
const float aspect = gCameraUpAndAspect.w;
|
||||
@@ -57,10 +65,14 @@ float4 MainPS(PSInput input) : SV_Target {
|
||||
input.ndc.y * tanHalfFov * gCameraUpAndAspect.xyz);
|
||||
|
||||
float3 color = EvaluateProceduralSkybox(viewRay);
|
||||
if (gSkyboxRotationAndMode.y > 0.5f) {
|
||||
if (gSkyboxRotationAndMode.y > 1.5f) {
|
||||
color = gSkyboxTexture.Sample(gLinearSampler, RotateAroundY(viewRay)).rgb *
|
||||
gSkyboxTintAndExposure.rgb *
|
||||
gSkyboxTintAndExposure.w;
|
||||
} else if (gSkyboxRotationAndMode.y > 0.5f) {
|
||||
color = gSkyboxPanoramicTexture.Sample(gLinearSampler, ComputePanoramicUv(viewRay)).rgb *
|
||||
gSkyboxTintAndExposure.rgb *
|
||||
gSkyboxTintAndExposure.w;
|
||||
}
|
||||
|
||||
return float4(color, 1.0f);
|
||||
|
||||
@@ -5,6 +5,7 @@ Shader "Builtin Skybox"
|
||||
_Tint ("Tint", Color) = (1,1,1,1) [Semantic(Tint)]
|
||||
_Exposure ("Exposure", Float) = 1.0 [Semantic(Exposure)]
|
||||
_Rotation ("Rotation", Float) = 0.0 [Semantic(Rotation)]
|
||||
_MainTex ("Panoramic", 2D) = "white" [Semantic(SkyboxPanoramicTexture)]
|
||||
_Tex ("Cubemap (HDR)", Cube) = "white" [Semantic(SkyboxTexture)]
|
||||
}
|
||||
SubShader
|
||||
@@ -17,8 +18,9 @@ Shader "Builtin Skybox"
|
||||
{
|
||||
EnvironmentConstants (ConstantBuffer, 0, 0) [Semantic(Environment)]
|
||||
MaterialConstants (ConstantBuffer, 1, 0) [Semantic(Material)]
|
||||
SkyboxTexture (TextureCube, 2, 0) [Semantic(SkyboxTexture)]
|
||||
LinearClampSampler (Sampler, 3, 0) [Semantic(LinearClampSampler)]
|
||||
SkyboxPanoramicTexture (Texture2D, 2, 0) [Semantic(SkyboxPanoramicTexture)]
|
||||
SkyboxTexture (TextureCube, 3, 0) [Semantic(SkyboxTexture)]
|
||||
LinearClampSampler (Sampler, 4, 0) [Semantic(LinearClampSampler)]
|
||||
}
|
||||
HLSLPROGRAM
|
||||
#pragma vertex MainVS
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -369,7 +369,8 @@ bool BuiltinForwardPipeline::ExecuteForwardSkyboxPass(const RenderPassContext& p
|
||||
m_skyboxPipelineState == nullptr ||
|
||||
m_skyboxEnvironmentSet.set == nullptr ||
|
||||
m_skyboxMaterialSet.set == nullptr ||
|
||||
m_skyboxTextureSet.set == nullptr ||
|
||||
m_skyboxPanoramicTextureSet.set == nullptr ||
|
||||
m_skyboxCubemapTextureSet.set == nullptr ||
|
||||
m_skyboxSamplerSet.set == nullptr) {
|
||||
Debug::Logger::Get().Error(
|
||||
Debug::LogCategory::Rendering,
|
||||
@@ -392,14 +393,44 @@ bool BuiltinForwardPipeline::ExecuteForwardSkyboxPass(const RenderPassContext& p
|
||||
const Resources::Material* skyboxMaterial = sceneData.environment.HasMaterialSkybox()
|
||||
? sceneData.environment.materialSkybox.material
|
||||
: nullptr;
|
||||
const Resources::Texture* skyboxTexture = ResolveSkyboxTexture(skyboxMaterial);
|
||||
RHI::RHIResourceView* skyboxTextureView = ResolveTextureView(skyboxTexture);
|
||||
const bool useTexturedSkybox = sceneData.environment.HasMaterialSkybox() && skyboxTextureView != nullptr;
|
||||
if (skyboxTextureView == nullptr) {
|
||||
skyboxTextureView = m_fallbackTextureCubeView;
|
||||
}
|
||||
const Resources::Texture* panoramicSkyboxTexture = ResolveSkyboxPanoramicTexture(skyboxMaterial);
|
||||
const Resources::Texture* cubemapSkyboxTexture = ResolveSkyboxCubemapTexture(skyboxMaterial);
|
||||
RHI::RHIResourceView* panoramicSkyboxTextureView = ResolveTextureView(panoramicSkyboxTexture);
|
||||
RHI::RHIResourceView* cubemapSkyboxTextureView = ResolveTextureView(cubemapSkyboxTexture);
|
||||
|
||||
const BuiltinSkyboxMaterialData skyboxMaterialData = BuildBuiltinSkyboxMaterialData(skyboxMaterial);
|
||||
BuiltinSkyboxTextureMode activeTextureMode = BuiltinSkyboxTextureMode::None;
|
||||
switch (skyboxMaterialData.textureMode) {
|
||||
case BuiltinSkyboxTextureMode::Panoramic:
|
||||
if (panoramicSkyboxTextureView != nullptr) {
|
||||
activeTextureMode = BuiltinSkyboxTextureMode::Panoramic;
|
||||
} else if (cubemapSkyboxTextureView != nullptr) {
|
||||
activeTextureMode = BuiltinSkyboxTextureMode::Cubemap;
|
||||
}
|
||||
break;
|
||||
case BuiltinSkyboxTextureMode::Cubemap:
|
||||
if (cubemapSkyboxTextureView != nullptr) {
|
||||
activeTextureMode = BuiltinSkyboxTextureMode::Cubemap;
|
||||
} else if (panoramicSkyboxTextureView != nullptr) {
|
||||
activeTextureMode = BuiltinSkyboxTextureMode::Panoramic;
|
||||
}
|
||||
break;
|
||||
case BuiltinSkyboxTextureMode::None:
|
||||
default:
|
||||
if (panoramicSkyboxTextureView != nullptr) {
|
||||
activeTextureMode = BuiltinSkyboxTextureMode::Panoramic;
|
||||
} else if (cubemapSkyboxTextureView != nullptr) {
|
||||
activeTextureMode = BuiltinSkyboxTextureMode::Cubemap;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (panoramicSkyboxTextureView == nullptr) {
|
||||
panoramicSkyboxTextureView = m_fallbackTexture2DView;
|
||||
}
|
||||
if (cubemapSkyboxTextureView == nullptr) {
|
||||
cubemapSkyboxTextureView = m_fallbackTextureCubeView;
|
||||
}
|
||||
|
||||
SkyboxMaterialConstants materialConstants = {};
|
||||
materialConstants.tintAndExposure = Math::Vector4(
|
||||
skyboxMaterialData.tint.x,
|
||||
@@ -408,15 +439,19 @@ bool BuiltinForwardPipeline::ExecuteForwardSkyboxPass(const RenderPassContext& p
|
||||
std::max(0.0f, skyboxMaterialData.exposure));
|
||||
materialConstants.rotationRadiansAndMode = Math::Vector4(
|
||||
Math::Radians(skyboxMaterialData.rotationDegrees),
|
||||
useTexturedSkybox ? 1.0f : 0.0f,
|
||||
static_cast<float>(activeTextureMode),
|
||||
0.0f,
|
||||
0.0f);
|
||||
|
||||
m_skyboxEnvironmentSet.set->WriteConstant(0, &constants, sizeof(constants));
|
||||
m_skyboxMaterialSet.set->WriteConstant(0, &materialConstants, sizeof(materialConstants));
|
||||
if (m_skyboxBoundTextureView != skyboxTextureView) {
|
||||
m_skyboxTextureSet.set->Update(0, skyboxTextureView);
|
||||
m_skyboxBoundTextureView = skyboxTextureView;
|
||||
if (m_skyboxBoundPanoramicTextureView != panoramicSkyboxTextureView) {
|
||||
m_skyboxPanoramicTextureSet.set->Update(0, panoramicSkyboxTextureView);
|
||||
m_skyboxBoundPanoramicTextureView = panoramicSkyboxTextureView;
|
||||
}
|
||||
if (m_skyboxBoundCubemapTextureView != cubemapSkyboxTextureView) {
|
||||
m_skyboxCubemapTextureSet.set->Update(0, cubemapSkyboxTextureView);
|
||||
m_skyboxBoundCubemapTextureView = cubemapSkyboxTextureView;
|
||||
}
|
||||
|
||||
RHI::RHICommandList* commandList = context.commandList;
|
||||
@@ -425,10 +460,11 @@ bool BuiltinForwardPipeline::ExecuteForwardSkyboxPass(const RenderPassContext& p
|
||||
RHI::RHIDescriptorSet* descriptorSets[] = {
|
||||
m_skyboxEnvironmentSet.set,
|
||||
m_skyboxMaterialSet.set,
|
||||
m_skyboxTextureSet.set,
|
||||
m_skyboxPanoramicTextureSet.set,
|
||||
m_skyboxCubemapTextureSet.set,
|
||||
m_skyboxSamplerSet.set
|
||||
};
|
||||
commandList->SetGraphicsDescriptorSets(0, 4, descriptorSets, m_skyboxPipelineLayout);
|
||||
commandList->SetGraphicsDescriptorSets(0, 5, descriptorSets, m_skyboxPipelineLayout);
|
||||
commandList->Draw(3, 1, 0, 0);
|
||||
return true;
|
||||
}
|
||||
@@ -630,7 +666,8 @@ bool BuiltinForwardPipeline::EnsureSkyboxResources(const RenderContext& context)
|
||||
m_skyboxPipelineState != nullptr &&
|
||||
m_skyboxEnvironmentSet.set != nullptr &&
|
||||
m_skyboxMaterialSet.set != nullptr &&
|
||||
m_skyboxTextureSet.set != nullptr &&
|
||||
m_skyboxPanoramicTextureSet.set != nullptr &&
|
||||
m_skyboxCubemapTextureSet.set != nullptr &&
|
||||
m_skyboxSamplerSet.set != nullptr) {
|
||||
return true;
|
||||
}
|
||||
@@ -685,9 +722,13 @@ bool BuiltinForwardPipeline::CreateSkyboxResources(const RenderContext& context)
|
||||
materialLayout.bindings = &materialBinding;
|
||||
materialLayout.bindingCount = 1;
|
||||
|
||||
RHI::DescriptorSetLayoutDesc textureLayout = {};
|
||||
textureLayout.bindings = &textureBinding;
|
||||
textureLayout.bindingCount = 1;
|
||||
RHI::DescriptorSetLayoutDesc panoramicTextureLayout = {};
|
||||
panoramicTextureLayout.bindings = &textureBinding;
|
||||
panoramicTextureLayout.bindingCount = 1;
|
||||
|
||||
RHI::DescriptorSetLayoutDesc cubemapTextureLayout = {};
|
||||
cubemapTextureLayout.bindings = &textureBinding;
|
||||
cubemapTextureLayout.bindingCount = 1;
|
||||
|
||||
RHI::DescriptorSetLayoutDesc samplerLayout = {};
|
||||
samplerLayout.bindings = &samplerBinding;
|
||||
@@ -696,13 +737,14 @@ bool BuiltinForwardPipeline::CreateSkyboxResources(const RenderContext& context)
|
||||
RHI::DescriptorSetLayoutDesc setLayouts[] = {
|
||||
environmentLayout,
|
||||
materialLayout,
|
||||
textureLayout,
|
||||
panoramicTextureLayout,
|
||||
cubemapTextureLayout,
|
||||
samplerLayout
|
||||
};
|
||||
|
||||
RHI::RHIPipelineLayoutDesc pipelineLayoutDesc = {};
|
||||
pipelineLayoutDesc.setLayouts = setLayouts;
|
||||
pipelineLayoutDesc.setLayoutCount = 4;
|
||||
pipelineLayoutDesc.setLayoutCount = 5;
|
||||
m_skyboxPipelineLayout = m_device->CreatePipelineLayout(pipelineLayoutDesc);
|
||||
if (m_skyboxPipelineLayout == nullptr) {
|
||||
Debug::Logger::Get().Error(
|
||||
@@ -741,10 +783,15 @@ bool BuiltinForwardPipeline::CreateSkyboxResources(const RenderContext& context)
|
||||
false,
|
||||
m_skyboxMaterialSet) ||
|
||||
!createSkyboxDescriptorSet(
|
||||
textureLayout,
|
||||
panoramicTextureLayout,
|
||||
RHI::DescriptorHeapType::CBV_SRV_UAV,
|
||||
true,
|
||||
m_skyboxTextureSet) ||
|
||||
m_skyboxPanoramicTextureSet) ||
|
||||
!createSkyboxDescriptorSet(
|
||||
cubemapTextureLayout,
|
||||
RHI::DescriptorHeapType::CBV_SRV_UAV,
|
||||
true,
|
||||
m_skyboxCubemapTextureSet) ||
|
||||
!createSkyboxDescriptorSet(
|
||||
samplerLayout,
|
||||
RHI::DescriptorHeapType::Sampler,
|
||||
@@ -758,8 +805,10 @@ bool BuiltinForwardPipeline::CreateSkyboxResources(const RenderContext& context)
|
||||
}
|
||||
|
||||
m_skyboxSamplerSet.set->UpdateSampler(0, m_sampler);
|
||||
m_skyboxTextureSet.set->Update(0, m_fallbackTextureCubeView);
|
||||
m_skyboxBoundTextureView = m_fallbackTextureCubeView;
|
||||
m_skyboxPanoramicTextureSet.set->Update(0, m_fallbackTexture2DView);
|
||||
m_skyboxCubemapTextureSet.set->Update(0, m_fallbackTextureCubeView);
|
||||
m_skyboxBoundPanoramicTextureView = m_fallbackTexture2DView;
|
||||
m_skyboxBoundCubemapTextureView = m_fallbackTextureCubeView;
|
||||
|
||||
m_skyboxPipelineState = m_device->CreatePipelineState(
|
||||
CreateSkyboxPipelineDesc(
|
||||
@@ -786,10 +835,12 @@ void BuiltinForwardPipeline::DestroySkyboxResources() {
|
||||
}
|
||||
|
||||
DestroyOwnedDescriptorSet(m_skyboxSamplerSet);
|
||||
DestroyOwnedDescriptorSet(m_skyboxTextureSet);
|
||||
DestroyOwnedDescriptorSet(m_skyboxCubemapTextureSet);
|
||||
DestroyOwnedDescriptorSet(m_skyboxPanoramicTextureSet);
|
||||
DestroyOwnedDescriptorSet(m_skyboxMaterialSet);
|
||||
DestroyOwnedDescriptorSet(m_skyboxEnvironmentSet);
|
||||
m_skyboxBoundTextureView = nullptr;
|
||||
m_skyboxBoundPanoramicTextureView = nullptr;
|
||||
m_skyboxBoundCubemapTextureView = nullptr;
|
||||
|
||||
if (m_skyboxPipelineLayout != nullptr) {
|
||||
m_skyboxPipelineLayout->Shutdown();
|
||||
|
||||
Reference in New Issue
Block a user