Skip to content

Commit

Permalink
Fixed a bug where all texture signatures would be output
Browse files Browse the repository at this point in the history
  • Loading branch information
shadeops committed Aug 18, 2024
1 parent e3e2d5e commit a284c4c
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 3 deletions.
4 changes: 3 additions & 1 deletion soho/python2.7/PBRTnodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,9 @@ def get_used_parms(self):
if self.node.coshaderNodes(parm_name):
# Instead of adding checks for this multiple
# times, check once and then continue
parms[parm_name] = parm_tup
if not parm_tup.isHidden():
# If hidden, then wrong signature
parms[parm_name] = parm_tup
continue

if parm_tup.isDisabled() or parm_tup.isHidden():
Expand Down
4 changes: 3 additions & 1 deletion soho/python3.7/PBRTnodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@ def get_used_parms(self):
if self.node.coshaderNodes(parm_name):
# Instead of adding checks for this multiple
# times, check once and then continue
parms[parm_name] = parm_tup
if not parm_tup.isHidden():
# If hidden, then wrong signature
parms[parm_name] = parm_tup
continue

if parm_tup.isDisabled() or parm_tup.isHidden():
Expand Down
52 changes: 52 additions & 0 deletions tests/scenes/TestMaterials/test_texture_mixing_material.pbrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@

Film "rgb" "string filename" [ "test_texture_mixing_material.exr" ] "integer xresolution" [ 320 ] "integer yresolution" [ 240 ]
PixelFilter "gaussian" "float xradius" [ 2 ] "float yradius" [ 2 ]
Sampler "zsobol" "integer pixelsamples" [ 16 ]
Integrator "volpath" "integer maxdepth" [ 5 ]
Accelerator "bvh"

# /obj/cam1
Transform [ 0.6691 -0.4263 -0.6087 0 0 0.8192 -0.5736 0 -0.7431 -0.3838 -0.5481 0 0.5921 -0.07283 13.84 1 ]
Camera "perspective" "float fov" [ 45 ] "float screenwindow" [ -1 1 -0.75 0.75 ]

WorldBegin # {

# ==================================================
# Light Definitions
# /obj/envlight1
AttributeBegin # {
Transform [ 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 ]
Scale 1 1 -1
Rotate 90 0 0 1
Rotate 90 0 1 0
LightSource "infinite" "float scale" [ 0.5 ]
AttributeEnd # }


# ==================================================
# NamedMaterial Definitions
Texture "/mat/pbrt_texture_checkerboard2" "spectrum" "checkerboard"
Texture "/mat/pbrt_texture_checkerboard1" "float" "checkerboard"
Texture "/mat/pbrt_texture_mix1" "float" "mix" "float amount" [ 0.4 ] "texture tex1" [ "/mat/pbrt_texture_checkerboard1" ]
Texture "/mat/pbrt_texture_mix2" "spectrum" "mix" "texture amount" [ "/mat/pbrt_texture_mix1" ] "texture tex1" [ "/mat/pbrt_texture_checkerboard2" ]
MakeNamedMaterial "/mat/pbrt_material_diffuse1" "string type" "diffuse" "texture reflectance" [ "/mat/pbrt_texture_mix2" ]


# ==================================================
# NamedMedium Definitions

# ==================================================
# Object Instance Definitions

# ==================================================
# Object Definitions
# --------------------------------------------------
# /obj/geo1
AttributeBegin # {
ConcatTransform [ 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 ]
NamedMaterial "/mat/pbrt_material_diffuse1"
# Can not find soppath for object
AttributeEnd # }


# }
26 changes: 25 additions & 1 deletion tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ def test_exterior_cam(self):

def test_exterior_cam_interior_obj(self):
# TODO / NOTE:
# I don't believe this test is givign the expected results
# I don't believe this test is giving the expected results
# as there is no mediums attached to the lights.
# This is a lack of understanding on how pbrt-v4 works and
# will require some experiments
Expand Down Expand Up @@ -1048,6 +1048,30 @@ def test_checker_material(self):
self.geo.parm("shop_materialpath").set(matte.path())
self.compare_scene()

def test_texture_mixing_material(self):
space = hou.node("/obj").createNode("null")
space.parmTuple("t").set([1, 2, 3])
space.parmTuple("s").set([5, 10, 20])
matte = hou.node("/mat").createNode("pbrt_material_diffuse")
checks_float = hou.node("/mat").createNode("pbrt_texture_checkerboard")
checks_spectrum = hou.node("/mat").createNode("pbrt_texture_checkerboard")
mix_float = hou.node("/mat").createNode("pbrt_texture_mix")
mix_spectrum = hou.node("/mat").createNode("pbrt_texture_mix")
checks_float.parm("signature").set("default")
checks_float.parm("dimension").set(2)
mix_float.parm("signature").set("default")
mix_float.parm("amount").set(0.4)
checks_spectrum.parm("signature").set("s")
checks_spectrum.parm("dimension").set(2)
mix_spectrum.parm("signature").set("s")
mix_spectrum.parm("amount").set(0.4)
mix_float.setNamedInput("tex1", checks_float, "output")
mix_spectrum.setNamedInput("tex1", checks_spectrum, "output")
mix_spectrum.setNamedInput("amount", mix_float, "output")
matte.setNamedInput("reflectance", mix_spectrum, "output")
self.geo.parm("shop_materialpath").set(matte.path())
self.compare_scene()


class TestSpectrum(TestRoot):
@classmethod
Expand Down

0 comments on commit a284c4c

Please sign in to comment.