@:directlyUsed@:src({
@:import h3d.shader.pbr.BDRF;
var pbrLightDirection:Vec3;
var pbrSpecularLightDirection:Vec3;
var pbrLightColor:Vec3;
var pbrOcclusionFactor:Float;
@const var doDiscard:Bool = true;
function __init__fragment2() {
pbrSpecularLightDirection = pbrLightDirection;
};
function fragment() {
var NdL = normal.dot(pbrLightDirection).max(0.);
if (pbrLightColor.dot(pbrLightColor) > 0.0001 && NdL > 0) {
var half = (pbrSpecularLightDirection + view).normalize();
var NdH = normal.dot(half).max(0.);
var VdH = view.dot(half).max(0.);
var F0 = pbrSpecularColor;
var diffuse = albedo / PI;
var D = normalDistributionGGX(NdH, roughness);
var F = fresnelSchlick(VdH, F0);
var G = geometrySchlickGGX(NdV, NdL, roughness);
var specular = (D * F * G).max(0.);
var direct = (diffuse * (1 - metalness) * (1 - F) + specular) * pbrLightColor * NdL;
pixelColor.rgb += direct * shadow * mix(1, occlusion, pbrOcclusionFactor);
} else if (doDiscard) discard;
};
})@:build(hxsl.Macros.buildShader())@:autoBuild(hxsl.Macros.buildShader())