MCPcopy Create free account
hub / github.com/3DAnimals/3DAnimals / bsdf_pbr

Function bsdf_pbr

model/render/renderutils/bsdf.py:136–151  ·  view source on GitHub ↗
(kd, arm, pos, nrm, view_pos, light_pos, min_roughness, BSDF)

Source from the content-addressed store, hash-verified

134 return torch.where(frontfacing, w, torch.zeros_like(w))
135
136def 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

Callers 1

pbr_bsdfFunction · 0.85

Calls 4

_safe_normalizeFunction · 0.85
bsdf_lambertFunction · 0.85
bsdf_frostbiteFunction · 0.85
bsdf_pbr_specularFunction · 0.85

Tested by

no test coverage detected