Creation of customized shaders in the Shader Forge
The Shader Forge has its own editor to create shaders. The shaders must be written in HLSL and must meet the
SAS requirements (Microsoft Standard Annotations and Semantics), to allow a direct link between the shaders parameters and the NOVA properties of the current scene.
The compilation of a shader may cause some errors which are then displayed in the log window of the Shader Forge. By clicking twice on the errors message, the cursor of the Shader Forge will automatically be moved to the involved codeline.
Annotations and Semantics supported¶
NOVA supports the
SAS requirements. Annotations and semantics are different according to the shader type (material or post-process):
Supported Annotations and Semantics for material shader¶
These semantics are managed at the matrix level :
- PROJECTION, PROJ : standard projection matrix
- VIEW : standard view matrix
- WORLD : world matrix of the current objet
- WORLDVIEWPROJECTION, WORLDVIEWPROJ : world matrix * view matrix * projection matrix
- WORLDVIEW : world matrix * view matrix
- WORLDCAMERAPOSITION : vector of position of the camera
The semantics of the matrix can be completed with the following suffix:
- I, INVERSE : inversion of the matrix
- T, TRANSPOSE : transposition of the matrix
The parameters of a shader may be completed with the following semantics:
- AMBIENT: affects the ambient value of the scene to the parameter
- TIME: affects the time counter value (in milliseconds) of the scene to the parameter
- DIFFUSE: the parameter can be handled by a ColorPicker
- NOVA : the parameter is on True to indicate that Nova is the current rendering engine
- NOVAMAJORVERSION: the parameter will receve the major version of Nova (ie 6)
- NOVAMINORVERSION: the parameter will receve the minor version of Nova (ie 0)
The textures can be completed with the following annotations to obtain specific behaviours:
Function : defines the HLSL function of the shader to generate the contents of the texture (parametric texture)
Width, Height, Depth : defines the size of the texture (parametric texture)
Dimensions : defines a vector with the size of the texture (parametric texture)
Type : defines the type of the parametric texture (2D, 3D, volume)
Format : defines the parametric texture format
Name : defines the name of the file containing the texture to load (non-parametric texture)
To link the properties of the entities of the scene (camera, time and lights), the annotations SasBindAddress.* are supported as well as the following :
- Object : allows to connect the parameter to the light properties of a light of a defined type (DIRECTIONALLIGHT, POINTLIGHT, SPOTLIGHT)
- refID : gives the unique ordering number ID for a light in the scene
- LightRef : gives the ordering number ID for a light in the scene
The following semantics are managed for the light entities :
POSITION : affects the parameter on the light's position
LIGHTCOLOR : affects the parameter on the targeted light's colour
A HLSL shader may contain several rendering methods. NOVA will select automatically the first "hardware compliant" method working with the current material. It is easy, from the shader properties window, to switch to another rendering method if necessary.
The following annotations allow to tweak the rendering targets of a shader in order to allow several rendering passes. These annotations are available on the pass level of every rendering technique :
- rendercolortarget0 : defines the target of the actual pass. The target must be a texture, declared before in the shader, or an empty value (which indicates a drawing on the display buffer)
- draw : defines if the actual pass draws the geometry or a quad drawn all over the screen (buffer)
- clear : defines if NOVA must clear the working buffer before the drawing of the current pass (colour, depth, stencil)
Supported Annotations and Semantics for post-process shader¶
A post-process shader supports the
SCREENSIZE annotation.
Associated to a float2, SCREENSIZE represents the rendering texture size in the post-process shader entry (texture available in the first sampler of the shader). The first float is for the length, the second for the width.
Annotations and Semantics commonly supported by material and post-process shaders¶
The following annotations allow to manage an automatic interface in the properties of the shader within the
Entities Browser.
- UIName, UIWidget, UIType, SasUiControl : defines the graphic controller associated to the parameter (COLOR, COLORPICKER, MAXSWATCH, SLIDER, FLOATSPINNER, INTSPINNER, MAXSPINNER, FILEPICKER, NUMERIC)
- UIName, SasUiLabel : defines the label of the associated controller
- UIMin, SasUiMin : defines the min value of the property (only for SLIDER and SPINNER controls)
- UIMax, SasUiMax : defines the maximum value for the property (only for SLIDER and SPINNER controls)
- UIStep, SasUiSteps : defines the variation step of the property (only for SLIDER and SPINNER controls)
Affect a material shader to an object
To affect a shader to an object, you must first select that entity. If the object is pickable, (
Pickable object's property on True), you only have to select it in the viewport (CTRL+Click). If not, via the
Entities Browser, it is possible to select an object with the contextual menu. Then, select the material containing the shader (created automatically by the
Shader Forge) and simply click on
Affect, in its contextual menu.
 Material shader affected to an object |
Affect a post-process shader to a camera
To affect a post-process shader to a camera, you must first select the material of the shader (created automatically by the
Shader Forge) and then call the
Assign as PostProcess to proporty of its contextual menu.
 Post-process shader affected to a camera |