Engine parameters examples
Texture parameters
Substance 3D Painter uses a Sparse Virtual Texture (SVT) system to display textures in the viewport.
For more information about this system, go to the online documentation.
This system has repercussions on how to write shader code. We are providing helpers to simplify its use with the SamplerSparse
structure and
texture lookup functions (see lib-sparse.glsl).
Basic usage:
Copied to your clipboard// Defines the SamplerSparse structureimport lib-sparse.glsl//: param auto TEXTURE_TAGuniform SamplerSparse uniform_tex; // Texture sampler and its information
Texture parameters allow to use 'or' operator to define a fallback:
Copied to your clipboard//: param auto TEXTURE_TAG_1 or TEXTURE_TAG_2uniform SamplerSparse uniform_tex; // if TEXTURE_TAG_1 exists then TEXTURE_TAG_1 else TEXTURE_TAG_2
Where TEXTURE_TAG
is one of the described tags below.
Document's channels tags
All these textures are premultiplied and dilated to avoid seams problems.
Texture set channels
channel_ambientocclusion
channel_anisotropyangle
channel_anisotropylevel
channel_basecolor
channel_blendingmask
channel_diffuse
channel_displacement
channel_emissive
channel_glossiness
channel_height
channel_ior
channel_metallic
channel_normal
channel_opacity
channel_reflection
channel_roughness
channel_scattering
channel_specular
channel_specularlevel
channel_transmissive
User channels
channel_user0
channel_user1
channel_user2
channel_user3
channel_user4
channel_user5
channel_user6
channel_user7
Mesh maps
texture_ambientocclusion
: Ambient Occlusion map
texture_curvature
: Curvature map
texture_id
: ID map
texture_normal
: Tangent space normal map
texture_normal_ws
: World space normal map
texture_position
: World space position map
texture_thickness
: Thickness map
texture_height
: Height map
texture_bent_normals
: Bent normals map
texture_opacity
: Opacity map
Additional texture parameters
Basic usage:
Copied to your clipboard//: param auto TEXTURE_TAGuniform sampler2D uniform_tex; // The texture itself//: param auto TEXTURE_TAG_sizeuniform vec4 uniform_tex_size; // The size of the texture (width, height, 1/width, 1/height)
Texture parameters allow to use 'or' operator to define a fallback:
Copied to your clipboard//: param auto TEXTURE_TAG_1 or TEXTURE_TAG_2uniform sampler2D uniform_tex; // if TEXTURE_TAG_1 exists then TEXTURE_TAG_1 else TEXTURE_TAG_2//: param auto TEX_TAG_1_size or TEX_TAG_2_sizeuniform vec4 uniform_tex_size; // if TEX_TAG_1 exists then TEX_TAG_1_size else TEX_TAG_2_size
Where TEXTURE_TAG
is one of the described tags below.
texture_blue_noise
: A blue noise texture
texture_environment
: Environment map, mip-mapped, use lib-env.glsl to use this one
Other parameters
aspect_ratio
: a float
containing the viewport width / height
ratio
Copied to your clipboard//: param auto aspect_ratiouniform float uniform_aspect_ratio;
camera_view_matrix
: a mat4
representing the transformation from world space to camera space
Copied to your clipboard//: param auto camera_view_matrixuniform mat4 uniform_camera_view_matrix;
camera_view_matrix_it
: inverse transpose version of camera_view_matrix
Copied to your clipboard//: param auto camera_view_matrix_ituniform mat4 uniform_camera_view_matrix_it;
camera_vp_matrix_inverse
: inverse of projection * camera_view_matrix
matrix
Copied to your clipboard//: param auto camera_vp_matrix_inverseuniform mat4 uniform_camera_vp_matrix_inverse;
environment_exposure
: a float
representing the envmap's exposure
Copied to your clipboard//: param auto environment_exposureuniform float uniform_environment_exposure;
environment_max_lod
: a float
representing the envmap's depth of mip-map pyramid
Copied to your clipboard//: param auto environment_max_loduniform float uniform_max_lod;
environment_matrix
: a mat3
representing the transformation from world space vector to environment map direction
Copied to your clipboard//: param auto environment_matrixuniform mat3 uniform_environment_matrix;
facing
: an integer
indicating rendered faces (-1: back faces, 0: undefined, 1: front faces)
value of 0 means you can safely rely on glsl built-in variable gl_FrontFacing
Copied to your clipboard//: param auto facinguniform int uniform_facing;
fovy
: a float
representing the camera field of view along Y axis
Copied to your clipboard//: param auto fovyuniform float uniform_fovy;
is_2d_view
: a bool
indicating whether the rendering is performed for 2D view or not
Copied to your clipboard//: param auto is_2d_viewuniform bool uniform_2d_view;
is_perspective_projection
: a bool
indicating whether the projection is perspective or orthographic
Copied to your clipboard//: param auto is_perspective_projectionuniform bool uniform_perspective_projection;
main_light
: a vec4
indicating the position of the main light in the environment
Copied to your clipboard//: param auto main_lightuniform vec4 uniform_main_light;
mvp_matrix
: a mat4
representing the model view projection matrix
Copied to your clipboard//: param auto mvp_matrixuniform mat4 uniform_mvp_matrix;
scene_original_radius
: a float
representing the radius of the scene's bounding sphere before its normalization
Copied to your clipboard//: param auto scene_original_radiusuniform float uniform_scene_original_radius;
screen_size
: a vec4
containing screen size data (width, height, 1/width, 1/height)
Copied to your clipboard//: param auto screen_sizeuniform vec4 uniform_screen_size;
world_camera_direction
: a vec3
representing the world camera orientation
Copied to your clipboard//: param auto world_camera_directionuniform vec3 uniform_world_camera_direction;
world_eye_position
: a vec3
representing the world eye position
Copied to your clipboard//: param auto world_eye_positionuniform vec3 uniform_world_eye_position;