51 {
53 args.fVaryingHandler->addVarying(
"atlasCoord", &atlasCoord);
54
55 const char* atlasAdjustName;
56 *atlasAdjustUniformHandle =
args.fUniformHandler->addUniform(
58
59 args.fVertBuilder->codeAppendf(
60
61
62 "float2 atlasTopLeft = float2(abs(locations.x) - 1, locations.y);"
63 "float2 devTopLeft = locations.zw;"
64 "bool transposed = locations.x < 0;"
65 "float2 atlasCoord = %s - devTopLeft;"
66 "if (transposed) {"
67 "atlasCoord = atlasCoord.yx;"
68 "}"
69 "atlasCoord += atlasTopLeft;"
70 "%s = atlasCoord * %s;", devCoord.
c_str(), atlasCoord.vsOut(), atlasAdjustName);
71
74 args.fVaryingHandler->addVarying(
"atlasbounds", &atlasBounds,
76 args.fVertBuilder->codeAppendf(R
"(
77 float4 atlasBounds = atlasTopLeft.xyxy + (transposed ? sizeInAtlas.00yx
78 : sizeInAtlas.00xy);
79 %s = atlasBounds * %s.xyxy;)", atlasBounds.vsOut(), atlasAdjustName);
80
81 args.fFragBuilder->codeAppendf(
82 "half atlasCoverage = 0;"
83 "float2 atlasCoord = %s;"
84 "float4 atlasBounds = %s;"
85 "if (all(greaterThan(atlasCoord, atlasBounds.xy)) &&"
86 "all(lessThan(atlasCoord, atlasBounds.zw))) {"
87 "atlasCoverage = ", atlasCoord.fsIn(), atlasBounds.fsIn());
88 args.fFragBuilder->appendTextureLookup(
args.fTexSamplers[0],
"atlasCoord");
89 args.fFragBuilder->codeAppendf(R
"(.a;
90 })");
91 } else {
92 args.fFragBuilder->codeAppendf(
"half atlasCoverage = ");
93 args.fFragBuilder->appendTextureLookup(
args.fTexSamplers[0], atlasCoord.fsIn());
94 args.fFragBuilder->codeAppendf(
".a;");
95 }
96
98 args.fFragBuilder->codeAppendf(
"%s *= (1 - atlasCoverage);",
args.fOutputCoverage);
99 } else {
100 args.fFragBuilder->codeAppendf(
"%s *= atlasCoverage;",
args.fOutputCoverage);
101 }
102}
const char * c_str() const
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args