Files
filament/samples/materials/arrayTexture.mat
Sungun Park 37c615e249 Support multi-layered render target (#8108)
Clients can create a multi-layered render target that consists of array
textures, and use it as a custom render target.

A new sample app "hellostereo" demonstrates how to use this feature.
2024-09-09 20:27:58 +00:00

40 lines
965 B
Plaintext

material {
name : ArrayTexture,
parameters : [
{
type : sampler2dArray,
name : image
},
{
type : int,
name : layerIndex
},
{
type : bool,
name : borderEffect
}
],
requires : [
uv0
],
shadingModel : unlit,
culling : none
}
fragment {
void material(inout MaterialInputs material) {
prepareMaterial(material);
float3 v = texture(materialParams_image, vec3(getUV0(), materialParams.layerIndex)).rgb;
material.baseColor.rgb = v;
// Add black border effect.
if (materialParams.borderEffect) {
vec2 st = getUV0();
float minDist0 = min(st.x, st.y);
float minDist1 = min(1.0 - st.x, 1.0 - st.y);
float minDist = min(minDist0, minDist1);
material.baseColor.rgb *= smoothstep(0.0, 0.1, minDist);
}
}
}