Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove support for legacy OSL closures #2121

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ option(MATERIALX_TEST_RENDER "Run rendering tests for MaterialX Render module. G
option(MATERIALX_WARNINGS_AS_ERRORS "Interpret all compiler warnings as errors." OFF)
option(MATERIALX_COVERAGE_ANALYSIS "Build MaterialX libraries with coverage analysis on supporting platforms." OFF)
option(MATERIALX_DYNAMIC_ANALYSIS "Build MaterialX libraries with dynamic analysis on supporting platforms." OFF)
option(MATERIALX_OSL_LEGACY_CLOSURES "Build OSL shader generation supporting the legacy OSL closures." OFF)

option(MATERIALX_BUILD_IOS "Build MaterialX for iOS. (Deprecated. Set CMAKE_SYSTEM_NAME instead)" OFF)
option(MATERIALX_BUILD_APPLE_FRAMEWORK "Build MaterialX as an Apple Framework" ${__build_apple_framework})
Expand Down Expand Up @@ -180,7 +179,6 @@ mark_as_advanced(MATERIALX_PYTHON_EXECUTABLE)
mark_as_advanced(MATERIALX_PYTHON_OCIO_DIR)
mark_as_advanced(MATERIALX_PYTHON_PYBIND11_DIR)
mark_as_advanced(MATERIALX_OIIO_DIR)
mark_as_advanced(MATERIALX_OSL_LEGACY_CLOSURES)
mark_as_advanced(MATERIALX_OSL_BINARY_OSLC)
mark_as_advanced(MATERIALX_OSL_BINARY_TESTRENDER)
mark_as_advanced(MATERIALX_OSL_INCLUDE_PATH)
Expand Down Expand Up @@ -227,9 +225,6 @@ if(MATERIALX_BUILD_RENDER AND MATERIALX_BUILD_GEN_OSL AND MATERIALX_BUILD_TESTS)
endif()

# Add global definitions
if (MATERIALX_OSL_LEGACY_CLOSURES)
add_definitions(-DMATERIALX_OSL_LEGACY_CLOSURES)
endif()
if(MATERIALX_BUILD_OIIO)
add_definitions(-DMATERIALX_BUILD_OIIO)
endif()
Expand Down
10 changes: 2 additions & 8 deletions libraries/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
if (MATERIALX_OSL_LEGACY_CLOSURES)
set(PBRLIB_SUFFIX "legacy")
else()
set(PBRLIB_SUFFIX "mtlx")
endif()

if(NOT SKBUILD)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
DESTINATION "${MATERIALX_INSTALL_STDLIB_PATH}"
PATTERN "CMakeLists.txt" EXCLUDE
PATTERN "pbrlib_genosl_impl.*" EXCLUDE)
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/pbrlib/genosl/pbrlib_genosl_impl.${PBRLIB_SUFFIX}"
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/pbrlib/genosl/pbrlib_genosl_impl.mtlx"
DESTINATION "${MATERIALX_INSTALL_STDLIB_PATH}/pbrlib/genosl/" RENAME pbrlib_genosl_impl.mtlx)
endif()

Expand All @@ -23,6 +17,6 @@ if(MATERIALX_BUILD_PYTHON)
DESTINATION "${MATERIALX_PYTHON_LIBRARIES_PATH}"
PATTERN "CMakeLists.txt" EXCLUDE
PATTERN "pbrlib_genosl_impl.*" EXCLUDE)
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/pbrlib/genosl/pbrlib_genosl_impl.${PBRLIB_SUFFIX}"
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/pbrlib/genosl/pbrlib_genosl_impl.mtlx"
DESTINATION "${MATERIALX_PYTHON_LIBRARIES_PATH}/pbrlib/genosl/" RENAME pbrlib_genosl_impl.mtlx)
endif()
5 changes: 0 additions & 5 deletions libraries/pbrlib/genosl/legacy/mx_anisotropic_vdf.osl

This file was deleted.

6 changes: 0 additions & 6 deletions libraries/pbrlib/genosl/legacy/mx_burley_diffuse_bsdf.osl

