Skip to content

Commit

Permalink
bugfix: fix update problem with material descriptor set
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Pollind <[email protected]>
  • Loading branch information
pollend committed Jan 9, 2024
1 parent e10811f commit ebdf3cd
Show file tree
Hide file tree
Showing 16 changed files with 287 additions and 292 deletions.
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
4 changes: 2 additions & 2 deletions HPL2/include/graphics/SceneResource.h
Original file line number Diff line number Diff line change
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
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);
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
6 changes: 3 additions & 3 deletions HPL2/resource/scene_defs.h.fsl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#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_REFLECTION_COUNT 4
#define SCENE_MAX_TEXTURE_COUNT 10000
#define SCENE_MAX_TEXTURE_CUBE_COUNT 5000

Expand All @@ -28,7 +28,7 @@ STRUCT(TranslucentMaterial) {
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
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
21 changes: 11 additions & 10 deletions HPL2/resource/visibilityBuffer_alpha_pass.frag.fsl
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,25 @@ float4 PS_MAIN(PsIn In, SV_PrimitiveID(uint) primitiveID)
}


float4 value;
if(SampleSceneTextureFloat4(material.alphaTextureIndex,Get(sceneSampler), texCoord, 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);
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(obj.dissolveAmount < 1.0 || isTextureIndexValid(material.alphaTextureIndex) || (material.config & MATERIAL_USE_ALPHA_DISSOLVE_FILTER) > 0) {
const float2 dissolveCoord = In.Position.xy * (1.0/128.0); //128 = size of dissolve texture.
float fDissolve = SampleTex2D(Get(dissolveTexture), Get(nearPointWrapSampler), dissolveCoord).x;

float4 alphaValue;
if(SampleSceneTextureFloat4(material.dissolveAlphaTextureIndex, Get(sceneSampler), texCoord, alphaValue)) {
const uint dissolveAlphaTextureIndex = material.dissolveAlphaTextureIndex;
if(isTextureIndexValid(dissolveAlphaTextureIndex)) {
float fDissolveAlpha = 0.0f;
//Get in 0.75 - 1 range
fDissolve = fDissolve * 0.25 + 0.75;
float fDissolveAlpha = ((material.config & MATERIAL_IS_ALPHA_SINGLE_CHANNEL) > 0) ? alphaValue.r : alphaValue.a;
BeginNonUniformResourceIndex(dissolveAlphaTextureIndex);
fDissolveAlpha = ((material.config & MATERIAL_IS_ALPHA_SINGLE_CHANNEL) > 0) ? SampleTex2D(Get(sceneTextures)[dissolveAlphaTextureIndex], Get(sceneSampler), texCoord).r : SampleTex2D(Get(sceneTextures)[dissolveAlphaTextureIndex], Get(sceneSampler), texCoord).a;
EndNonUniformResourceIndex();
fDissolve -= (0.25 - fDissolveAlpha * 0.25);
} else {
//Get in 0.5 - 1 range.
Expand Down
4 changes: 2 additions & 2 deletions HPL2/resource/visibility_emit_shade_pass.frag.fsl
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ float4 PS_MAIN(PsIn In)
float4 diffuseColor = float4(0,0,0,0);
float3 shadedColor = f3(0.0f);

if(isTextureIndexValid(material.diffuseTextureIndex)) {
const uint diffuseTextureIdx = material.diffuseTextureIndex;
const uint diffuseTextureIdx = material.diffuseTextureIndex;
if(isTextureIndexValid(diffuseTextureIdx)) {
BeginNonUniformResourceIndex(diffuseTextureIdx);
diffuseColor = SampleGradTex2D(Get(sceneTextures)[diffuseTextureIdx], Get(sceneSampler), texCoord, texCoordDX, texCoordDY);
EndNonUniformResourceIndex();
Expand Down
Loading

0 comments on commit ebdf3cd

Please sign in to comment.