@:directlyUsed@:src({
var albedo:Vec3;
var depth:Float;
var normal:Vec3;
var metalness:Float;
var roughness:Float;
var occlusion:Float;
var emissive:Float;
var custom1:Float;
var custom2:Float;
@param var shadowMap:Channel;
@param var shadowMapCube:SamplerCube;
@const var shadowIsCube:Bool;
@const var smode:Int;
function getColor(x:Float, y:Float):Vec3 {
var color:Vec3;
if (y < 3) {
if (x < 1) color = albedo.sqrt() else if (x < 2) color = packNormal(normal).rgb else if (x < 3) color = roughness.xxx else color = metalness.xxx;
} else {
if (x < 1) color = vec3(emissive, custom1, custom2) else if (x < 2) color = depth.xxx else if (x < 3) color = occlusion.xxx else {
var uv = vec2(x, y) - 3;
if (shadowIsCube) {
var phi = (1 - uv.x) * 3.1415 * 2;
var theta = (-uv.y + 0.5) * 3.1415;
var dir = vec3(cos(phi) * cos(theta), sin(phi) * cos(theta), sin(theta));
color = shadowMapCube.get(dir).xxx;
} else color = shadowMap.get(uv).xxx;
};
};
return color;
};
function fragment() {
var color:Vec3;
var x = input.uv.x * 4;
var y = input.uv.y * 4;
if (smode == 0) color = getColor(x, y) else color = getColor((smode - 1) % 4 + input.uv.x, int((smode - 1) / 4) * 3 + input.uv.y);
pixelColor = vec4(color, 1.);
};
})@:build(hxsl.Macros.buildShader())@:autoBuild(hxsl.Macros.buildShader())