(kd, arm, pos, nrm, view_pos, light_pos, min_roughness, BSDF)
| 134 | return torch.where(frontfacing, w, torch.zeros_like(w)) |
| 135 | |
| 136 | def bsdf_pbr(kd, arm, pos, nrm, view_pos, light_pos, min_roughness, BSDF): |
| 137 | wo = _safe_normalize(view_pos - pos) |
| 138 | wi = _safe_normalize(light_pos - pos) |
| 139 | |
| 140 | spec_str = arm[..., 0:1] # x component |
| 141 | roughness = arm[..., 1:2] # y component |
| 142 | metallic = arm[..., 2:3] # z component |
| 143 | ks = (0.04 * (1.0 - metallic) + kd * metallic) * (1 - spec_str) |
| 144 | kd = kd * (1.0 - metallic) |
| 145 | |
| 146 | if BSDF == 0: |
| 147 | diffuse = kd * bsdf_lambert(nrm, wi) |
| 148 | else: |
| 149 | diffuse = kd * bsdf_frostbite(nrm, wi, wo, roughness) |
| 150 | specular = bsdf_pbr_specular(ks, nrm, wo, wi, roughness*roughness, min_roughness=min_roughness) |
| 151 | return diffuse + specular |
no test coverage detected