|
The Vish Visualization Shell 0.3
Vish
|
A helper class to create a shader program from either intrinsic code, or external files, as given under the specified name in Programmable::CompileShader(). More...
#include <ocean/Anemonia/Programmable.hpp>
Classes | |
| struct | ShaderPrefix |
| struct | ShaderSegment |
Public Types | |
| typedef RenderBasin::Program | Program |
| Shortcut typedef. | |
Public Member Functions | |
| RefPtr< RenderBasin::Program > | CompileShader (VRenderContext &Context, const std::string &Name, const RenderBasin::Program::Setup &SetupFunction=nullptr, const RefPtr< RenderBasin::Program > &ExistingProgram=NullPtr(), const glsl &LocalVertexShaderPrefixCode="", const glsl &LocalGeometryShaderPrefixCode="", const glsl &LocalFragmentShaderPrefixCode="") const |
| Compile the shader into an OpenGL Program. | |
| void | enableViewportArray (bool EnableFragmentLayerViewport=true) |
| virtual glsl | fragment_shader (VRenderContext &Context) const =0 |
| Vertexshader GLGS code. | |
| virtual glsl | geometry_shader (VRenderContext &Context) const |
| Geometry GLGS code, not used here, only in subclass ProgrammableGeometry . | |
| virtual glsl | GeometryShaderPrefix (VRenderContext &Context) const |
| Optional context-dependent prefix shader code. | |
| std::pair< glsl, string > | getCode (VRenderContext &Context, const std::string &Name, const std::string &Ext, std::string(Programmable::*shader)(VRenderContext &Context) const, const string &PrefixCode) const |
| Return the combination of GLSL source code and the filename from which it was read. | |
| void | setGLSLVersion (const string &v_version, const string &g_version, const string &f_version) |
| Set the version number string, e.g. | |
| void | setGLSLVersion (const string &version) |
| Set the version number string, e.g. | |
| virtual glsl | vertex_shader (VRenderContext &Context) const =0 |
| Vertexshader GLGS code. | |
Static Public Member Functions | |
| static string | OptionalFileRead (const string &filename, const string &text) |
| Read some string from the given file, using the given text as default if no such file exists. | |
| static glsl | setNumberOfLightSources (VRenderContext &Context, const std::string &VariableName="lightNum") |
| Produce GLSL code including the number of light sources that are currently active in the render context. | |
Public Attributes | |
| glsl | f_prefix |
| Optional shader code to be always prefixed in the fragment shader. | |
| glsl | g_prefix |
| Optional static shader code to be always prefixed in the geometry shader. | |
| RenderBasin::GeometryInputType | GeometryInput |
| Input type for geometry shaders. | |
| RenderBasin::GeometryOutputType | GeometryOutput |
| Output type for geometry shaders. | |
| glsl | v_prefix |
| Optional shader code to be always prefixed in the vertex shader. | |
A helper class to create a shader program from either intrinsic code, or external files, as given under the specified name in Programmable::CompileShader().
If no files exist, then the virtual functions are called. If files exist, they are read in and their content used instead. If files exist but have zero length, then they will be overwritten and the internal code will be inserted into them.
| void Wizt::Programmable::enableViewportArray | ( | bool | EnableFragmentLayerViewport = true | ) |
During construction, i.e. after calling setGLSLVersion(),
calling this function will enable the
<A HREF="https://registry.khronos.org/OpenGL/extensions/ARB/ARB_viewport_array.txt">
viewport arrays extension
</A> and optionally also
<A HREF="https://registry.khronos.org/OpenGL/extensions/ARB/ARB_fragment_layer_viewport.txt">
fragment layer support
</A>.
If enabled, the geometry shader (required) must write to the variable
\b gl_ViewportIndex to specify which viewport to address for the next
primitive. Note that its \b max_vertices specification must be multiplied
accordingly by the maximum number of viewports, e.g. 16 as supported by
OpenGL.
With the fragment layer extension, the \b gl_ViewportIndex also becomes available
in the fragment shader as a read-only input directive.
The rendering infrastructure provides two global variables that designate the
range of viewports as enabled by the user interface:
@code
uniform int vish_MinViewportIndex = 0; uniform int vish_MaxViewportIndex = 1; The macro vish_for_Viewport(i) may be used to iterate over all enabled viewports in the geometry shader, the macro vish_ViewportValue01(i) computes a float value in the range from 0.0 to 1.0 depending on the viewport for use in the geometry shader. Equivalently, the function vish_ViewportValue01() provides such a scaled floating point value in the fragment shader (without argument, for the respective gl_ViewportIndex that is available in the fragment shader).
|
static |
Read some string from the given file, using the given text as default if no such file exists.
If a file of the given name exists and contains nothing more than a question mark, then the file will be created using that default text.
| void Wizt::Programmable::setGLSLVersion | ( | const string & | v_version, |
| const string & | g_version, | ||
| const string & | f_version | ||
| ) |
Set the version number string, e.g.
"130", on for the various shaders. This function will overwrite all existing values of the shader prefixes. Appending values after calling this function is an option.
| void Wizt::Programmable::setGLSLVersion | ( | const string & | version | ) |
Set the version number string, e.g.
"130", on all shader prefixes. This function will overwrite all existing values of the shader prefixes. If shader version numbers need to be different, or special enable flags are to be set, then call the alternative functions with multiple arguments. Appending values after calling this function is an option.
|
static |
Produce GLSL code including the number of light sources that are currently active in the render context.
This call will define an integer constant such as:
| glsl Wizt::Programmable::g_prefix |
Optional static shader code to be always prefixed in the geometry shader.
The default code sets the version to 120 and enables geometry shader
Referenced by Wizt::ProgrammableGeometry::CompileGeometryShader().
| glsl Wizt::Programmable::v_prefix |
Optional shader code to be always prefixed in the vertex shader.
For instance, the version setting may go here.
Referenced by Wizt::ProgrammableGeometry::CompileGeometryShader().