Super Dynamic Lighting Shader
Last updated
Last updated
This is an advanced version of the Dynamic Lighting Shader.
Additional features:
Supported Texture channels and their transformations: diffuse, transparency, specular, reflection, displacement, and normal map
Support for shadow maps from infinite and spot affected lights
Selection of Lambert or Oren-Nayar shading for diffuse
Options for specular reflectivity: Phong, Anisotropic and Cook Torrance
Rim lighting
Vertex displacement
Reflection spherical texturing
Support for a second UV set with assigned LightMap textures per model
MatCap diffuse shading
Support for global ambient and fog settings
To get access to a wider list of texture channels, you have to put checkbox "Advanced Mode" in the material layout
The shader is taking in a count texture transformation as well for channels: diffuse, transparency, displacement, specular, reflect and normal map.
Reload Shaders
Action
a development button, to trigger an internal glsl shaders reload
Use Scene Lights
boolean
switch between global list of scene lights and local list of affected lights in the shader
AffectingLights
List of lights
defines which lights should be used for the shader. That the option required for the shadow mapping
Transparency
Enum alpha mode
defines a more of transparency
TransparencyFactor
Number
multiplier of transparency
Shadows
boolean
a toggle to use shadow maps
ShadowMapSize
Number
defines a map of shadow map. It's prefered to have it power of two (1024, 2048, 4096)
ShadowCasters
List of models
list of models to be used as shadow casters. That is a requirement for the shadow mapping.
Offset Factor
Number
for shadow map rendering, multiplies the max depth slope of the polygon
Offset Units
Number
fr shadow map rendering, a fixed const offset in depth units for all polygons
Switch Albedo to sRGB
Boolean
switch between sRGB and linear color space, a gamma correction for used material textures
Force Update Textures
Boolean
update on gpu for the used material textures every frame
Use Rim Lighting
Boolean
emulation of back lighting
Rim Power
Number
back lighting power
Rim Color
Color
back lighting color
Use MatCap
Boolean
use a Material Capture texture, see a correspondent section in the documentation
MatCap
texture object reference
a reference to a texture object
The selection is defined by a material custom property (see a custom properties section)
Supported diffuse shading:
Lambert
Oren-Nayar (more diffused light destribution, better fit for a character skin surface)
Supported specular reflections:
Phong (material like plastic)
Anisotropic (material like brushed metal)
Cook Torrance (with a given specular map where R channel describes the roughness, it's a good fit for a skin surface specular reflections)
Shadows are implemented as projected textured shadow maps. Shadows will be rendered only from infinite and spot lights which are defined in Affected Lights properties of the shader.
Shadows will be rendered only for models defined in the Casters property list of a shader.
Defined list of affected lights and list of caster models is a requirement for shadows
Super dynamic lighting has support for unlimited number of lights (depends on your hardware capabilities, I would recommend to avoid having more than 32). The same for shadow mapping, it goes as a texture array and will try to allocate and render as many shadows as it was required.
On a shader side we have parameters
Shadows - to toggle shadow mapping for the shader instance
Shadow Size - by default 2k, the size of shadow textures (better to use a size of a power of two like 1024, 2048, 4096)
Offset Factor - offset to a polygon in a current view based on its slope
Offset Units - global const offset in depth units
Each light has "cast shadows" flag to toggle shadow casting individually.
Each model has flags for Casts Shadows and Receive Shadows which are connected to a correspondent logic inside the shader.
Infinite light shadow uses the whole scene bounding box as a default frustum area to render into a shadow map. With a big complex scene that could lead to a shadow quality degradation.
There is a way to define a custom bounding box for a shadow rendering. To do so you have to define an object or set of objects which bounding box you would like to use.
Then attach these objects into a "Shadow Bounding Box" custom light property
Diffuse Type where 0 - Lambert, and 1 - Oren-Nayar
Specular Type where 0 - Phong, 1 - Anisotropic and 2 - Cook Torrance
RoughnessX and RoughnessY - properties or specular distribution for the anisotropic specular
Magnitude - Number, defines the light influence radius
Cast Specular On Object - bool, defines either light have to contribute to a specular term
Shadow Bounding Box - list of objects, to define a custom bounding box area for an infinite frustum when we do render objects into a shadow map
There is a script ScriptCreateLightAndMaterialProperties.py in OpenMobu/PythonScripts/Actions/SuperDynamicLightingShader
The script will help to create needed custom properties for selected light or material models.
When shader transparency is defined, then blend mode based on alpha channel source is enabled in opengl
In additional shader could do a fragment discard on alpha less than 0.5. That could be useful for a depth information masking for ambient occlusion.
Material ambient color is used in combination with a defined global ambient color. In case you have black global ambient color, there will be no effect from the material ambient
Fog in global light settings also has an influence on the shading, so you can use it with Super Dynamic Lighting shader.
MatCap (short for "Material Capture") is a shading technique commonly used in 3D rendering to create fast and visually appealing materials by mapping lighting and material properties directly from a texture.
In order to use MatCap shading you have to import such matcap image and assign it as input for MatCap texture in the shader properties. Plus you have to put "Use MatCap" property to true.