Files
filament/samples/materials/mirror.mat
Philip Rideout 0e27f0c162 RenderTarget demo now disables post-processing in offscreen view.
The color now match up perfectly.  Woops.

(#3402)
2021-02-05 11:21:06 -08:00

37 lines
916 B
Plaintext

material {
name : Mirror,
flipUV : true,
culling: none,
parameters : [
{
type : sampler2d,
name : albedo
}
],
requires : [
uv0
],
shadingModel : unlit,
}
fragment {
void material(inout MaterialInputs material) {
prepareMaterial(material);
if (gl_FrontFacing) {
// Make a lookup into the mirror texture.
vec2 uv = getResolution().zw * gl_FragCoord.xy;
material.baseColor.rgb = texture(materialParams_albedo, uv).rgb;
// Add black borders to the mirror.
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);
}
material.baseColor.a = 1.0;
}
}