Skip to content
Open
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
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,10 @@ add_subdirectory(source/MaterialXFormat)
# Add shader generation subdirectories
add_subdirectory(source/MaterialXGenShader)
if(MATERIALX_BUILD_GEN_GLSL OR MATERIALX_BUILD_GEN_OSL OR MATERIALX_BUILD_GEN_MDL OR MATERIALX_BUILD_GEN_MSL)
if(MATERIALX_BUILD_GEN_GLSL OR MATERIALX_BUILD_GEN_MSL)
add_subdirectory(source/MaterialXGenHw)
endif()

if (MATERIALX_BUILD_GEN_GLSL)
add_definitions(-DMATERIALX_BUILD_GEN_GLSL)
add_subdirectory(source/MaterialXGenGlsl)
Expand Down
1 change: 1 addition & 0 deletions source/JsMaterialX/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ target_link_libraries(JsMaterialXGenShader
PUBLIC MaterialXCore
PUBLIC MaterialXFormat
PUBLIC MaterialXGenShader
PUBLIC MaterialXGenHw
PUBLIC MaterialXGenGlsl
PRIVATE ${CMAKE_DL_LIBS})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
// SPDX-License-Identifier: Apache-2.0
//

#include <MaterialXGenShader/HwShaderGenerator.h>
#include <MaterialXGenHw/HwShaderGenerator.h>
#include <MaterialXGenShader/GenContext.h>

#include <emscripten/bind.h>

Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXGenGlsl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mx_add_library(MaterialXGenGlsl
HEADER_FILES
${materialx_headers}
MTLX_MODULES
MaterialXGenShader
MaterialXGenHw
MaterialXCore
EXPORT_DEFINE
MATERIALX_GENGLSL_EXPORTS)
2 changes: 1 addition & 1 deletion source/MaterialXGenGlsl/EsslShaderGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <MaterialXGenGlsl/EsslShaderGenerator.h>
#include <MaterialXGenGlsl/EsslSyntax.h>

#include <MaterialXGenShader/Nodes/HwImageNode.h>
#include <MaterialXGenHw/HwConstants.h>

MATERIALX_NAMESPACE_BEGIN

Expand Down
2 changes: 2 additions & 0 deletions source/MaterialXGenGlsl/GlslResourceBindingContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#include <MaterialXGenGlsl/GlslResourceBindingContext.h>

#include <MaterialXGenShader/GenContext.h>

MATERIALX_NAMESPACE_BEGIN

//
Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXGenGlsl/GlslResourceBindingContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include <MaterialXGenGlsl/Export.h>

#include <MaterialXGenShader/HwShaderGenerator.h>
#include <MaterialXGenHw/HwResourceBindingContext.h>

MATERIALX_NAMESPACE_BEGIN

Expand Down
38 changes: 20 additions & 18 deletions source/MaterialXGenGlsl/GlslShaderGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,27 @@

#include <MaterialXGenGlsl/GlslSyntax.h>

#include <MaterialXGenHw/HwLightShaders.h>
#include <MaterialXGenHw/Nodes/HwImageNode.h>
#include <MaterialXGenHw/Nodes/HwGeomColorNode.h>
#include <MaterialXGenHw/Nodes/HwGeomPropValueNode.h>
#include <MaterialXGenHw/Nodes/HwTexCoordNode.h>
#include <MaterialXGenHw/Nodes/HwTransformNode.h>
#include <MaterialXGenHw/Nodes/HwPositionNode.h>
#include <MaterialXGenHw/Nodes/HwNormalNode.h>
#include <MaterialXGenHw/Nodes/HwTangentNode.h>
#include <MaterialXGenHw/Nodes/HwBitangentNode.h>
#include <MaterialXGenHw/Nodes/HwFrameNode.h>
#include <MaterialXGenHw/Nodes/HwTimeNode.h>
#include <MaterialXGenHw/Nodes/HwViewDirectionNode.h>
#include <MaterialXGenHw/Nodes/HwLightCompoundNode.h>
#include <MaterialXGenHw/Nodes/HwLightNode.h>
#include <MaterialXGenHw/Nodes/HwLightSamplerNode.h>
#include <MaterialXGenHw/Nodes/HwLightShaderNode.h>
#include <MaterialXGenHw/Nodes/HwNumLightsNode.h>
#include <MaterialXGenHw/Nodes/HwSurfaceNode.h>

