See exampleCustomShaders for an example of how to modify the VR-Vantage shaders.
8.7.1 OsgEarth Virtual Programs
VR-Forces takes advantage of the osgEarth framework for shader composition called virtual programs. These virtual programs allow multiple libraries to contribute to a shader program without needing to have the full program available and even apply the same shader function to multiple programs. OsgEarth has in-depth documentation here: http://docs.osgearth.org/en/latest/developer/shader_composition.html
8.7.2 Global Shader Variables
VR-Forces shaders use global variables to pass information between virtual program functions. Here is a list of some important globals you may want to use, what they are used for, and when you can modify them. All of these globals are only available in the fragment shader.
-
vec3 vrv_gNormalViewSpace. Normal at the fragment in view space. It is used for calculating the lighting and reflections. This global is set in the Coloring stage at priority 4.0 and is used in the lighting stage at priority 2.0.
-
float vrv_gAmbientMultiplier. Multiplier for the ambient light. It is used for ambient occlusion and is set in the coloring stage at priority 3.0 and used in the lighting stage at lighting priority 2.0.
-
vec4 vrv_gSpecularMultiplier. Multiplier for the specular light intensity. It is used for scaling the specular lighting and is set in the coloring stage at priority 4.0 and used in the lighting stage at lighting priority 2.0.
-
float vrv_gSpecularExponent. Multiplier for the shininess intensity. It is used for scaling the specular lighting’s shininess exponent and is set in the coloring stage at priority 4.0 and used in the lighting stage at lighting priority 2.0.
-
vec4 vrv_gEmission. Multiplier for the emissive lighting component. The Alpha component is an additional multiplier that only affects the scene when HDR is turned on. It is set in the coloring stage at priority 4.0 and used in the lighting stage at priority 2.0.
-
float vrv_gShadowFactor. Multiplier for the shadow factor. Set to 0.0 for the object to be entirely in shadow and set to 1.0 for the object to be entirely out of shadow. It is set in the lighting stage at priority -25.0 and used in the lighting stage at priority 2.0.
-
vec4 vrv_gDiffuseColor. Multiplier for the color of the diffuse light. It is used to control the color of the diffuse light and is set in the coloring stage at priority 2.0 and used in the lighting stage at priorty 2.0.
-
vec4 vrv_gAmbientColor. Multiplier for the color of the ambient light. It is used to control the color of the ambient light and is set in the coloring stage at priority 2.0 and used in the lighting stage at priorty 2.0.
8.7.3 Shader Variants
Variants are used to pass data between the vertex shader and the fragment shader. The following list describes some important variants used by the VR-Vantage shaders, when they are set, and when they are used:
-
vrv_vInstanceUserData. Contains the user data value for an instanced model. The data can be anything that needs to be set on a per model instance basis. This is set using DtInstanceManager::setUserDefined(). The value is already used by SensorFX so it should not be changed when using the SensorFX plugin. This value is set in the vertex shader view stage at priority 2.0 and unused in the regular VR-Vantage shaders.
-
vrv_vVertex_Projection_Space. This is the vertex position in projected space. It is set in the vertex view stage at priority 2.0 and used in the fragment lighting stage at priority 2.0.
-
vrv_vVertex_View_Space. This is the vertex position in vew space. It is set in the vertex view stage at priority 2.0 and used in the fragment lighting stage at priority 2.0.
[<< Example of Transforming Nodes Programmatically] [Home] [Top of Page]