Skip to content

Commit

Permalink
Merge branch 'main' into zicher3d/patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
jstone-lucasfilm authored Aug 20, 2023
2 parents f857773 + 2d12c16 commit b0960b6
Show file tree
Hide file tree
Showing 37 changed files with 327 additions and 224 deletions.
34 changes: 34 additions & 0 deletions cmake/modules/MaterialXVersion.rc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

#define MATERIALX_FILEVERSION @MATERIALX_MAJOR_VERSION@,@MATERIALX_MINOR_VERSION@,@MATERIALX_BUILD_VERSION@,0
#define MATERIALX_FILEVERSION_STR "@MATERIALX_MAJOR_VERSION@.@MATERIALX_MINOR_VERSION@.@MATERIALX_BUILD_VERSION@.0\0"
#define MATERIALX_FILENAME_STR "@MATERIALX_MODULE_NAME@.dll\0"

1 VERSIONINFO
FILEVERSION MATERIALX_FILEVERSION
PRODUCTVERSION MATERIALX_FILEVERSION
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "FileVersion", MATERIALX_FILEVERSION_STR
VALUE "LegalCopyright", "Apache License 2.0\0"
VALUE "OriginalFilename", MATERIALX_FILENAME_STR
VALUE "ProductName", "MaterialX\0"
VALUE "ProductVersion", MATERIALX_FILEVERSION_STR
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END
11 changes: 2 additions & 9 deletions libraries/stdlib/genglsl/mx_image_color3.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@

void mx_image_color3(sampler2D tex_sampler, int layer, vec3 defaultval, vec2 texcoord, int uaddressmode, int vaddressmode, int filtertype, int framerange, int frameoffset, int frameendaction, vec2 uv_scale, vec2 uv_offset, out vec3 result)
{
if (textureSize(tex_sampler, 0).x > 1)
{
vec2 uv = mx_transform_uv(texcoord, uv_scale, uv_offset);
result = texture(tex_sampler, uv).rgb;
}
else
{
result = defaultval;
}
vec2 uv = mx_transform_uv(texcoord, uv_scale, uv_offset);
result = texture(tex_sampler, uv).rgb;
}
11 changes: 2 additions & 9 deletions libraries/stdlib/genglsl/mx_image_color4.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@

void mx_image_color4(sampler2D tex_sampler, int layer, vec4 defaultval, vec2 texcoord, int uaddressmode, int vaddressmode, int filtertype, int framerange, int frameoffset, int frameendaction, vec2 uv_scale, vec2 uv_offset, out vec4 result)
{
if (textureSize(tex_sampler, 0).x > 1)
{
vec2 uv = mx_transform_uv(texcoord, uv_scale, uv_offset);
result = texture(tex_sampler, uv);
}
else
{
result = defaultval;
}
vec2 uv = mx_transform_uv(texcoord, uv_scale, uv_offset);
result = texture(tex_sampler, uv);
}
11 changes: 2 additions & 9 deletions libraries/stdlib/genglsl/mx_image_float.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@

void mx_image_float(sampler2D tex_sampler, int layer, float defaultval, vec2 texcoord, int uaddressmode, int vaddressmode, int filtertype, int framerange, int frameoffset, int frameendaction, vec2 uv_scale, vec2 uv_offset, out float result)
{
if (textureSize(tex_sampler, 0).x > 1)
{
vec2 uv = mx_transform_uv(texcoord, uv_scale, uv_offset);
result = texture(tex_sampler, uv).r;
}
else
{
result = defaultval;
}
vec2 uv = mx_transform_uv(texcoord, uv_scale, uv_offset);
result = texture(tex_sampler, uv).r;
}
11 changes: 2 additions & 9 deletions libraries/stdlib/genglsl/mx_image_vector2.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@

void mx_image_vector2(sampler2D tex_sampler, int layer, vec2 defaultval, vec2 texcoord, int uaddressmode, int vaddressmode, int filtertype, int framerange, int frameoffset, int frameendaction, vec2 uv_scale, vec2 uv_offset, out vec2 result)
{
if (textureSize(tex_sampler, 0).x > 1)
{
vec2 uv = mx_transform_uv(texcoord, uv_scale, uv_offset);
result = texture(tex_sampler, uv).rg;
}
else
{
result = defaultval;
}
vec2 uv = mx_transform_uv(texcoord, uv_scale, uv_offset);
result = texture(tex_sampler, uv).rg;
}
11 changes: 2 additions & 9 deletions libraries/stdlib/genglsl/mx_image_vector3.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@

