Closed MarkMurillo closed 3 years ago
Figured it out...changed the blending mode to masked and updated the logic a bit.
material {
name : textured,
shadingModel : unlit,
blending : masked,
maskThreshold : 0.5,
parameters : [
{
type : sampler2d,
name : texture
},
{
type : float3,
name : chromaKey
}
],
requires : [
uv0
]
}
fragment {
void material(inout MaterialInputs material) {
prepareMaterial(material);
material.baseColor = texture(materialParams_texture, getUV0());
// Check for rgb thresholds.
// Check for red
if (materialParams.chromaKey.x >= -1.0f) {
if (material.baseColor.r > materialParams.chromaKey.x
&& material.baseColor.g < materialParams.chromaKey.x
&& material.baseColor.b < materialParams.chromaKey.x) {
// Discard
material.baseColor = vec4(0.0, 0.0, 0.0, 0.0);
}
}
// Check for green
if (materialParams.chromaKey.y >= -1.0f) {
if (material.baseColor.r < materialParams.chromaKey.y
&& material.baseColor.g > materialParams.chromaKey.y
&& material.baseColor.b < materialParams.chromaKey.y) {
// Discard
material.baseColor = vec4(0.0, 0.0, 0.0, 0.0);
}
}
// Check for blue
if (materialParams.chromaKey.z >= -1.0f) {
if (material.baseColor.r < materialParams.chromaKey.z
&& material.baseColor.g < materialParams.chromaKey.z
&& material.baseColor.b > materialParams.chromaKey.z) {
// Discard
material.baseColor = vec4(0.0, 0.0, 0.0, 0.0);
}
}
}
}
I have a simple filament mat definition but can't seem to get the pixel to be transparent above a certain threshold. It has similar logic to how I'm doing it in my open GL shader but i'm pretty sure I'm calling the wrong methods...or setting the wrong configurations...
Here is my material definition: