Skip to content

Commit fe4d1cf

Browse files
Fix transparency rendering and normal attribute decode.
1 parent 0d8e0d3 commit fe4d1cf

File tree

1 file changed

+17
-7
lines changed
  • examples_tests/41.VisibilityBuffer

1 file changed

+17
-7
lines changed

examples_tests/41.VisibilityBuffer/main.cpp

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,18 @@ layout(location = 4) flat out uint drawID; //TODO: override main
2727
2828
vec4 nbl_glsl_decodeRGB10A2_UNORM(in uint x)
2929
{
30-
const uvec3 rgbMask = uvec3(0x3ffu);
3130
const uvec4 shifted = uvec4(x,uvec3(x)>>uvec3(10,20,30));
32-
return vec4(vec3(shifted.rgb&rgbMask),shifted.a)/vec4(vec3(rgbMask),3.0);
31+
const uvec4 rgbaMask = uvec4(uvec3(0x3ffu),0x3u);
32+
return vec4(shifted&rgbaMask)/vec4(rgbaMask);
3333
}
3434
3535
vec4 nbl_glsl_decodeRGB10A2_SNORM(in uint x)
3636
{
37-
uvec4 shifted = uvec4(x,uvec3(x)>>uvec3(10,20,30));
38-
const uvec3 rgbMask = uvec3(0x3ffu);
39-
const uvec3 rgbBias = uvec3(0x200u);
40-
return max(vec4(vec3(shifted.rgb&rgbMask)-rgbBias,float(shifted.a)-2.0)/vec4(vec3(rgbBias-uvec3(1u)),1.0),vec4(-1.0));
37+
const ivec4 shifted = ivec4(x,uvec3(x)>>uvec3(10u,20u,30u));
38+
const ivec4 rgbaBias = ivec4(ivec3(0x200u),0x2u);
39+
const ivec4 halfMask = rgbaBias-ivec4(1);
40+
const ivec4 signed = (-(shifted&rgbaBias))|(shifted&halfMask);
41+
return max(vec4(signed)/vec4(halfMask),vec4(-1.0));
4142
}
4243
4344
//pos
@@ -702,7 +703,16 @@ int main()
702703
return {};
703704

704705
// sort meshbuffers by pipeline
705-
std::sort(meshBuffers.begin(),meshBuffers.end(),[](const auto& lhs, const auto& rhs){return lhs->getPipeline()<rhs->getPipeline();});
706+
std::sort(meshBuffers.begin(),meshBuffers.end(),[](const auto& lhs, const auto& rhs)
707+
{
708+
auto lPpln = lhs->getPipeline();
709+
auto rPpln = rhs->getPipeline();
710+
// render non-transparent things first
711+
if (lPpln->getBlendParams().blendParams[0].blendEnable<rPpln->getBlendParams().blendParams[0].blendEnable)
712+
return true;
713+
return lPpln<rPpln;
714+
}
715+
);
706716

707717
core::vector<MbPipelineRange> output;
708718
core::smart_refctd_ptr<ICPURenderpassIndependentPipeline> mbPipeline = nullptr;

0 commit comments

Comments
 (0)