Skip to content

Commit

Permalink
Merge branch 'main' into adsk/bugfix/module_path_fix_python_3_8
Browse files Browse the repository at this point in the history
  • Loading branch information
jstone-lucasfilm committed Nov 21, 2023
2 parents f5ab44f + 30a446e commit ffbd77d
Show file tree
Hide file tree
Showing 23 changed files with 302 additions and 95 deletions.
42 changes: 23 additions & 19 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ jobs:
python: 3.7
cmake_config: -DMATERIALX_BUILD_SHARED_LIBS=ON

- name: Linux_GCC_11_Python39
os: ubuntu-20.04
compiler: gcc
compiler_version: "11"
python: 3.9
build_javascript: ON

- name: Linux_GCC_12_Python311
os: ubuntu-22.04
compiler: gcc
compiler_version: "12"
python: 3.11
upload_shaders: ON
build_javascript: ON

- name: Linux_GCC_13_Python312
os: ubuntu-22.04
compiler: gcc
compiler_version: "13"
python: 3.12
static_analysis: ON

- name: Linux_GCC_CoverageAnalysis
os: ubuntu-22.04
Expand All @@ -53,20 +53,19 @@ jobs:
compiler_version: "10"
python: 3.7
cmake_config: -DMATERIALX_BUILD_SHARED_LIBS=ON
static_analysis: ON

- name: Linux_Clang_14_Python311
- name: Linux_Clang_15_Python312
os: ubuntu-22.04
compiler: clang
compiler_version: "14"
python: 3.11
compiler_version: "15"
python: 3.12
test_render: ON
clang_format: ON

- name: Linux_Clang_14_DynamicAnalysis
- name: Linux_Clang_DynamicAnalysis
os: ubuntu-22.04
compiler: clang
compiler_version: "14"
compiler_version: "15"
python: None
cmake_config: -DMATERIALX_DYNAMIC_ANALYSIS=ON
dynamic_analysis: ON
Expand Down Expand Up @@ -104,18 +103,19 @@ jobs:
python: 3.7
cmake_config: -G "Visual Studio 16 2019" -A "Win32" -DMATERIALX_BUILD_SHARED_LIBS=ON

- name: Windows_VS2022_x64_Python39
- name: Windows_VS2022_x64_Python311
os: windows-2022
architecture: x64
python: 3.9
python: 3.11
cmake_config: -G "Visual Studio 17 2022" -A "x64"
test_shaders: ON

- name: Windows_VS2022_x64_Python311
- name: Windows_VS2022_x64_Python312
os: windows-2022
architecture: x64
python: 3.11
python: 3.12
cmake_config: -G "Visual Studio 17 2022" -A "x64"
test_shaders: ON
upload_shaders: ON

steps:
- name: Sync Repository
Expand Down Expand Up @@ -172,6 +172,10 @@ jobs:
python-version: ${{ matrix.python }}
architecture: ${{ matrix.architecture }}

- name: Install Python Dependencies
if: matrix.python != 'None'
run: pip install setuptools

- name: Install Emscripten
if: matrix.build_javascript == 'ON'
run: |
Expand Down
12 changes: 6 additions & 6 deletions libraries/stdlib/genmdl/stdlib_genmdl_impl.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@
<!-- ======================================================================== -->