This file was deleted.

32 changes: 0 additions & 32 deletions libraries/pbrlib/genosl/legacy/mx_conductor_bsdf.osl

This file was deleted.

36 changes: 0 additions & 36 deletions libraries/pbrlib/genosl/legacy/mx_dielectric_bsdf.osl

This file was deleted.

38 changes: 0 additions & 38 deletions libraries/pbrlib/genosl/legacy/mx_generalized_schlick_bsdf.osl

This file was deleted.

5 changes: 0 additions & 5 deletions libraries/pbrlib/genosl/legacy/mx_oren_nayar_diffuse_bsdf.osl

This file was deleted.

24 changes: 0 additions & 24 deletions libraries/pbrlib/genosl/legacy/mx_sheen_bsdf.osl

This file was deleted.

6 changes: 0 additions & 6 deletions libraries/pbrlib/genosl/legacy/mx_subsurface_bsdf.osl

This file was deleted.

6 changes: 0 additions & 6 deletions libraries/pbrlib/genosl/legacy/mx_surface.osl

This file was deleted.

5 changes: 0 additions & 5 deletions libraries/pbrlib/genosl/legacy/mx_translucent_bsdf.osl

This file was deleted.

74 changes: 0 additions & 74 deletions libraries/pbrlib/genosl/pbrlib_genosl_impl.legacy

This file was deleted.

47 changes: 0 additions & 47 deletions source/MaterialXGenOsl/Nodes/ClosureLayerNodeOsl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,51 +37,6 @@ void ClosureLayerNodeOsl::emitFunctionCall(const ShaderNode& _node, GenContext&
ShaderNode* top = topInput->getConnection()->getNode();
ShaderNode* base = baseInput->getConnection()->getNode();

#ifdef MATERIALX_OSL_LEGACY_CLOSURES

ClosureContext* cct = context.getClosureContext();

// Evaluate top and base nodes and combine their result
// according to throughput.
//
// TODO: In the BSDF over BSDF case should we emit code
// to check the top throughput amount before calling
// the base BSDF?

// Make sure the connections are sibling nodes and not the graph interface.
if (top->getParent() == node.getParent())
{
// If this layer node has closure parameters set,
// we pass this on to the top component only.
ScopedSetClosureParams setParams(&node, top, cct);
shadergen.emitFunctionCall(*top, context, stage);
}
if (base->getParent() == node.getParent())
{
shadergen.emitFunctionCall(*base, context, stage);
}

// Get the result variables.
const string& topResult = topInput->getConnection()->getVariable();
const string& baseResult = baseInput->getConnection()->getVariable();

// Calculate the layering result.
emitOutputVariables(node, context, stage);
if (base->getOutput()->getType() == Type::VDF)
{
// Combining a surface closure with a volumetric closure is simply done with the add operator in OSL.
shadergen.emitLine(output->getVariable() + ".response = " + topResult + ".response + " + baseResult, stage);
// Just pass the throughput along.
shadergen.emitLine(output->getVariable() + ".throughput = " + topResult + ".throughput", stage);
}
else
{
shadergen.emitLine(output->getVariable() + ".response = " + topResult + ".response + " + baseResult + ".response * " + topResult + ".throughput", stage);
shadergen.emitLine(output->getVariable() + ".throughput = " + topResult + ".throughput * " + baseResult + ".throughput", stage);
}

#else

// Emit the function call for top and base layer.
// Make sure the connections are sibling nodes and not the graph interface.
if (top->getParent() == node.getParent())
Expand All @@ -102,8 +57,6 @@ void ClosureLayerNodeOsl::emitFunctionCall(const ShaderNode& _node, GenContext&
shadergen.emitOutput(output, true, false, context, stage);
shadergen.emitString(" = layer(" + topResult + ", " + baseResult + ")", stage);
shadergen.emitLineEnd(stage);

#endif // MATERIALX_OSL_LEGACY_CLOSURES
}

MATERIALX_NAMESPACE_END
Loading