void mx_image_vector3(sampler2D tex_sampler, int layer, vec3 defaultval, vec2 texcoord, int uaddressmode, int vaddressmode, int filtertype, int framerange, int frameoffset, int frameendaction, vec2 uv_scale, vec2 uv_offset, out vec3 result)
{
if (textureSize(tex_sampler, 0).x > 1)
{
vec2 uv = mx_transform_uv(texcoord, uv_scale, uv_offset);
result = texture(tex_sampler, uv).rgb;
}
else
{
result = defaultval;
}
vec2 uv = mx_transform_uv(texcoord, uv_scale, uv_offset);
result = texture(tex_sampler, uv).rgb;
}
11 changes: 2 additions & 9 deletions libraries/stdlib/genglsl/mx_image_vector4.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@

void mx_image_vector4(sampler2D tex_sampler, int layer, vec4 defaultval, vec2 texcoord, int uaddressmode, int vaddressmode, int filtertype, int framerange, int frameoffset, int frameendaction, vec2 uv_scale, vec2 uv_offset, out vec4 result)
{
if (textureSize(tex_sampler, 0).x > 1)
{
vec2 uv = mx_transform_uv(texcoord, uv_scale, uv_offset);
result = texture(tex_sampler, uv);
}
else
{
result = defaultval;
}
vec2 uv = mx_transform_uv(texcoord, uv_scale, uv_offset);
result = texture(tex_sampler, uv);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0"?>
<materialx version="1.38" colorspace="lin_rec709">
<surfacematerial name="surfacematerial" type="material" xpos="17.246376" ypos="-15.689655">
<input name="surfaceshader" type="surfaceshader" nodename="surface_unlit" />
</surfacematerial>
<input name="input_color3" type="color3" value="0, 0, 1" xpos="10.905797" ypos="-15.982759" />
<surface_unlit name="surface_unlit" type="surfaceshader" xpos="14.231884" ypos="-16.241379">
<input name="emission_color" type="color3" interfacename="input_color3" />
</surface_unlit>
</materialx>
36 changes: 36 additions & 0 deletions resources/Materials/TestSuite/stdlib/texture/image_default.mtlx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0"?>
<materialx version="1.38" colorspace="lin_rec709">
<!--
Validation of default color fallbacks for missing image files.
-->
<image name="image_color4" type="color4">
<input name="file" type="filename" value="resources/Images/invalid.png" />
<input name="default" type="color4" value="0.8, 0.2, 0.2, 1.0" />
</image>
<output name="image_color4_output" type="color4" nodename="image_color4" />
<image name="image_color3" type="color3">
<input name="file" type="filename" value="resources/Images/invalid.png" />
<input name="default" type="color3" value="0.8, 0.2, 0.2" />
</image>
<output name="image_color3_output" type="color3" nodename="image_color3" />
<image name="image_vector4" type="vector4">
<input name="file" type="filename" value="resources/Images/invalid.png" />
<input name="default" type="vector4" value="0.8, 0.2, 0.2, 1.0" />
</image>
<output name="image_vector4_output" type="vector4" nodename="image_vector4" />
<image name="image_vector3" type="vector3">
<input name="file" type="filename" value="resources/Images/invalid.png" />
<input name="default" type="vector3" value="0.8, 0.2, 0.2" />
</image>
<output name="image_vector3_output" type="vector3" nodename="image_vector3" />
<image name="image_vector2" type="vector2">
<input name="file" type="filename" value="resources/Images/invalid.png" />
<input name="default" type="vector2" value="0.8, 0.2" />
</image>
<output name="image_vector2_output" type="vector2" nodename="image_vector2" />
<image name="image_float" type="float">
<input name="file" type="filename" value="resources/Images/invalid.png" />
<input name="default" type="float" value="0.8" />
</image>
<output name="image_float_output" type="float" nodename="image_float" />
</materialx>
24 changes: 16 additions & 8 deletions source/MaterialXCore/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,40 +1,48 @@
set(MATERIALX_MODULE_NAME MaterialXCore)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Generated.h.in ${CMAKE_CURRENT_BINARY_DIR}/Generated.h)