<!-- <image> -->
<implementation name="IM_image_float_genmdl" nodedef="ND_image_float" sourcecode="mx::stdlib::mx_image_float({{file}}, {{layer}}, {{default}}, {{texcoord}}, {{uaddressmode}}, {{vaddressmode}}, {{filtertype}}, {{framerange}}, {{frameoffset}}, {{frameendaction}})" target="genmdl">
<implementation name="IM_image_float_genmdl" nodedef="ND_image_float" sourcecode="mx::stdlib::mx_image_float({{file}}, {{layer}}, {{default}}, {{texcoord}}, {{uaddressmode}}, {{vaddressmode}}, {{filtertype}}, {{framerange}}, {{frameoffset}}, {{frameendaction}}, mxp_flip_v:{{flip_v}})" target="genmdl">
<input name="default" type="float" implname="default_value" />
</implementation>
<implementation name="IM_image_color3_genmdl" nodedef="ND_image_color3" sourcecode="mx::stdlib::mx_image_color3({{file}}, {{layer}}, {{default}}, {{texcoord}}, {{uaddressmode}}, {{vaddressmode}}, {{filtertype}}, {{framerange}}, {{frameoffset}}, {{frameendaction}})" target="genmdl">
<implementation name="IM_image_color3_genmdl" nodedef="ND_image_color3" sourcecode="mx::stdlib::mx_image_color3({{file}}, {{layer}}, {{default}}, {{texcoord}}, {{uaddressmode}}, {{vaddressmode}}, {{filtertype}}, {{framerange}}, {{frameoffset}}, {{frameendaction}}, mxp_flip_v:{{flip_v}})" target="genmdl">
<input name="default" type="color3" implname="default_value" />
</implementation>
<implementation name="IM_image_color4_genmdl" nodedef="ND_image_color4" sourcecode="mx::stdlib::mx_image_color4({{file}}, {{layer}}, {{default}}, {{texcoord}}, {{uaddressmode}}, {{vaddressmode}}, {{filtertype}}, {{framerange}}, {{frameoffset}}, {{frameendaction}})" target="genmdl">
<implementation name="IM_image_color4_genmdl" nodedef="ND_image_color4" sourcecode="mx::stdlib::mx_image_color4({{file}}, {{layer}}, {{default}}, {{texcoord}}, {{uaddressmode}}, {{vaddressmode}}, {{filtertype}}, {{framerange}}, {{frameoffset}}, {{frameendaction}}, mxp_flip_v:{{flip_v}})" target="genmdl">
<input name="default" type="color4" implname="default_value" />
</implementation>
<implementation name="IM_image_vector2_genmdl" nodedef="ND_image_vector2" sourcecode="mx::stdlib::mx_image_vector2({{file}}, {{layer}}, {{default}}, {{texcoord}}, {{uaddressmode}}, {{vaddressmode}}, {{filtertype}}, {{framerange}}, {{frameoffset}}, {{frameendaction}})" target="genmdl">
<implementation name="IM_image_vector2_genmdl" nodedef="ND_image_vector2" sourcecode="mx::stdlib::mx_image_vector2({{file}}, {{layer}}, {{default}}, {{texcoord}}, {{uaddressmode}}, {{vaddressmode}}, {{filtertype}}, {{framerange}}, {{frameoffset}}, {{frameendaction}}, mxp_flip_v:{{flip_v}})" target="genmdl">
<input name="default" type="vector2" implname="default_value" />
</implementation>
<implementation name="IM_image_vector3_genmdl" nodedef="ND_image_vector3" sourcecode="mx::stdlib::mx_image_vector3({{file}}, {{layer}}, {{default}}, {{texcoord}}, {{uaddressmode}}, {{vaddressmode}}, {{filtertype}}, {{framerange}}, {{frameoffset}}, {{frameendaction}})" target="genmdl">
<implementation name="IM_image_vector3_genmdl" nodedef="ND_image_vector3" sourcecode="mx::stdlib::mx_image_vector3({{file}}, {{layer}}, {{default}}, {{texcoord}}, {{uaddressmode}}, {{vaddressmode}}, {{filtertype}}, {{framerange}}, {{frameoffset}}, {{frameendaction}}, mxp_flip_v:{{flip_v}})" target="genmdl">
<input name="default" type="vector3" implname="default_value" />
</implementation>
<implementation name="IM_image_vector4_genmdl" nodedef="ND_image_vector4" sourcecode="mx::stdlib::mx_image_vector4({{file}}, {{layer}}, {{default}}, {{texcoord}}, {{uaddressmode}}, {{vaddressmode}}, {{filtertype}}, {{framerange}}, {{frameoffset}}, {{frameendaction}})" target="genmdl">
<implementation name="IM_image_vector4_genmdl" nodedef="ND_image_vector4" sourcecode="mx::stdlib::mx_image_vector4({{file}}, {{layer}}, {{default}}, {{texcoord}}, {{uaddressmode}}, {{vaddressmode}}, {{filtertype}}, {{framerange}}, {{frameoffset}}, {{frameendaction}}, mxp_flip_v:{{flip_v}})" target="genmdl">
<input name="default" type="vector4" implname="default_value" />
</implementation>