#include <MaterialXGenShader/Nodes/MaterialNode.h>
#include <MaterialXGenShader/Nodes/HwImageNode.h>
#include <MaterialXGenShader/Nodes/HwGeomColorNode.h>
#include <MaterialXGenShader/Nodes/HwGeomPropValueNode.h>
#include <MaterialXGenShader/Nodes/HwTexCoordNode.h>
#include <MaterialXGenShader/Nodes/HwTransformNode.h>
#include <MaterialXGenShader/Nodes/HwPositionNode.h>
#include <MaterialXGenShader/Nodes/HwNormalNode.h>
#include <MaterialXGenShader/Nodes/HwTangentNode.h>
#include <MaterialXGenShader/Nodes/HwBitangentNode.h>
#include <MaterialXGenShader/Nodes/HwFrameNode.h>
#include <MaterialXGenShader/Nodes/HwTimeNode.h>
#include <MaterialXGenShader/Nodes/HwViewDirectionNode.h>
#include <MaterialXGenShader/Nodes/HwLightCompoundNode.h>
#include <MaterialXGenShader/Nodes/HwLightNode.h>
#include <MaterialXGenShader/Nodes/HwLightSamplerNode.h>
#include <MaterialXGenShader/Nodes/HwLightShaderNode.h>
#include <MaterialXGenShader/Nodes/HwNumLightsNode.h>
#include <MaterialXGenShader/Nodes/HwSurfaceNode.h>

MATERIALX_NAMESPACE_BEGIN

Expand Down
3 changes: 2 additions & 1 deletion source/MaterialXGenGlsl/GlslShaderGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

#include <MaterialXGenGlsl/Export.h>

#include <MaterialXGenShader/HwShaderGenerator.h>
#include <MaterialXGenHw/HwShaderGenerator.h>
#include <MaterialXGenHw/HwResourceBindingContext.h>

MATERIALX_NAMESPACE_BEGIN

Expand Down
1 change: 0 additions & 1 deletion source/MaterialXGenGlsl/GlslSyntax.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <MaterialXGenGlsl/GlslSyntax.h>

#include <MaterialXGenShader/ShaderGenerator.h>
#include <MaterialXGenShader/HwShaderGenerator.h>

MATERIALX_NAMESPACE_BEGIN

Expand Down
2 changes: 2 additions & 0 deletions source/MaterialXGenGlsl/VkResourceBindingContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#include <MaterialXGenGlsl/VkResourceBindingContext.h>

#include <MaterialXGenShader/GenContext.h>

MATERIALX_NAMESPACE_BEGIN

//
Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXGenGlsl/VkResourceBindingContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include <MaterialXGenGlsl/Export.h>

#include <MaterialXGenShader/HwShaderGenerator.h>
#include <MaterialXGenHw/HwResourceBindingContext.h>

MATERIALX_NAMESPACE_BEGIN

Expand Down
1 change: 1 addition & 0 deletions source/MaterialXGenGlsl/VkShaderGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <MaterialXGenGlsl/VkShaderGenerator.h>
#include <MaterialXGenGlsl/VkSyntax.h>
#include <MaterialXGenHw/HwConstants.h>

MATERIALX_NAMESPACE_BEGIN

Expand Down
2 changes: 2 additions & 0 deletions source/MaterialXGenGlsl/WgslResourceBindingContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#include <MaterialXGenGlsl/WgslResourceBindingContext.h>

#include <MaterialXGenShader/GenContext.h>

MATERIALX_NAMESPACE_BEGIN

//
Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXGenGlsl/WgslShaderGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <MaterialXGenGlsl/WgslShaderGenerator.h>
#include <MaterialXGenGlsl/WgslSyntax.h>

#include <MaterialXGenShader/Nodes/HwImageNode.h>
#include <MaterialXGenHw/HwConstants.h>

MATERIALX_NAMESPACE_BEGIN

