33 lines
1 KiB
GLSL
33 lines
1 KiB
GLSL
// Proxy shader for canvas textures
|
|
|
|
#define STRAIGHT_UVS ((CanvasFlags&0x01) != 0)
|
|
#define DONT_FIX_ALPHA ((CanvasFlags&0x02) != 0)
|
|
#define ALPHA_KEY ((CanvasFlags&0x04) != 0)
|
|
#define NO_FULLBRIGHT ((CanvasFlags&0x08) != 0)
|
|
|
|
void SetupMaterial( inout Material mat )
|
|
{
|
|
// canvas textures are upside-down when used by models
|
|
// this is the default use-case here, so for other situations,
|
|
// there's a macro for it™
|
|
if ( STRAIGHT_UVS )
|
|
mat.Base = texture(scrtex,vTexCoord.st);
|
|
else
|
|
mat.Base = texture(scrtex,vec2(vTexCoord.s,1.-vTexCoord.t));
|
|
// drawing with render styles applied can alter the alpha of the
|
|
// canvas itself, which may not be intended, so cap it to 100% here
|
|
// unless explicitly disabled
|
|
if ( !DONT_FIX_ALPHA )
|
|
mat.Base.a = 1.;
|
|
// treat pure black as fully transparent
|
|
// used by some special textures
|
|
if ( ALPHA_KEY )
|
|
{
|
|
if ( mat.Base.rgb == vec3(0.) )
|
|
mat.Base.a = 0.;
|
|
}
|
|
mat.Normal = ApplyNormalMap(vTexCoord.st);
|
|
// by default, canvas textures are treated as fullbright
|
|
if ( !NO_FULLBRIGHT )
|
|
mat.Bright = vec4(1.);
|
|
}
|