TriVoxel: Burley + (EON, Gotanda, Chan) Diffuse Models

This commit is contained in:
2026-09-08 22:02:48 -07:00
parent d44fd9993a
commit 42fdff4757
12 changed files with 241 additions and 24 deletions

View File

@ -173,6 +173,19 @@ def add_world_defs():
wrd.world_defs += '_Brdf'
assets.add_khafile_def("lnx_brdf")
if rpdat.lnx_diffuse_model == 'Burley':
wrd.world_defs += '_BurleyDiffuse'
assets.add_khafile_def('lnx_burley_diffuse')
elif rpdat.lnx_diffuse_model == 'EON':
wrd.world_defs += '_EONDiffuse'
assets.add_khafile_def('lnx_eon_diffuse')
elif rpdat.lnx_diffuse_model == 'Gotanda':
wrd.world_defs += '_GotandaDiffuse'
assets.add_khafile_def('lnx_gotanda_diffuse')
elif rpdat.lnx_diffuse_model == 'Chan':
wrd.world_defs += '_ChanDiffuse'
assets.add_khafile_def('lnx_chan_diffuse')
def build():
rpdat = lnx.utils.get_rp()
project_path = lnx.utils.get_fp()

View File

@ -737,7 +737,7 @@ def make_forward_base(con_mesh, parse_opacity=False, transluc_pass=False):
if '_Rad' in wrd.world_defs:
frag.write('prefilteredColor = pow(prefilteredColor, vec3(2.2));')
frag.write('envl *= albedo;')
frag.write('envl *= diffuseIBL(albedo, roughness, f0, dotNV);')
if '_Brdf' in wrd.world_defs:
frag.write('envl.rgb *= 1.0 - F;')
@ -771,7 +771,7 @@ def make_forward_base(con_mesh, parse_opacity=False, transluc_pass=False):
if '_VoxelGI' in wrd.world_defs:
frag.write('vec4 diffuse_indirect = traceDiffuse(wposition, n, voxels, clipmaps);')
frag.write('indirect = (diffuse_indirect.rgb * albedo * (1.0 - F) + envl * (1.0 - diffuse_indirect.a)) * voxelgiDiff;')
frag.write('indirect = (diffuse_indirect.rgb * diffuseIBL(albedo, roughness, f0, dotNV) * (1.0 - F) + envl * (1.0 - diffuse_indirect.a)) * voxelgiDiff;')
frag.write('if (roughness < 1.0 && specular > 0.0) {')
frag.write(' indirect += traceSpecular(wposition, n, voxels, voxelsSDF, vVec, roughness * roughness, clipmaps, gl_FragCoord.xy, velocity).rgb * F * voxelgiRefl;')
frag.write('}')
@ -847,7 +847,7 @@ def make_forward_base(con_mesh, parse_opacity=False, transluc_pass=False):
if '_ExtBRDF' in wrd.world_defs:
frag.write('float sunLayerWeight;')
frag.write('vec3 sdirect = applyExtBRDFLayers(')
frag.write(' lambertDiffuseBRDF(albedo, sdotNL) + specularBRDF(f0, roughness, sdotNL, sdotNH, dotNV, sdotVH) * specular,')
frag.write(' diffuseBRDF(albedo, roughness, f0, sdotNL, dotNV, sdotVH) + specularBRDF(f0, roughness, sdotNL, sdotNH, dotNV, sdotVH) * specular,')
frag.write(' albedo, f0, roughness, sdotNL, dotNV, sdotNH, sdotVH, n, sunDir, vVec, sh')
if '_ClearCoat' in wrd.world_defs:
frag.write(', clearcoat, clearcoatRough, coatIOR, coatTint, nCoat')
@ -858,7 +858,7 @@ def make_forward_base(con_mesh, parse_opacity=False, transluc_pass=False):
frag.write(', sunLayerWeight);')
frag.write('direct += sdirect * sunCol * svisibility;')
else:
frag.write('direct += (lambertDiffuseBRDF(albedo, sdotNL) + specularBRDF(f0, roughness, sdotNL, sdotNH, dotNV, sdotVH) * specular) * sunCol * svisibility;')
frag.write('direct += (diffuseBRDF(albedo, roughness, f0, sdotNL, dotNV, sdotVH) + specularBRDF(f0, roughness, sdotNL, sdotNH, dotNV, sdotVH) * specular) * sunCol * svisibility;')
# sun
if '_SinglePoint' in wrd.world_defs:
@ -880,7 +880,8 @@ def make_forward_base(con_mesh, parse_opacity=False, transluc_pass=False):
else:
frag.add_uniform('vec2 lightProj', link='_lightPlaneProj', included=True)
frag.add_uniform('samplerCubeShadow shadowMapPoint[1]', included=True)
frag.add_uniform('samplerCube shadowMapPointTransparent[1]', included=True)
if is_transparent_shadows:
frag.add_uniform('samplerCube shadowMapPointTransparent[1]', included=True)
frag.write('direct += sampleLight(')
frag.write(' wposition, n, vVec, dotNV, pointPos, pointCol, albedo, roughness, specular, f0')
if is_shadows:

View File

@ -411,7 +411,8 @@ def make_gi(context_id):
frag.add_uniform('vec4 pointLightDataArray[maxLightsCluster]', link='_pointLightsAtlasArray', included=True)
else:
frag.add_uniform('samplerCubeShadow shadowMapPoint[4]', included=True)
frag.add_uniform('samplerCube shadowMapPointTransparent[4]', included=True)
if is_transparent_shadows:
frag.add_uniform('samplerCube shadowMapPointTransparent[4]', included=True)
vert.add_out('vec4 wvppositionGeom')
vert.add_uniform('mat4 VP', '_viewProjectionMatrix')

View File

@ -486,6 +486,14 @@ class LnxRPListItem(bpy.types.PropertyGroup):
('Solid', 'Solid', 'Solid'),
],
name="Materials", description="Material builder", default='Full', update=update_material_model)
lnx_diffuse_model: EnumProperty(
items=[('Lambert', 'Lambert', 'Lambert'),
('Burley', 'Burley', 'Burley with Frostbite energy renormalization'),
('EON', 'Oren-Nayar', 'Energy preserving Oren Nayar with multi scatter compensation'),
('Gotanda', 'Gotanda GGX Diffuse', 'Microfacet GGX diffuse with Fresnel and visibility'),
('Chan', 'Chan Retroreflective', 'GGX microfacet diffuse with retroreflective lobe'),
],
name="Diffuse BRDF", description="Diffuse BRDF model", default='Burley', update=update_material_model)
lnx_rp_displacement: EnumProperty(
items=[('Off', 'Off', 'Off'),
('Vertex', 'Vertex', 'Vertex'),

View File

@ -1696,6 +1696,7 @@ class LNX_PT_RenderPathRendererPanel(bpy.types.Panel):
if rpdat.rp_renderer == 'Forward':
layout.prop(rpdat, 'rp_depthprepass')
layout.prop(rpdat, 'lnx_material_model')
layout.prop(rpdat, 'lnx_diffuse_model')
layout.prop(rpdat, 'rp_translucency_state')
layout.prop(rpdat, 'rp_overlays_state')
layout.prop(rpdat, 'rp_decals_state')