Expand Down
12 changes: 12 additions & 0 deletions source/MaterialXGenHw/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
file(GLOB_RECURSE materialx_source "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
file(GLOB_RECURSE materialx_headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h*")

mx_add_library(MaterialXGenHw
SOURCE_FILES
${materialx_source}
HEADER_FILES
${materialx_headers}
MTLX_MODULES
MaterialXGenShader
EXPORT_DEFINE
MATERIALX_GENHW_EXPORTS)
22 changes: 22 additions & 0 deletions source/MaterialXGenHw/Export.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// Copyright Contributors to the MaterialX Project
// SPDX-License-Identifier: Apache-2.0
//

#ifndef MATERIALX_GENHW_EXPORT_H
#define MATERIALX_GENHW_EXPORT_H

#include <MaterialXGenShader/Library.h>

/// @file
/// Macros for declaring imported and exported symbols.

#if defined(MATERIALX_GENHW_EXPORTS)
#define MX_GENHW_API MATERIALX_SYMBOL_EXPORT
#define MX_GENHW_EXTERN_TEMPLATE(...) MATERIALX_EXPORT_EXTERN_TEMPLATE(__VA_ARGS__)
#else
#define MX_GENHW_API MATERIALX_SYMBOL_IMPORT
#define MX_GENHW_EXTERN_TEMPLATE(...) MATERIALX_IMPORT_EXTERN_TEMPLATE(__VA_ARGS__)
#endif

#endif
168 changes: 168 additions & 0 deletions source/MaterialXGenHw/HwConstants.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
//
// Copyright Contributors to the MaterialX Project
// SPDX-License-Identifier: Apache-2.0
//

#include <MaterialXGenHw/HwConstants.h>
#include <MaterialXGenShader/TypeDesc.h>

MATERIALX_NAMESPACE_BEGIN

namespace HW
{

const string T_IN_POSITION = "$inPosition";
const string T_IN_NORMAL = "$inNormal";
const string T_IN_TANGENT = "$inTangent";
const string T_IN_BITANGENT = "$inBitangent";
const string T_IN_TEXCOORD = "$inTexcoord";
const string T_IN_GEOMPROP = "$inGeomprop";
const string T_IN_COLOR = "$inColor";
const string T_POSITION_WORLD = "$positionWorld";
const string T_NORMAL_WORLD = "$normalWorld";
const string T_TANGENT_WORLD = "$tangentWorld";
const string T_BITANGENT_WORLD = "$bitangentWorld";
const string T_POSITION_OBJECT = "$positionObject";
const string T_NORMAL_OBJECT = "$normalObject";
const string T_TANGENT_OBJECT = "$tangentObject";
const string T_BITANGENT_OBJECT = "$bitangentObject";
const string T_TEXCOORD = "$texcoord";
const string T_COLOR = "$color";
const string T_WORLD_MATRIX = "$worldMatrix";
const string T_WORLD_INVERSE_MATRIX = "$worldInverseMatrix";
const string T_WORLD_TRANSPOSE_MATRIX = "$worldTransposeMatrix";
const string T_WORLD_INVERSE_TRANSPOSE_MATRIX = "$worldInverseTransposeMatrix";
const string T_VIEW_MATRIX = "$viewMatrix";
const string T_VIEW_INVERSE_MATRIX = "$viewInverseMatrix";
const string T_VIEW_TRANSPOSE_MATRIX = "$viewTransposeMatrix";
const string T_VIEW_INVERSE_TRANSPOSE_MATRIX = "$viewInverseTransposeMatrix";
const string T_PROJ_MATRIX = "$projectionMatrix";
const string T_PROJ_INVERSE_MATRIX = "$projectionInverseMatrix";
const string T_PROJ_TRANSPOSE_MATRIX = "$projectionTransposeMatrix";
const string T_PROJ_INVERSE_TRANSPOSE_MATRIX = "$projectionInverseTransposeMatrix";
const string T_WORLD_VIEW_MATRIX = "$worldViewMatrix";
const string T_VIEW_PROJECTION_MATRIX = "$viewProjectionMatrix";
const string T_WORLD_VIEW_PROJECTION_MATRIX = "$worldViewProjectionMatrix";
const string T_VIEW_POSITION = "$viewPosition";
const string T_VIEW_DIRECTION = "$viewDirection";
const string T_FRAME = "$frame";
const string T_TIME = "$time";
const string T_GEOMPROP = "$geomprop";
const string T_ALPHA_THRESHOLD = "$alphaThreshold";
const string T_NUM_ACTIVE_LIGHT_SOURCES = "$numActiveLightSources";
const string T_ENV_MATRIX = "$envMatrix";
const string T_ENV_RADIANCE = "$envRadiance";
const string T_ENV_RADIANCE_SAMPLER2D = "$envRadianceSampler2D";
const string T_ENV_RADIANCE_MIPS = "$envRadianceMips";
const string T_ENV_RADIANCE_SAMPLES = "$envRadianceSamples";
const string T_ENV_IRRADIANCE = "$envIrradiance";
const string T_ENV_IRRADIANCE_SAMPLER2D = "$envIrradianceSampler2D";
const string T_TEX_SAMPLER_SAMPLER2D = "$texSamplerSampler2D";
const string T_TEX_SAMPLER_SIGNATURE = "$texSamplerSignature";
const string T_CLOSURE_DATA_CONSTRUCTOR = "$closureDataConstructor";

const string T_ENV_LIGHT_INTENSITY = "$envLightIntensity";
const string T_ENV_PREFILTER_MIP = "$envPrefilterMip";
const string T_REFRACTION_TWO_SIDED = "$refractionTwoSided";
const string T_ALBEDO_TABLE = "$albedoTable";
const string T_ALBEDO_TABLE_SIZE = "$albedoTableSize";
const string T_AMB_OCC_MAP = "$ambOccMap";
const string T_AMB_OCC_GAIN = "$ambOccGain";
const string T_SHADOW_MAP = "$shadowMap";
const string T_SHADOW_MATRIX = "$shadowMatrix";
const string T_VERTEX_DATA_INSTANCE = "$vd";
const string T_LIGHT_DATA_INSTANCE = "$lightData";

const string IN_POSITION = "i_position";
const string IN_NORMAL = "i_normal";
const string IN_TANGENT = "i_tangent";
const string IN_BITANGENT = "i_bitangent";
const string IN_TEXCOORD = "i_texcoord";
const string IN_GEOMPROP = "i_geomprop";
const string IN_COLOR = "i_color";
const string POSITION_WORLD = "positionWorld";
const string NORMAL_WORLD = "normalWorld";
const string TANGENT_WORLD = "tangentWorld";
const string BITANGENT_WORLD = "bitangentWorld";
const string POSITION_OBJECT = "positionObject";
const string NORMAL_OBJECT = "normalObject";
const string TANGENT_OBJECT = "tangentObject";
const string BITANGENT_OBJECT = "bitangentObject";
const string TEXCOORD = "texcoord";
const string COLOR = "color";
const string WORLD_MATRIX = "u_worldMatrix";
const string WORLD_INVERSE_MATRIX = "u_worldInverseMatrix";
const string WORLD_TRANSPOSE_MATRIX = "u_worldTransposeMatrix";
const string WORLD_INVERSE_TRANSPOSE_MATRIX = "u_worldInverseTransposeMatrix";
const string VIEW_MATRIX = "u_viewMatrix";
const string VIEW_INVERSE_MATRIX = "u_viewInverseMatrix";
const string VIEW_TRANSPOSE_MATRIX = "u_viewTransposeMatrix";
const string VIEW_INVERSE_TRANSPOSE_MATRIX = "u_viewInverseTransposeMatrix";
const string PROJ_MATRIX = "u_projectionMatrix";
const string PROJ_INVERSE_MATRIX = "u_projectionInverseMatrix";
const string PROJ_TRANSPOSE_MATRIX = "u_projectionTransposeMatrix";
const string PROJ_INVERSE_TRANSPOSE_MATRIX = "u_projectionInverseTransposeMatrix";
const string WORLD_VIEW_MATRIX = "u_worldViewMatrix";
const string VIEW_PROJECTION_MATRIX = "u_viewProjectionMatrix";
const string WORLD_VIEW_PROJECTION_MATRIX = "u_worldViewProjectionMatrix";
const string VIEW_POSITION = "u_viewPosition";
const string VIEW_DIRECTION = "u_viewDirection";
const string FRAME = "u_frame";
const string TIME = "u_time";
const string GEOMPROP = "u_geomprop";
const string ALPHA_THRESHOLD = "u_alphaThreshold";
const string NUM_ACTIVE_LIGHT_SOURCES = "u_numActiveLightSources";
const string ENV_MATRIX = "u_envMatrix";
const string ENV_RADIANCE = "u_envRadiance";
const string ENV_RADIANCE_SPLIT = "u_envRadiance_texture, u_envRadiance_sampler";
const string ENV_RADIANCE_SAMPLER2D = "u_envRadiance";
const string ENV_RADIANCE_SAMPLER2D_SPLIT = "sampler2D(u_envRadiance_texture, u_envRadiance_sampler)";
const string ENV_RADIANCE_MIPS = "u_envRadianceMips";
const string ENV_RADIANCE_SAMPLES = "u_envRadianceSamples";
const string ENV_IRRADIANCE = "u_envIrradiance";
const string ENV_IRRADIANCE_SPLIT = "u_envIrradiance_texture, u_envIrradiance_sampler";
const string ENV_IRRADIANCE_SAMPLER2D = "u_envIrradiance";
const string ENV_IRRADIANCE_SAMPLER2D_SPLIT = "sampler2D(u_envIradiance_texture, u_envIrradiance_sampler)";

const string TEX_SAMPLER_SAMPLER2D = "tex_sampler";
const string TEX_SAMPLER_SAMPLER2D_SPLIT = "sampler2D(tex_texture, tex_sampler)";
const string TEX_SAMPLER_SIGNATURE = "sampler2D tex_sampler";
const string TEX_SAMPLER_SIGNATURE_SPLIT = "texture2D tex_texture, sampler tex_sampler";

const string ENV_LIGHT_INTENSITY = "u_envLightIntensity";
const string ENV_PREFILTER_MIP = "u_envPrefilterMip";
const string REFRACTION_TWO_SIDED = "u_refractionTwoSided";
const string ALBEDO_TABLE = "u_albedoTable";
const string ALBEDO_TABLE_SIZE = "u_albedoTableSize";
const string AMB_OCC_MAP = "u_ambOccMap";
const string AMB_OCC_GAIN = "u_ambOccGain";
const string SHADOW_MAP = "u_shadowMap";
const string SHADOW_MATRIX = "u_shadowMatrix";
const string VERTEX_DATA_INSTANCE = "vd";
const string LIGHT_DATA_INSTANCE = "u_lightData";
const string LIGHT_DATA_MAX_LIGHT_SOURCES = "MAX_LIGHT_SOURCES";

const string VERTEX_INPUTS = "VertexInputs";
const string VERTEX_DATA = "VertexData";
const string PRIVATE_UNIFORMS = "PrivateUniforms";
const string PUBLIC_UNIFORMS = "PublicUniforms";
const string LIGHT_DATA = "LightData";
const string PIXEL_OUTPUTS = "PixelOutputs";
const string DIR_N = "N";
const string CLOSURE_DATA_TYPE = "ClosureData";
const string CLOSURE_DATA_ARG = "closureData";
const string DIR_L = "L";
const string DIR_V = "V";
const string WORLD_POSITION = "P";
const string OCCLUSION = "occlusion";
const string CLOSURE_DATA_CONSTRUCTOR = "ClosureData(closureType, L, V, N, P, occlusion)";
const string ATTR_TRANSPARENT = "transparent";
const string USER_DATA_CLOSURE_CONTEXT = "udcc";
const string USER_DATA_LIGHT_SHADERS = "udls";
const string USER_DATA_BINDING_CONTEXT = "udbinding";

const TypeDesc ClosureDataType = TypeDesc("ClosureData", TypeDesc::BASETYPE_NONE, TypeDesc::SEMANTIC_NONE, 1, 0);
} // namespace HW


MATERIALX_NAMESPACE_END
Loading