Skip to content

Commit

Permalink
Merge pull request #117 from OSS-Cosmic/bugfix/resolve-descriptor-set…
Browse files Browse the repository at this point in the history
…-update-thrashing

bugfix: fix update problem with material descriptor set
  • Loading branch information
pollend authored Jan 10, 2024
2 parents e10811f + e660a59 commit 9ddfe8a
Show file tree
Hide file tree
Showing 20 changed files with 337 additions and 322 deletions.
7 changes: 6 additions & 1 deletion HPL2/include/graphics/BindlessDescriptorPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ namespace hpl {
void dispose(uint32_t slot);
private:

struct SlotInfo {
SharedTexture m_texture;
uint8_t m_count = 0;
};

struct RingEntry {
Action m_action;
uint32_t slot;
Expand All @@ -26,7 +31,7 @@ namespace hpl {
uint32_t m_index = 0;
IndexPool m_pool;
folly::small_vector<std::vector<RingEntry>> m_ring;
std::vector<SharedTexture> m_slot;
std::vector<SlotInfo> m_slot;
DescriptorHandler m_actionHandler;
};
} // namespace hpl
2 changes: 1 addition & 1 deletion HPL2/include/graphics/ForgeRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ namespace hpl {
Semaphore* m_renderCompleteSemaphore = nullptr;
CommandResourcePool* m_resourcePool = nullptr;
RenderTarget* m_finalRenderTarget = nullptr;

std::vector<Semaphore*> m_waitSemaphores = {};

template<typename T>
inline void pushResource(const T& ele) {
Expand Down
1 change: 1 addition & 0 deletions HPL2/include/graphics/RendererDeferred.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ namespace hpl {

SharedRootSignature m_lightClusterRootSignature;
std::array<SharedDescriptorSet, ForgeRenderer::SwapChainLength> m_lightDescriptorPerFrameSet;
SharedDescriptorSet m_lightDescriptorConstSet;
SharedShader m_lightClusterShader;
SharedShader m_clearLightClusterShader;
SharedPipeline m_lightClusterPipeline;
Expand Down
8 changes: 4 additions & 4 deletions HPL2/include/graphics/SceneResource.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ namespace hpl::resource {
static constexpr uint32_t MaterailSamplerNonAntistropyCount = static_cast<uint32_t>(eTextureWrap_LastEnum) * static_cast<uint32_t>(eTextureFilter_LastEnum);
uint32_t textureFilterNonAnistropyIdx(eTextureWrap wrap, eTextureFilter filter);

static constexpr uint32_t MaxScene2DTextureCount = 10000;
static constexpr uint32_t MaxSceneCubeTextureCount = 5000;
static constexpr uint32_t MaxScene2DTextureCount = 4096;
static constexpr uint32_t MaxSceneCubeTextureCount = 1024;

static constexpr uint32_t MaxReflectionBuffers = 4;
static constexpr uint32_t MaxObjectUniforms = 4096;
Expand Down Expand Up @@ -147,7 +147,7 @@ namespace hpl::resource {
uint m_alphaTextureIndex;
uint m_specularTextureIndex;
uint m_heightTextureIndex;
uint m_illuminiationTextureIndex;
uint m_illuminationTextureIndex;
uint m_dissolveAlphaTextureIndex;
uint m_materialConfig;
float m_heightMapScale;
Expand All @@ -162,7 +162,7 @@ namespace hpl::resource {
uint32_t m_alphaTextureIndex;
uint32_t m_specularTextureIndex;
uint32_t m_heightTextureIndex;
uint32_t m_illuminiationTextureIndex;
uint32_t m_illuminationTextureIndex;
uint32_t m_dissolveAlphaTextureIndex;
uint32_t m_cubeMapTextureIndex;
uint32_t m_cubeMapAlphaTextureIndex;
Expand Down
7 changes: 5 additions & 2 deletions HPL2/resource/decal_shade.frag.fsl
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ float4 PS_MAIN(PsIn In, SV_PrimitiveID(uint) primitiveID)
const Decal decal = Get(decals)[Get(indirectDrawId)];
#endif

float4 diffuseColor;
SampleSceneTextureFloat4(decal.diffuseTextureIndex, Get(sceneSampler), In.uv, diffuseColor);
float4 diffuseColor = float4(0,0,0,0);
const uint diffuseTextureIndex = decal.diffuseTextureIndex;
BeginNonUniformResourceIndex(diffuseTextureIndex);
diffuseColor = SampleTex2D(Get(sceneTextures)[diffuseTextureIndex], Get(sceneSampler), In.uv);
EndNonUniformResourceIndex();
if(diffuseColor.w < 0.01 ) {
discard;
}
Expand Down
1 change: 0 additions & 1 deletion HPL2/resource/deferred_resources.h.fsl
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ PUSH_CONSTANT(materialRootConstant, b0)
DATA(float, sceneAlpha, None);

};

// translucency
INLINE uint BlendModeTrans(uint _options) { return (_options & 0xf); }
INLINE uint ReflectionBuffer(uint _options) { return (_options >> 4) & 0x7; }
Expand Down
11 changes: 5 additions & 6 deletions HPL2/resource/depth_shade.frag.fsl
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@ float4 PS_MAIN(PsIn In, SV_PrimitiveID(uint) primitiveID)

float diffuseAlpha = 1.0;
float4 value;
if(SampleSceneTextureFloat4(material.alphaTextureIndex,Get(sceneSampler), In.uv, value)) {
if((material.config & MATERIAL_IS_ALPHA_SINGLE_CHANNEL) > 0) {
diffuseAlpha = value.r;
} else {
diffuseAlpha = value.a;
}
const uint alphaTextureIndex = material.alphaTextureIndex;
if(isTextureIndexValid(alphaTextureIndex)) {
BeginNonUniformResourceIndex(alphaTextureIndex, SCENE_MAX_TEXTURE_COUNT);
diffuseAlpha = ((material.config & MATERIAL_IS_ALPHA_SINGLE_CHANNEL) > 0) ? SampleTex2D(Get(sceneTextures)[alphaTextureIndex], Get(sceneSampler), In.uv.xy).r : SampleTex2D(Get(sceneTextures)[alphaTextureIndex], Get(sceneSampler), In.uv.xy).a;
EndNonUniformResourceIndex();
}

if(diffuseAlpha < 0.5) {
Expand Down
6 changes: 4 additions & 2 deletions HPL2/resource/particle_shade.frag.fsl
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ float4 PS_MAIN(PsIn In)
#endif

float4 finalColor = float4(0.0, 0.0 ,0.0, 1.0);
SampleSceneTextureFloat4(particle.diffuseTextureIndex, Get(sceneSampler), In.uv, finalColor);
finalColor *= In.color;
const uint diffuseTextureIndex = particle.diffuseTextureIndex;
BeginNonUniformResourceIndex(diffuseTextureIndex);
finalColor = SampleTex2D(Get(sceneTextures)[diffuseTextureIndex], Get(sceneSampler), In.uv) * In.color;
EndNonUniformResourceIndex();

float finalAlpha = particle.sceneAlpha;
if ((Get(worldInfo).worldFlags & WORLD_FLAG_IS_FOG_ENABLED) > 0) {
Expand Down
14 changes: 7 additions & 7 deletions HPL2/resource/scene_defs.h.fsl
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
#define LIGHT_CLUSTER_DATA_POS(il, ix, iy) ( LIGHT_CLUSTER_COUNT_POS(ix, iy)*LIGHT_CLUSTER_COUNT + (il) )

#define PRIMARY_VIEWPORT_INDEX 0
#define SCENE_MAX_REFLECTION_COUNT 10000
#define SCENE_MAX_TEXTURE_COUNT 10000
#define SCENE_MAX_TEXTURE_CUBE_COUNT 5000
#define SCENE_MAX_REFLECTION_COUNT 4
#define SCENE_MAX_TEXTURE_COUNT 4096
#define SCENE_MAX_TEXTURE_CUBE_COUNT 1024

STRUCT(TranslucentMaterial) {
DATA(uint, diffuseTextureIndex, None);
DATA(uint, normalTextureIndex, None);
DATA(uint, alphaTextureIndex, None);
DATA(uint, specularTextureIndex, None);
DATA(uint, heightTextureIndex, None);
DATA(uint, illuminiationTextureIndex, None);
DATA(uint, illuminationTextureIndex, None);
DATA(uint, dissolveAlphaTextureIndex, None);
DATA(uint, cubeMapTextureIndex, None);
DATA(uint, cubeMapAlphaTextureIndex, None);
Expand Down Expand Up @@ -67,7 +67,7 @@ STRUCT(DiffuseMaterial) {
DATA(uint, alphaTextureIndex, None);
DATA(uint, specularTextureIndex, None);
DATA(uint, heightTextureIndex, None);
DATA(uint, illuminiationTextureIndex, None);
DATA(uint, illuminationTextureIndex, None);
DATA(uint, dissolveAlphaTextureIndex, None);
DATA(uint, config, None);

Expand Down Expand Up @@ -96,11 +96,11 @@ STRUCT(Particle) {
DATA(float4x4, uvMat, None);
};

bool isTextureIndexValid(uint index) {
INLINE bool isTextureIndexValid(uint index) {
return index < SCENE_MAX_TEXTURE_COUNT;
}

bool isTextureCubeIndexValid(uint index) {
INLINE bool isTextureCubeIndexValid(uint index) {
return index < SCENE_MAX_TEXTURE_CUBE_COUNT;
}

Expand Down
2 changes: 1 addition & 1 deletion HPL2/resource/scene_light_cluster.comp.fsl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ void CS_MAIN(SV_GroupThreadID(uint3) threadInGroupId, SV_GroupID(uint3) groupId)
const float invClusterWidth = 1.0f / float(LIGHT_CLUSTER_WIDTH);
const float invClusterHeight = 1.0f / float(LIGHT_CLUSTER_HEIGHT);

ViewportInfo viewInfo = Get(viewports)[PRIMARY_VIEWPORT_INDEX];
ViewportInfo viewInfo = Get(viewport);
float2 screenDim = viewInfo.rect.zw;

//Near and far values of the cluster in view space
Expand Down
11 changes: 5 additions & 6 deletions HPL2/resource/scene_light_cluster_resource.h.fsl
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#include "scene_defs.h.fsl"

CBUFFER(sceneInfo, UPDATE_FREQ_PER_FRAME, b0, binding = 0) {
DATA(WorldInfo, worldInfo, None);
DATA(ViewportInfo, viewports[64], None);
CBUFFER(uniformBlock_rootcbv, UPDATE_FREQ_NONE, b2, binding = 1) {
DATA(ViewportInfo, viewport, None);
};

RES(Buffer(Light), lights, UPDATE_FREQ_PER_FRAME, t0, binding = 1);
RES(RWBuffer(atomic_uint), lightClustersCount, UPDATE_FREQ_PER_FRAME, u0, binding = 2);
RES(RWBuffer(atomic_uint), lightClusters, UPDATE_FREQ_PER_FRAME, u1, binding = 3);
RES(Buffer(Light), lights, UPDATE_FREQ_PER_FRAME, t0, binding = 2);
RES(RWBuffer(atomic_uint), lightClustersCount, UPDATE_FREQ_PER_FRAME, u0, binding = 3);
RES(RWBuffer(atomic_uint), lightClusters, UPDATE_FREQ_PER_FRAME, u1, binding = 4);

93 changes: 27 additions & 66 deletions HPL2/resource/scene_resource.h.fsl
Original file line number Diff line number Diff line change
Expand Up @@ -15,47 +15,47 @@
RES(SamplerState, nearEdgeClampSampler, UPDATE_FREQ_NONE, s0, binding = 0);
RES(SamplerState, nearPointWrapSampler, UPDATE_FREQ_NONE, s1, binding = 1);
RES(SamplerState, linearBorderSampler, UPDATE_FREQ_NONE, s2, binding = 2);
RES(SamplerComparisonState, shadowCmpSampler, UPDATE_FREQ_NONE, s3, binding = 2);
RES(SamplerState, sceneSampler, UPDATE_FREQ_NONE, s4, binding = 3);
RES(SamplerComparisonState, shadowCmpSampler, UPDATE_FREQ_NONE, s3, binding = 3);
RES(SamplerState, sceneSampler, UPDATE_FREQ_NONE, s4, binding = 4);

CBUFFER(sceneInfo, UPDATE_FREQ_PER_FRAME, b1, binding = 4) {
CBUFFER(sceneInfo, UPDATE_FREQ_PER_FRAME, b1, binding = 5) {
DATA(WorldInfo, worldInfo, None);
};

CBUFFER(uniformBlock_rootcbv, UPDATE_FREQ_NONE, b2, binding = 5) {
CBUFFER(uniformBlock_rootcbv, UPDATE_FREQ_NONE, b2, binding = 6) {
DATA(ViewportInfo, viewport, None);
};

RES(Buffer(UniformObject), sceneObjects, UPDATE_FREQ_PER_FRAME, t0, binding = 5);
RES(Buffer(Light), lights, UPDATE_FREQ_PER_FRAME, t1, binding = 6);
RES(Buffer(Particle), particles, UPDATE_FREQ_PER_FRAME, t2, binding = 7);
RES(Buffer(Decal), decals, UPDATE_FREQ_PER_FRAME, t3, binding = 8);
RES(Buffer(UniformObject), sceneObjects, UPDATE_FREQ_PER_FRAME, t0, binding = 7);
RES(Buffer(Light), lights, UPDATE_FREQ_PER_FRAME, t1, binding = 8);
RES(Buffer(Particle), particles, UPDATE_FREQ_PER_FRAME, t2, binding = 9);
RES(Buffer(Decal), decals, UPDATE_FREQ_PER_FRAME, t3, binding = 10);

// opaque geometry set
RES(ByteBuffer, vtxOpaqueIndex, UPDATE_FREQ_NONE, t4, binding = 9);
RES(ByteBuffer, vtxOpaquePosition, UPDATE_FREQ_NONE, t5, binding = 10);
RES(ByteBuffer, vtxOpaqueTangnet, UPDATE_FREQ_NONE, t6, binding = 11);
RES(ByteBuffer, vtxOpaqueNormal, UPDATE_FREQ_NONE, t7, binding = 12);
RES(ByteBuffer, vtxOpaqueUv, UPDATE_FREQ_NONE, t8, binding = 13);
RES(ByteBuffer, vtxOpaqueColor, UPDATE_FREQ_NONE, t9, binding = 14);
RES(ByteBuffer, vtxOpaqueIndex, UPDATE_FREQ_NONE, t4, binding = 11);
RES(ByteBuffer, vtxOpaquePosition, UPDATE_FREQ_NONE, t5, binding = 12);
RES(ByteBuffer, vtxOpaqueTangnet, UPDATE_FREQ_NONE, t6, binding = 13);
RES(ByteBuffer, vtxOpaqueNormal, UPDATE_FREQ_NONE, t7, binding = 14);
RES(ByteBuffer, vtxOpaqueUv, UPDATE_FREQ_NONE, t8, binding = 15);
RES(ByteBuffer, vtxOpaqueColor, UPDATE_FREQ_NONE, t9, binding = 16);

RES(Buffer(DiffuseMaterial), sceneDiffuseMat, UPDATE_FREQ_NONE, t10, binding = 15);
RES(Buffer(TranslucentMaterial), sceneTranslucentMat, UPDATE_FREQ_NONE, t11, binding = 16);
RES(Buffer(WaterMaterial), sceneWaterMat, UPDATE_FREQ_NONE, t12, binding = 17);
RES(Buffer(DiffuseMaterial), sceneDiffuseMat, UPDATE_FREQ_NONE, t10, binding = 17);
RES(Buffer(TranslucentMaterial), sceneTranslucentMat, UPDATE_FREQ_NONE, t11, binding = 18);
RES(Buffer(WaterMaterial), sceneWaterMat, UPDATE_FREQ_NONE, t12, binding = 19);

RES(Tex2D(float4), shadowTexture, UPDATE_FREQ_NONE, t13, binding = 17);
RES(Tex2D(float4), visibilityTexture, UPDATE_FREQ_PER_FRAME, t14, binding = 18);
RES(Tex2D(float4), albedoTexture, UPDATE_FREQ_PER_FRAME, t15, binding = 19);
RES(Tex2D(float4), refractionTexture, UPDATE_FREQ_PER_FRAME, t16, binding = 20);
RES(Tex2D(float4), reflectionTexture[SCENE_MAX_REFLECTION_COUNT], UPDATE_FREQ_PER_FRAME, t17, binding = 20);
RES(Tex2D(float4), shadowTexture, UPDATE_FREQ_NONE, t13, binding = 20);
RES(Tex2D(float4), visibilityTexture, UPDATE_FREQ_PER_FRAME, t14, binding = 21);
RES(Tex2D(float4), albedoTexture, UPDATE_FREQ_PER_FRAME, t15, binding = 22);
RES(Tex2D(float4), refractionTexture, UPDATE_FREQ_PER_FRAME, t16, binding = 23);
RES(Tex2D(float4), reflectionTexture[SCENE_MAX_REFLECTION_COUNT], UPDATE_FREQ_PER_FRAME, t17, binding = 24);

RES(Tex2D(float4), dissolveTexture, UPDATE_FREQ_NONE, t22, binding = 21);
RES(Tex2D(float4), dissolveTexture, UPDATE_FREQ_NONE, t22, binding = 25);

RES(ByteBuffer, lightClustersCount, UPDATE_FREQ_PER_FRAME, t23, binding = 22);
RES(ByteBuffer, lightClusters, UPDATE_FREQ_PER_FRAME, t24, binding = 23);
RES(ByteBuffer, lightClustersCount, UPDATE_FREQ_PER_FRAME, t23, binding = 26);
RES(ByteBuffer, lightClusters, UPDATE_FREQ_PER_FRAME, t24, binding = 27);

RES(Tex2D(float4), sceneTextures[SCENE_MAX_TEXTURE_COUNT], UPDATE_FREQ_PER_FRAME, t25, binding = 24);
RES(TexCube(float4), sceneCubeTextures[SCENE_MAX_TEXTURE_CUBE_COUNT], UPDATE_FREQ_PER_FRAME, t10025, binding = 25);
RES(Tex2D(float4), sceneTextures[SCENE_MAX_TEXTURE_COUNT], UPDATE_FREQ_PER_FRAME, t25, binding = 28);
RES(TexCube(float4), sceneCubeTextures[SCENE_MAX_TEXTURE_CUBE_COUNT], UPDATE_FREQ_PER_FRAME, t10025, binding = 29);

#define SCENE_OBJECT_ID_BIT 19 // 13 bits for ObjectID
#define SCENE_PRIM_ID_BIT 0 // 19 bits for PrimitiveID
Expand All @@ -71,43 +71,4 @@ RES(TexCube(float4), sceneCubeTextures[SCENE_MAX_TEXTURE_CUBE_COUNT], UPDATE_FR
#define SCENE_VIZ_OBJECT_ID(id) (((id) & SCENE_OBJECT_ID_MASK) >> SCENE_OBJECT_ID_BIT)
#define SCENE_VIZ_PRIM_ID(id) (((id) & SCENE_PRIM_ID_MASK) >> SCENE_PRIM_ID_BIT)

bool SampleSceneTextureProjFloat4(uint textureIdx, SamplerState sh, float4 projectUV, inout float4 value) {
if(textureIdx < SCENE_MAX_TEXTURE_COUNT) {
BeginNonUniformResourceIndex(textureIdx);
value = SampleTex2DProj(Get(sceneTextures)[textureIdx], sh, projectUV);
EndNonUniformResourceIndex();
return true;
}
return false;
}

INLINE bool SampleSceneCubeTextureFloat4(uint textureIdx, SamplerState sh, float3 uv, inout float4 value) {
if(textureIdx < SCENE_MAX_TEXTURE_CUBE_COUNT) {
BeginNonUniformResourceIndex(textureIdx);
value = SampleTexCube(Get(sceneCubeTextures)[textureIdx], sh, uv);
EndNonUniformResourceIndex();
return true;
}
return false;
}

INLINE bool SampleSceneTextureFloat4(uint textureIdx,SamplerState sh, float2 uv, inout float4 value) {
if(textureIdx < SCENE_MAX_TEXTURE_COUNT) {
BeginNonUniformResourceIndex(textureIdx);
value = SampleTex2D(Get(sceneTextures)[textureIdx], sh, uv);
EndNonUniformResourceIndex();
return true;
}
return false;
}
INLINE bool SampleSceneTextureGradFloat4(uint textureIdx, SamplerState sh, float2 uv, float2 texCoordDX, float2 texCoordDY, inout float4 value) {
if(textureIdx < SCENE_MAX_TEXTURE_COUNT) {
BeginNonUniformResourceIndex(textureIdx);
value = SampleGradTex2D(Get(sceneTextures)[textureIdx], sh, uv, texCoordDX, texCoordDY);
EndNonUniformResourceIndex();
return true;
}
return false;
}

#endif
32 changes: 23 additions & 9 deletions HPL2/resource/translucency_shade.frag.fsl
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ PsOut PS_MAIN(PsIn In, SV_PrimitiveID(uint) primitiveID)
float4 finalColor = float4(0.0, 0.0 ,0.0, 1.0);

#ifndef USE_ILLUMINATION
SampleSceneTextureFloat4(material.diffuseTextureIndex, Get(sceneSampler), In.uv.xy, finalColor);
finalColor *= In.Color;
const uint diffuseTextureIndex = material.diffuseTextureIndex;
BeginNonUniformResourceIndex(diffuseTextureIndex);
finalColor = SampleTex2D(Get(sceneTextures)[diffuseTextureIndex], Get(sceneSampler), In.uv.xy) * In.Color;
EndNonUniformResourceIndex();
#endif

float finalAlpha = obj.alphaAmount;
Expand Down Expand Up @@ -71,8 +73,13 @@ PsOut PS_MAIN(PsIn In, SV_PrimitiveID(uint) primitiveID)
float3 mapNormal = float3(0,0,0);
float3 screenNormal = float3(0,0,0);

float4 normalSample;
if(SampleSceneTextureFloat4(material.normalTextureIndex, Get(sceneSampler), In.uv, normalSample)) {
float4 normalSample = float4(0,0,0,0);
const uint normalTextureIndex = material.normalTextureIndex;
if(isTextureIndexValid(normalTextureIndex)) {
BeginNonUniformResourceIndex(normalTextureIndex);
normalSample = SampleTex2D(Get(sceneTextures)[normalTextureIndex], Get(sceneSampler), In.uv.xy);
EndNonUniformResourceIndex();

mapNormal = normalSample.xyz * 2.0 - 1.0;
screenNormal = normalize(mapNormal.x * In.tangent + mapNormal.y * In.bitangent + mapNormal.z * In.normal);
} else {
Expand Down Expand Up @@ -118,15 +125,22 @@ PsOut PS_MAIN(PsIn In, SV_PrimitiveID(uint) primitiveID)
viewInfo.viewMat[0].xyz,
viewInfo.viewMat[1].xyz,
viewInfo.viewMat[2].xyz)), vEnvUv);
float4 reflectionColor;
if(SampleSceneCubeTextureFloat4(material.cubeMapTextureIndex, Get(sceneSampler), vEnvUv, reflectionColor)) {
const uint cubeMapTextureIndex = material.cubeMapTextureIndex;
if(isTextureCubeIndexValid(cubeMapTextureIndex)) {
float afEDotN = max(dot(-eyeVec, screenNormal),0.0);
float fFresnel = Fresnel(afEDotN, material.frenselBias, material.frenselPos);

float4 reflectionColor = f4(0.0);
BeginNonUniformResourceIndex(cubeMapTextureIndex);
reflectionColor = SampleTexCube(Get(sceneCubeTextures)[cubeMapTextureIndex], Get(sceneSampler), vEnvUv);
EndNonUniformResourceIndex();

//Alpha for environment map
float4 specular;
if(SampleSceneTextureFloat4(material.cubeMapAlphaTextureIndex, Get(sceneSampler), In.uv.xy, specular)) {
reflectionColor *= specular.w;
const uint cubeMapAlphaTextureIndex = material.cubeMapAlphaTextureIndex;
if(isTextureIndexValid(cubeMapAlphaTextureIndex)) {
BeginNonUniformResourceIndex(cubeMapAlphaTextureIndex);
reflectionColor *= SampleTex2D(Get(sceneTextures)[cubeMapAlphaTextureIndex], Get(sceneSampler), In.uv.xy).w;
EndNonUniformResourceIndex();
}

finalColor.xyz += reflectionColor.xyz * fFresnel * finalAlpha * obj.lightLevel;
Expand Down
4 changes: 2 additions & 2 deletions HPL2/resource/translucency_water_shade.frag.fsl
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ PsOut PS_MAIN(PsIn In, SV_PrimitiveID(uint) primitiveID)
float3 vFinalNormal = normalize(vNormal1*0.7 + vNormal2*0.3);

//Get the diffuse color
const uint diffuseTextureIndex = material.normalTextureIndex;
float4 surfaceColor; //= SampleTex2D(Get(diffuseMap), Get(materialSampler), vUv1);
const uint diffuseTextureIndex = material.diffuseTextureIndex;
float4 surfaceColor = float4(0,0,0,0);
BeginNonUniformResourceIndex(diffuseTextureIndex);
surfaceColor = SampleTex2D(Get(sceneTextures)[diffuseTextureIndex], Get(sceneSampler), vUv1);
EndNonUniformResourceIndex();
Expand Down
Loading

0 comments on commit 9ddfe8a

Please sign in to comment.