file(GLOB materialx_source "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
file(GLOB materialx_headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h" "${CMAKE_CURRENT_BINARY_DIR}/*.h")

add_library(MaterialXCore ${materialx_source} ${materialx_headers})
add_library(${MATERIALX_MODULE_NAME} ${materialx_source} ${materialx_headers})

add_definitions(-DMATERIALX_CORE_EXPORTS)

# Create version resource
if(MATERIALX_BUILD_SHARED_LIBS AND MSVC)
configure_file(${CMAKE_SOURCE_DIR}/cmake/modules/MaterialXVersion.rc.in ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
target_sources(${MATERIALX_MODULE_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
endif()

set_target_properties(
MaterialXCore PROPERTIES
OUTPUT_NAME MaterialXCore${MATERIALX_LIBNAME_SUFFIX}
${MATERIALX_MODULE_NAME} PROPERTIES
OUTPUT_NAME ${MATERIALX_MODULE_NAME}${MATERIALX_LIBNAME_SUFFIX}
COMPILE_FLAGS "${EXTERNAL_COMPILE_FLAGS}"
LINK_FLAGS "${EXTERNAL_LINK_FLAGS}"
VERSION "${MATERIALX_LIBRARY_VERSION}"
SOVERSION "${MATERIALX_MAJOR_VERSION}")

target_link_libraries(
MaterialXCore
${MATERIALX_MODULE_NAME}
${CMAKE_DL_LIBS})

target_include_directories(MaterialXCore
target_include_directories(${MATERIALX_MODULE_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/../>
$<INSTALL_INTERFACE:${MATERIALX_INSTALL_INCLUDE_PATH}>
PRIVATE
${EXTERNAL_INCLUDE_DIRS})

install(TARGETS MaterialXCore
install(TARGETS ${MATERIALX_MODULE_NAME}
EXPORT MaterialX
ARCHIVE DESTINATION ${MATERIALX_INSTALL_LIB_PATH}
LIBRARY DESTINATION ${MATERIALX_INSTALL_LIB_PATH}
RUNTIME DESTINATION bin)

install(FILES ${materialx_headers}
DESTINATION ${MATERIALX_INSTALL_INCLUDE_PATH}/MaterialXCore/)
DESTINATION ${MATERIALX_INSTALL_INCLUDE_PATH}/${MATERIALX_MODULE_NAME}/)

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MaterialXCore.pdb"
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/${MATERIALX_MODULE_NAME}.pdb"
DESTINATION "${MATERIALX_INSTALL_LIB_PATH}/" OPTIONAL)
2 changes: 1 addition & 1 deletion source/MaterialXCore/Interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ InputPtr Input::getInterfaceInput() const
{
if (hasInterfaceName())
{
ConstNodeGraphPtr graph = getAncestorOfType<NodeGraph>();
ConstGraphElementPtr graph = getAncestorOfType<GraphElement>();
if (graph)
{
return graph->getInput(getInterfaceName());
Expand Down
10 changes: 0 additions & 10 deletions source/MaterialXCore/Node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,9 +439,7 @@ vector<ElementPtr> GraphElement::topologicalSort() const
}
}

size_t visitCount = 0;
vector<ElementPtr> result;

while (!childQueue.empty())
{
// Pop the queue and add to topological order.
Expand All @@ -467,14 +465,6 @@ vector<ElementPtr> GraphElement::topologicalSort() const
}
}
}

visitCount++;
}

// Check if there was a cycle.
if (visitCount != children.size())
{
throw ExceptionFoundCycle("Encountered a cycle in graph: " + getName());
}

return result;
Expand Down
1 change: 0 additions & 1 deletion source/MaterialXCore/Node.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ class MX_CORE_API GraphElement : public InterfaceElement

/// Return a vector of all children (nodes and outputs) sorted in
/// topological order.
/// @throws ExceptionFoundCycle if a cycle is encountered.
vector<ElementPtr> topologicalSort() const;

/// If not yet present, add a geometry node to this graph matching the given property
Expand Down
24 changes: 16 additions & 8 deletions source/MaterialXFormat/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,43 +1,51 @@
set(MATERIALX_MODULE_NAME MaterialXFormat)

file(GLOB_RECURSE materialx_source "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
file(GLOB_RECURSE materialx_headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h*")

assign_source_group("Source Files" ${materialx_source})
assign_source_group("Header Files" ${materialx_headers})

add_library(MaterialXFormat ${materialx_source} ${materialx_headers})
add_library(${MATERIALX_MODULE_NAME} ${materialx_source} ${materialx_headers})

add_definitions(-DMATERIALX_FORMAT_EXPORTS)

# Create version resource
if(MATERIALX_BUILD_SHARED_LIBS AND MSVC)
configure_file(${CMAKE_SOURCE_DIR}/cmake/modules/MaterialXVersion.rc.in ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
target_sources(${MATERIALX_MODULE_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
endif()

set_target_properties(
MaterialXFormat PROPERTIES
OUTPUT_NAME MaterialXFormat${MATERIALX_LIBNAME_SUFFIX}
${MATERIALX_MODULE_NAME} PROPERTIES
OUTPUT_NAME ${MATERIALX_MODULE_NAME}${MATERIALX_LIBNAME_SUFFIX}
COMPILE_FLAGS "${EXTERNAL_COMPILE_FLAGS}"
LINK_FLAGS "${EXTERNAL_LINK_FLAGS}"
INSTALL_RPATH "${MATERIALX_SAME_DIR_RPATH}"
VERSION "${MATERIALX_LIBRARY_VERSION}"
SOVERSION "${MATERIALX_MAJOR_VERSION}")

target_link_libraries(
MaterialXFormat
${MATERIALX_MODULE_NAME}
MaterialXCore
${CMAKE_DL_LIBS})

target_include_directories(MaterialXFormat
target_include_directories(${MATERIALX_MODULE_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../>
$<INSTALL_INTERFACE:${MATERIALX_INSTALL_INCLUDE_PATH}>
PRIVATE
${EXTERNAL_INCLUDE_DIRS})

install(TARGETS MaterialXFormat
install(TARGETS ${MATERIALX_MODULE_NAME}
EXPORT MaterialX
ARCHIVE DESTINATION ${MATERIALX_INSTALL_LIB_PATH}
LIBRARY DESTINATION ${MATERIALX_INSTALL_LIB_PATH}
RUNTIME DESTINATION bin)

install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/"
DESTINATION ${MATERIALX_INSTALL_INCLUDE_PATH}/MaterialXFormat/ MESSAGE_NEVER
DESTINATION ${MATERIALX_INSTALL_INCLUDE_PATH}/${MATERIALX_MODULE_NAME}/ MESSAGE_NEVER
FILES_MATCHING PATTERN "*.h*")

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MaterialXFormat.pdb"
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/${MATERIALX_MODULE_NAME}.pdb"
DESTINATION "${MATERIALX_INSTALL_LIB_PATH}/" OPTIONAL)
24 changes: 16 additions & 8 deletions source/MaterialXGenGlsl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,44 +1,52 @@
set(MATERIALX_MODULE_NAME MaterialXGenGlsl)

file(GLOB_RECURSE materialx_source "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
file(GLOB_RECURSE materialx_headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h*")

assign_source_group("Source Files" ${materialx_source})
assign_source_group("Header Files" ${materialx_headers})

add_library(MaterialXGenGlsl ${materialx_source} ${materialx_headers})
add_library(${MATERIALX_MODULE_NAME} ${materialx_source} ${materialx_headers})

add_definitions(-DMATERIALX_GENGLSL_EXPORTS)

# Create version resource
if(MATERIALX_BUILD_SHARED_LIBS AND MSVC)
configure_file(${CMAKE_SOURCE_DIR}/cmake/modules/MaterialXVersion.rc.in ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
target_sources(${MATERIALX_MODULE_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
endif()

set_target_properties(
MaterialXGenGlsl PROPERTIES
OUTPUT_NAME MaterialXGenGlsl${MATERIALX_LIBNAME_SUFFIX}
${MATERIALX_MODULE_NAME} PROPERTIES
OUTPUT_NAME ${MATERIALX_MODULE_NAME}${MATERIALX_LIBNAME_SUFFIX}
COMPILE_FLAGS "${EXTERNAL_COMPILE_FLAGS}"
LINK_FLAGS "${EXTERNAL_LINK_FLAGS}"
INSTALL_RPATH "${MATERIALX_SAME_DIR_RPATH}"
VERSION "${MATERIALX_LIBRARY_VERSION}"
SOVERSION "${MATERIALX_MAJOR_VERSION}")

target_link_libraries(
MaterialXGenGlsl
${MATERIALX_MODULE_NAME}
MaterialXGenShader
MaterialXCore
${CMAKE_DL_LIBS})

target_include_directories(MaterialXGenGlsl
target_include_directories(${MATERIALX_MODULE_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../>
$<INSTALL_INTERFACE:${MATERIALX_INSTALL_INCLUDE_PATH}>
PRIVATE
${EXTERNAL_INCLUDE_DIRS})

install(TARGETS MaterialXGenGlsl
install(TARGETS ${MATERIALX_MODULE_NAME}
EXPORT MaterialX
ARCHIVE DESTINATION ${MATERIALX_INSTALL_LIB_PATH}
LIBRARY DESTINATION ${MATERIALX_INSTALL_LIB_PATH}
RUNTIME DESTINATION bin)

install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/"
DESTINATION ${MATERIALX_INSTALL_INCLUDE_PATH}/MaterialXGenGlsl/ MESSAGE_NEVER
DESTINATION ${MATERIALX_INSTALL_INCLUDE_PATH}/${MATERIALX_MODULE_NAME}/ MESSAGE_NEVER
FILES_MATCHING PATTERN "*.h*")

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/MaterialXGenGlsl.pdb"
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/${MATERIALX_MODULE_NAME}.pdb"
DESTINATION "${MATERIALX_INSTALL_LIB_PATH}/" OPTIONAL)
Loading

0 comments on commit b0960b6

Please sign in to comment.