Skip to content

Commit

Permalink
Merge pull request #367 from howetuft/hotfix
Browse files Browse the repository at this point in the history
Hotfix: adapt Cycles Principled parameters to code evolution (4.0.0) and scale Luxcore sheen
  • Loading branch information
howetuft authored Mar 5, 2024
2 parents 04c1b21 + 3a65f25 commit 6dda4fc
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 19 deletions.
81 changes: 65 additions & 16 deletions Render/renderers/Cycles.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,22 +544,48 @@ def _write_material_glass(name, matval, connect_to="output surface"):

def _write_material_disney(name, matval, connect_to="output surface"):
"""Compute a string in the renderer SDL for a Disney material."""
# For ascending compatibility reasons, we kept sheen, clearcoat
# and clearcoat_roughness
sheentint = matval["sheentint"]
return f"""
<principled_bsdf
name="{name}_bsdf"
base_color = "{matval["basecolor"]}"
subsurface = "{matval["subsurface"]}"
subsurface_weight = "{matval["subsurface"]}"
metallic = "{matval["metallic"]}"
specular = "{matval["specular"]}"
ior = "1.4"
specular_ior_level = "{matval["specular"]}"
specular_tint = "{matval["speculartint"]}"
roughness = "{matval["roughness"]}"
anisotropic = "{matval["anisotropic"]}"
sheen = "{matval["sheen"]}"
sheen_tint = "{matval["sheentint"]}"
clearcoat = "{matval["clearcoat"]}"
clearcoat_roughness = "{1 - float(matval["clearcoatgloss"])}"
sheen_weight = "{matval["sheen"]}"
sheen_tint = "{sheentint}"
coat_weight = "{matval["clearcoat"]}"
/>
<math
name="{name}_clearcoatgloss_invert"
math_type="subtract"
value1="1.0"
value2="{matval["clearcoatgloss"]}"
/>
<connect
from="{name}_clearcoatgloss_invert value"
to="{name}_bsdf clearcoat_roughness"
/>
<connect
from="{name}_clearcoatgloss_invert value"
to="{name}_bsdf coat_roughness"
/>
<mix
name="{name}_sheentint"
mix_type="mix"
color1="1.0 1.0 1.0"
color2="{matval["basecolor"]}"
fac="{matval["sheentint"]}"
/>
<connect
from="{name}_sheentint color"
to="{name}_bsdf sheen_tint"
/>
<connect from="{name}_bsdf bsdf" to="{connect_to}"/>"""

Expand Down Expand Up @@ -773,21 +799,44 @@ def _write_texture(**kwargs):
/>
<connect from="{texname} color" to="output displacement"/>"""

elif propname == "clearcoatgloss":
elif propname == "subsurface":
colorspace = "__builtin_raw"
connect = f"""
<math
name="{texname}_clearcoat_roughness"
math_type="subtract"
value1="1.0"
/>
<connect
from="{texname} color"
to="{texname}_clearcoat_roughness value2"
/>
to="{objname}_bsdf subsurface_weight"
/>"""

elif propname == "sheen":
colorspace = "__builtin_raw"
connect = f"""
<connect
from="{texname}_clearcoat_roughness value"
to="{objname}_bsdf clearcoat_roughness"
from="{texname} color"
to="{objname}_bsdf sheen_weight"
/>"""

elif propname == "sheentint":
colorspace = "__builtin_raw"
connect = f"""
<connect
from="{texname} color"
to="{objname}_sheentint fac"
/>"""

elif propname == "clearcoat":
colorspace = "__builtin_raw"
connect = f"""
<connect
from="{texname} color"
to="{objname}_bsdf coat_weight"
/>"""

elif propname == "clearcoatgloss":
colorspace = "__builtin_raw"
connect = f"""
<connect
from="{texname} color"
to="{objname}_clearcoatgloss_roughness value2"
/>"""

else:
Expand Down
5 changes: 4 additions & 1 deletion Render/renderers/Luxcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,10 +358,13 @@ def _write_material_disney(name, matval):
scene.materials.{name}.speculartint = {matval["speculartint"]}
scene.materials.{name}.roughness = {matval["roughness"]}
scene.materials.{name}.anisotropic = {matval["anisotropic"]}
scene.materials.{name}.sheen = {matval["sheen"]}
scene.materials.{name}.sheen = {name}_sheenscale
scene.materials.{name}.sheentint = {matval["sheentint"]}
scene.materials.{name}.clearcoat = {matval["clearcoat"]}
scene.materials.{name}.clearcoatgloss = {matval["clearcoatgloss"]}
scene.textures.{name}_sheenscale.type = "scale"
scene.textures.{name}_sheenscale.texture1 = {matval["sheen"]}
scene.textures.{name}_sheenscale.texture2 = 100
"""


Expand Down
4 changes: 2 additions & 2 deletions docs/EngineInstall.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,15 +322,15 @@ ready-to-use binaries for many platforms, along with excellent rendering feature
This is not done at installation but "on-the-fly" at first execution. However, this compilation
takes a few minutes.


In practical terms, at first rendering, LuxCore seems to hang with the following message:
`"[PathOCL kernel] Compiling kernels"`.

BE PATIENT, DO NOT INTERRUPT RENDERING AT THIS STAGE.

The compilation will eventually reach completion after a few minutes.
And for subsequent renderings, the compiled kernels will be cached and reused, without recompilation.

</details>

### Bugs & Errors
Expand Down

0 comments on commit 6dda4fc

Please sign in to comment.