Expand Down
3 changes: 1 addition & 2 deletions python/Scripts/baketextures.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@

import sys, os, argparse
from sys import platform

import MaterialX as mx
from MaterialX import PyMaterialXGenShader
from MaterialX import PyMaterialXGenGlsl
from MaterialX import PyMaterialXRender as mx_render
from MaterialX import PyMaterialXRenderGlsl as mx_render_glsl
if platform == "darwin":
Expand Down
5 changes: 3 additions & 2 deletions python/Scripts/generateshader.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
'''

import sys, os, argparse, subprocess

import MaterialX as mx
import MaterialX.PyMaterialXGenShader as mx_gen_shader
import MaterialX.PyMaterialXGenGlsl as mx_gen_glsl
import MaterialX.PyMaterialXGenOsl as mx_gen_osl
import MaterialX.PyMaterialXGenMdl as mx_gen_mdl
import MaterialX.PyMaterialXGenMsl as mx_gen_msl
import MaterialX.PyMaterialXGenOsl as mx_gen_osl
import MaterialX.PyMaterialXGenShader as mx_gen_shader

def validateCode(sourceCodeFile, codevalidator, codevalidatorArgs):
if codevalidator:
Expand Down
6 changes: 2 additions & 4 deletions python/Scripts/translateshader.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
'''

import sys, os, argparse
import MaterialX as mx

from sys import platform

import MaterialX as mx
from MaterialX import PyMaterialXGenShader as mx_gen_shader
from MaterialX import PyMaterialXGenGlsl as ms_gen_glsl
from MaterialX import PyMaterialXRender as mx_render
from MaterialX import PyMaterialXRenderGlsl as mx_render_glsl
if platform == "darwin":
from MaterialX import PyMaterialXGenMsl as ms_gen_msl
from MaterialX import PyMaterialXRenderMsl as mx_render_msl

def main():
Expand Down
9 changes: 9 additions & 0 deletions source/MaterialXGenMdl/MdlShaderGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <MaterialXGenMdl/Nodes/ClosureCompoundNodeMdl.h>
#include <MaterialXGenMdl/Nodes/ClosureSourceCodeNodeMdl.h>
#include <MaterialXGenMdl/Nodes/SwizzleNodeMdl.h>
#include <MaterialXGenMdl/Nodes/ImageNodeMdl.h>

#include <MaterialXGenShader/GenContext.h>
#include <MaterialXGenShader/Shader.h>
Expand Down Expand Up @@ -187,6 +188,14 @@ MdlShaderGenerator::MdlShaderGenerator() :

// <!-- <sheen_bsdf> -->
registerImplementation("IM_sheen_bsdf_" + MdlShaderGenerator::TARGET, LayerableNodeMdl::create);

// <!-- <image> -->
registerImplementation("IM_image_float_" + MdlShaderGenerator::TARGET, ImageNodeMdl::create);
registerImplementation("IM_image_color3_" + MdlShaderGenerator::TARGET, ImageNodeMdl::create);
registerImplementation("IM_image_color4_" + MdlShaderGenerator::TARGET, ImageNodeMdl::create);
registerImplementation("IM_image_vector2_" + MdlShaderGenerator::TARGET, ImageNodeMdl::create);
registerImplementation("IM_image_vector3_" + MdlShaderGenerator::TARGET, ImageNodeMdl::create);
registerImplementation("IM_image_vector4_" + MdlShaderGenerator::TARGET, ImageNodeMdl::create);
}

ShaderPtr MdlShaderGenerator::generate(const string& name, ElementPtr element, GenContext& context) const
Expand Down
50 changes: 50 additions & 0 deletions source/MaterialXGenMdl/Nodes/ImageNodeMdl.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//
// Copyright Contributors to the MaterialX Project
// SPDX-License-Identifier: Apache-2.0
//

#include <MaterialXGenMdl/Nodes/ImageNodeMdl.h>
#include <MaterialXGenShader/ShaderGenerator.h>
#include <MaterialXGenShader/Shader.h>
#include <MaterialXGenShader/GenContext.h>

MATERIALX_NAMESPACE_BEGIN

const string ImageNodeMdl::FLIP_V = "flip_v";

ShaderNodeImplPtr ImageNodeMdl::create()
{
return std::make_shared<ImageNodeMdl>();
}

void ImageNodeMdl::addInputs(ShaderNode& node, GenContext& context) const
{
BASE::addInputs(node, context);
node.addInput(ImageNodeMdl::FLIP_V, Type::BOOLEAN)->setUniform();
}

bool ImageNodeMdl::isEditable(const ShaderInput& input) const
{
if (input.getName() == ImageNodeMdl::FLIP_V)
{
return false;
}
return BASE::isEditable(input);
}

void ImageNodeMdl::emitFunctionCall(const ShaderNode& _node, GenContext& context, ShaderStage& stage) const
{
DEFINE_SHADER_STAGE(stage, Stage::PIXEL)
{
ShaderNode& node = const_cast<ShaderNode&>(_node);
ShaderInput* flipUInput = node.getInput(ImageNodeMdl::FLIP_V);
ValuePtr value = TypedValue<bool>::createValue(context.getOptions().fileTextureVerticalFlip);
if (flipUInput)
{
flipUInput->setValue(value);
}
BASE::emitFunctionCall(_node, context, stage);
}
}

MATERIALX_NAMESPACE_END
34 changes: 34 additions & 0 deletions source/MaterialXGenMdl/Nodes/ImageNodeMdl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// Copyright Contributors to the MaterialX Project
// SPDX-License-Identifier: Apache-2.0
//

#ifndef MATERIALX_IMAGENODEMDL_H
#define MATERIALX_IMAGENODEMDL_H

#include <MaterialXGenMdl/Export.h>

#include "SourceCodeNodeMdl.h"

MATERIALX_NAMESPACE_BEGIN

/// Image node implementation for MDL
class MX_GENMDL_API ImageNodeMdl : public SourceCodeNodeMdl
{
using BASE = SourceCodeNodeMdl;

public:
static const string FLIP_V; ///< the empty string ""

static ShaderNodeImplPtr create();

void addInputs(ShaderNode& node, GenContext& context) const override;

bool isEditable(const ShaderInput& input) const override;

void emitFunctionCall(const ShaderNode& node, GenContext& context, ShaderStage& stage) const override;
};

MATERIALX_NAMESPACE_END

#endif
10 changes: 5 additions & 5 deletions source/MaterialXGenMdl/mdl/materialx/hsv.mdl
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ import ::limits::*;
export float3 mx_hsvtorgb(float3 hsv) {
// from "Color Imaging, Fundamentals and Applications", Reinhard et al., p. 442

// A hue of 1.0 is questionably valid, and needs to be interpreted as 0.0f
float h_prime = (hsv.x < 1.0f) ? hsv.x * 6.0f : 0.0f; // H * 360.0/60.0
float h_floor = math::floor(h_prime);
float f = h_prime - h_floor;
float h = 6.0 * (hsv.x - math::floor(hsv.x));
int hi = int(h); // truncate
float f = h - float(hi);

float zy = hsv.z*hsv.y;
float a = hsv.z - zy;
float b = hsv.z - zy*f;
float c = a + zy*f;

switch(int(h_floor)) {
switch(hi) {
default:
// hue out of [0,1] range...
// fall through...
Expand Down
Loading

0 comments on commit ffbd77d

Please sign in to comment.