|
The Vish Visualization Shell 0.3
Vish
|
Base class for abstract render operations. More...
#include <ocean/Anemonia/RenderBasin.hpp>
Classes | |
| class | Buffer |
| Encapsulation of buffer objects. More... | |
| class | ComputationDispatcher |
| Base class for compute shader executions. More... | |
| struct | FloatedOrigin |
| Support for FloatingOrigin (class FloatOrigin ). More... | |
| class | Illumination |
| A render tentacle that activates all light sources that are defined through shader code. More... | |
| struct | MapMemory |
| class | Painter |
| Base class for paint operations. More... | |
| class | Program |
| Base class for abstract shader/render programs. More... | |
| class | RangedPainter |
| Intermediate class for painters that may cover just a subset of the entire domain. More... | |
| class | RenderFlag |
| Base class for render flags. More... | |
| class | RenderParameter |
| Base class for render parameters, which are Anemone::Tentacle instances that implement an updateValue() function via a provided functor to be invoked by Anemone::updateValues() . More... | |
| class | RenderTimer |
| Base class for render timers. More... | |
| struct | ShaderProgram |
| Helper struct for alternative call to createProgram() with better uniqueness of arguments. More... | |
| class | StorageBufferTentacle |
| Storage buffer objects. More... | |
| struct | TextureStorageFormat |
| Enum for the storage type of the texture, which will affect memory utilization on the GPU. More... | |
| class | TextureTentacle |
| Base class for textures, child classes are implemented by Renderers. More... | |
| struct | TypedRenderParameter |
| Helper class for implementations of render parameters that operate on one specific type. More... | |
| class | UniformParameter |
| Base class for uniform variables in programs. More... | |
| class | VertexAttribute |
| A Vertex Attribute is a set of data which sits available on each vertex of some rendering. More... | |
Public Types | |
| using | RPtr = MemCore::RefPtr< RenderParameter > |
| Convenience Shortcut. | |
Public Types inherited from Wizt::RenderNamespace | |
| using | AnyUniform = std::variant< int, float, double, unsigned, Eagle::FixedArray< int, 2 >, Eagle::FixedArray< float, 2 >, Eagle::FixedArray< double, 2 >, Eagle::FixedArray< int, 3 >, crd3f, Eagle::FixedArray< float, 3 >, crd3d, Eagle::FixedArray< double, 3 >, Eagle::FixedArray< int, 4 >, Eagle::FixedArray< float, 4 >, Eagle::FixedArray< double, 4 >, Eagle::Quadratic< 2, float >, Eagle::Quadratic< 3, float >, Eagle::Quadratic< 4, float >, vec3f_vector, crd3f_vector > |
| A variant that may carry all currently supported data types that can be used as a uniform variable in a GLSL shader. | |
| enum | GeometryInputType |
| Input type for geometry shaders. | |
| enum | GeometryOutputType |
| Output type for geometry shader. | |
| using | glsl = std::string |
| An alias name for strings such that the return value of functions providing GLSL code can be spotted easier. | |
| enum | Primitive { POINTS , LINE_STRIP , LINE_LOOP , LINES , TRIANGLE_STRIP , TRIANGLE_FAN , TRIANGLES , QUAD_STRIP , QUADS , POLYGON , LINES_ADJACENCY , TRIANGLES_ADJACENCY , LINE_STRIP_ADJACENCY , TRIANGLE_STRIP_ADJACENCY } |
| Enumeration type for primitives, similar to OpenGL (but numerically not identical). More... | |
| enum | TextureFormat |
| Enum for the type of texture to be used, implying the number of color channels and their meaning. | |
| enum | VertexAttributeTypes { COORDINATES , NORMALS , COLORS , SECONDARY_COLORS , TEXTURE0 , TEXTURE1 , USER_DEFINED } |
| Categories of vertex attributes for OpenGL default shader attributes, to be used in conjunction with RenderBasin::AttributeNames() and RenderBasin::createVertexAttribute(). More... | |
Public Member Functions | |
| RefPtr< StorageBufferTentacle > | bindStorageBuffer (Anemone &A, const char *BufferName, const void *theStorageData, size_t N, Buffer::StorageFlags={}) const |
| Create a storage buffer from the given data and bind it to all shader programs that are found at the given Anemone under the same buffer name. | |
| MemCore::RefPtr< VertexAttribute > | createCoordinates (const MemCore::RefPtr< MemCore::ChunkBase > &VertexData) |
| Convenience function to load coordinates as vertex attribute. | |
| MemCore::RefPtr< Program > | createGeometryProgram (const ShaderProgram &VertexShader, GeometryInputType geom_in, const ShaderProgram &GeometryShader, GeometryOutputType geom_out, const ShaderProgram &FragmentShader, const RenderBasin::Program::Setup &SetupFunction=nullptr, const MemCore::RefPtr< RenderBasin::Program > &ExistingProgram=nullptr) |
| Create a shader program using a geometry shader. | |
| MemCore::RefPtr< Program > | createGeometryProgram (const std::string &VertexShader, GeometryInputType, const std::string &GeometryShader, GeometryOutputType, const std::string &FragmentShader, const std::string &VertexShaderURL, const std::string &GeometryShaderURL, const std::string &FragmentShaderURL, const RenderBasin::Program::Setup &SetupFunction=nullptr, const MemCore::RefPtr< RenderBasin::Program > &ExistingProgram=nullptr) |
| Create a shader program using a geometry shader. | |
| virtual MemCore::RefPtr< Program > | createGeometryProgram (const std::vector< std::string > &VertexShader, const std::string &VertexShaderURL, unsigned VertexShaderLineNumber, GeometryInputType, const std::vector< std::string > &GeometryShader, GeometryOutputType, const std::string &GeometryShaderURL, unsigned GeometryShaderLineNumber, const std::vector< std::string > &FragmentShader, const std::string &FragmentShaderURL, unsigned FragmentShaderLineNumber, const RenderBasin::Program::Setup &SetupFunction=nullptr, const MemCore::RefPtr< RenderBasin::Program > &ExistingProgram=nullptr)=0 |
| Virtual function to create a shader program, possibly using a geometry shader. | |
| virtual MemCore::RefPtr< ElementAttribute > | createIndexBuffer (const MemCore::RefPtr< MemCore::ChunkBase > &ElementData)=0 |
| Create an index buffer containing the element indices. | |
| MemCore::RefPtr< Program > | createProgram (const glsl &VertexShader, const glsl &FragmentShader, const std::string &VertexShaderURL, const std::string &FragmentShaderURL, unsigned VertexShaderLineNumber=0, unsigned FragmentShaderLineNumber=0, const RenderBasin::Program::Setup &SetupFunction=nullptr, const MemCore::RefPtr< RenderBasin::Program > &ExistingProgram=nullptr) |
| Create a shader program from GLGS source code constructed from a vertex and fragment shader. | |
| MemCore::RefPtr< Program > | createProgram (const ShaderProgram &VertexShader, const ShaderProgram &FragmentShader, const RenderBasin::Program::Setup &SetupFunction=nullptr, const MemCore::RefPtr< RenderBasin::Program > &ExistingProgram=nullptr) |
| Create a program from vertex and fragment shader. | |
| template<class Lambda > | |
| RPtr | createRenderLambda (const std::string &what, VRenderContext &Context, const Lambda &theLambda) |
| virtual RPtr | createRenderParameter (const glsl &, const void *data, const std::type_info &type, int Multiplicity)=0 |
| Create a generic rendering parameter. | |
| template<class Type > | |
| RPtr | createRenderParameter (const std::string &what, const Type &Data) |
| Set variable of a given type, making use of the available META::MetaInfo<> type trait template. | |
| template<class SlotType , class ShaderType > | |
| RPtr | createRenderParameterWithStdFunctor (const glsl &what, const TypedSlot< SlotType > &InputSlot, const SlotType &SlotDefaultValue, const ShaderType &ShaderDefaultValue, const std::function< ShaderType(const VRenderContext &Context, const SlotType &SlotValue)> &theFunctor) |
| A more or less internal helper function that takes a std::function object for coupling a TypedSlot to a shader parameter, intended to be used by createRenderSlotWithFunctor() with a lambda function. | |
| template<class Type > | |
| RPtr | createRenderSlot (const std::string &what, const TypedSlot< Type > &InputSlot, const Type &DefaultValue, const WeakPtr< ValuePool > &Context) |
| Create a render parameter that will be connected to a given TypedSlot such that a dependency is considered and Anemone::updateValues() handles this input slot. | |
| template<typename F > requires RenderLambda<F> | |
| auto | createRenderSlotWithFunctor (const glsl &what, const TypedSlot< typename render_lambda_signature< F >::slot_type > &InputSlot, F &&theFunctor) |
| Couple a VObject's input slot to a render parameter, in particular uniform shader variables, according to createRenderParameter(); Synopsis: | |
| MemCore::RefPtr< VertexAttribute > | createStdVertexAttribute (const MemCore::RefPtr< MemCore::ChunkBase > &VertexData, VertexAttributeTypes Type) |
| Convenience function to load coordinates as vertex attribute that is known as fixed standard attribute in older OpenGL (discouraged, modern OpenGL and shader code should use entirely user-defined names). | |
| virtual RefPtr< StorageBufferTentacle > | createStorageBuffer (const void *theStorageData, size_t N, Buffer::StorageFlags={}) const =0 |
| Create a storage buffer tentacle, which is a reference to an OpenGL storage buffer. | |
| virtual RefPtr< RenderBasin::StorageBufferTentacle > | createStorageBuffer (Intercube &DataCreator, const DataCreationFunction &f, const RenderBasin::Buffer::StorageFlags Flags={}) const =0 |
| Create storage buffer of the given size with initialization from the given data creator if there is no data storage buffer associated with the specified Intercube. | |
| virtual RefPtr< RenderBasin::StorageBufferTentacle > | createStorageBuffer (Intercube &DataCreator, size_t N, const RenderBasin::Buffer::StorageFlags Flags={}) const =0 |
| Create storage buffer of the given size without initialization, but reuse an existing storage buffer if such is given at the specified Intercube. | |
| virtual MemCore::RefPtr< TextureTentacle > | createTexture (const MemCore::RefPtr< MemCore::ChunkBase > &TextureData, TextureFormat TF, int rank, const size_t *Dimensions, int TextureUnit=0, TextureStorageFormat TSF=AutomaticTexture(), int level=0, bool GenerateDoMipMap=false, const MemCore::RefPtr< TextureTentacle > &OldTT=nullptr)=0 |
| Application call to the Render Context to create a Texture. | |
| virtual MemCore::RefPtr< Attribute > | createTextureBuffer (const MemCore::RefPtr< MemCore::ChunkBase > &TextureData, int textureUnit=0, bool doNormalize=false, int AttributeClass=0, int MaxBitStorage=0)=0 |
| Create a texture buffer, which are basically 1D arrays of data that can be accessed randomly in OpenGL. | |
| MemCore::RefPtr< VertexAttribute > | createTextureCoordinates (const MemCore::RefPtr< MemCore::ChunkBase > &TextureCoordData, int TextureUnit=0) |
| Convenience function to load texture coordinates as vertex attribute. | |
| virtual MemCore::RefPtr< VertexAttribute > | createVertexAttribute (const MemCore::RefPtr< MemCore::ChunkBase > &VertexData, const std::string &name)=0 |
| MemCore::RefPtr< RenderFlag > | Disable (const char *what) |
| Disable some rendering flag. | |
| virtual MemCore::RefPtr< Painter > | drawPrimitives (Primitive, size_t howmany=0)=0 |
| virtual MemCore::RefPtr< RenderFlag > | Enable (const char *what, bool Yes=true)=0 |
| Virtual OpenGL call to enable some rendering flag. | |
| RefPtr< Illumination > | getIllumination () const |
| Insert into newly created Anemone objects, for instance via feedAnemone(). | |
| WeakPtr< Interactor > | getInteractor () const |
| Get the current Interactor . | |
| glsl | getLightSourceCode () |
| See getIllumination() for details. | |
| int | getNumberOfActiveLightSources () const |
| Get the number of currently active light sources. | |
| Seagrass & | getSeagrass () const |
| Get the Seagrass caching manager that is associated with this RenderBasin. | |
| const SeagrassWeakPtr_t & | getSeagrassPtr () const |
| Get a pointer to the Seagrass caching manager that is associated with this RenderBasin. | |
| virtual std::string | getShaderPlatformDefines () const =0 |
| Create a preprocessor string containing some platform-specific definitions. | |
| bool | lightingHasChanged (const AnemoneCreatorBase &A) const |
| Check whether the lighting managed by this RenderBasin (via its Seagrass) has changed so significantly such that shaders have to be recompiled. | |
| RefPtr< Interactor > | makeInteractor () const |
| Receive the current Interactor, if one is set already, and create a new one if that is not the case. | |
| void | mergeIlluminationUniforms (Program &P) const |
| For explicit handling of shader programs merge all the uniforms defined by the current set of light sources into the given Program. | |
| static TextureStorageFormat | MultichannelTexture (int nChannels, int Bits, bool Integer=false, bool Signed=false, bool Normalized=true, bool Compressed=true) |
| static TextureStorageFormat | MultichannelTexture (int nChannels, TextureStorageFormat::BitPrecision theBits=TextureStorageFormat::Unspecified, bool Integer=false, bool Signed=false, bool Normalized=true, bool Compressed=true) |
| Create some texture matching the number of specified channels, it will be: | |
| static TextureStorageFormat | OpenGLTexture (int OpenGLTextureTypeEnum, int BitsPerTexel, bool isInteger) |
| Create a texture storage format from an OpenGL texture enum, need to specify also the number of bits per texel for purposes of opengl memory management. | |
| static TextureStorageFormat | RedGreen (TextureStorageFormat::BitPrecision theBits=TextureStorageFormat::Unspecified) |
| color channels (two) | |
| RenderBasin (const SeagrassWeakPtr_t &mySeagrass) | |
| Construct a render basin with a weak pointer to a seagrass, which is a persistent manager for handling resources related to the respective rendering implementation. | |
| static TextureStorageFormat | Rgb (TextureStorageFormat::BitPrecision theBits=TextureStorageFormat::Unspecified) |
| color channels (three channels) | |
| static TextureStorageFormat | RgbAlpha (TextureStorageFormat::BitPrecision theColorBits=TextureStorageFormat::Unspecified, TextureStorageFormat::BitPrecision theAlphaBits=TextureStorageFormat::Unspecified) |
| color and alpha (four) | |
| void | setInteractor (const WeakPtr< Interactor > &) |
| Overwrite the current Interactor. | |
Static Public Member Functions | |
| static void | mergeIlluminationUniforms (const Lighting &, Program &P) |
| Lighting management: Similar in spirit to the semantics of light sources in OpenGL 1.0, Light Source objects via shaders are global and independent from lit objects, rather than squeezed into one single shader per object that also includes light sources. | |
| static TextureStorageFormat | Red (TextureStorageFormat::BitPrecision theBits=TextureStorageFormat::Unspecified) |
| color channels (one) | |
Public Attributes | |
| int | NumberOfActiveLightSources |
| The number of currently active light sources. | |
Base class for abstract render operations.
| struct Wizt::RenderBasin::ShaderProgram |
Helper struct for alternative call to createProgram() with better uniqueness of arguments.
Use GLSL_SHADER and GLSL_SOURCE macros to define and use GLS sources Define the GLSL source like this:
and construct the Program like this:
| Wizt::RenderBasin::RenderBasin | ( | const SeagrassWeakPtr_t & | mySeagrass | ) |
Construct a render basin with a weak pointer to a seagrass, which is a persistent manager for handling resources related to the respective rendering implementation.
For instance, when rendering via OpenGL, the seagrass manager would handle OpenGL ID's and the memory associated with them.
|
inline |
Convenience function to load coordinates as vertex attribute.
Calls the generic createVertexAttribute() function.
| MemCore::RefPtr< RenderBasin::Program > Wizt::RenderBasin::createProgram | ( | const glsl & | VertexShader, |
| const glsl & | FragmentShader, | ||
| const std::string & | VertexShaderURL, | ||
| const std::string & | FragmentShaderURL, | ||
| unsigned | VertexShaderLineNumber = 0, |
||
| unsigned | FragmentShaderLineNumber = 0, |
||
| const RenderBasin::Program::Setup & | SetupFunction = nullptr, |
||
| const MemCore::RefPtr< RenderBasin::Program > & | ExistingProgram = nullptr |
||
| ) |
Create a shader program from GLGS source code constructed from a vertex and fragment shader.
This is a simplified version of createGeometryProgram();
The setup function is given maximum values as possible by the current hardware and needs to specify the actually required values for a given shader.
References createGeometryProgram().
|
inline |
Initialize a typed updater, remembering the default value.
Virtual update function, reads the typed slot relative to the context and sends it to the render parameter.
References Wizt::RenderBasin::RenderParameter::modify().
|
pure virtual |
Create a generic rendering parameter.
The implementation of this function will have some intelligence built in with respect to what each parameter means. It might just set a uniform variable in a shader, or detect that it's name is "glLineWidth" and issue a special OpenGL call.
Implemented in Wizt::WebGLRenderContext, and Wizt::VGLRenderContext.
|
inline |
Create a render parameter that will be connected to a given TypedSlot such that a dependency is considered and Anemone::updateValues() handles this input slot.
Set variable of a given type, making use of the available META::MetaInfo<> type trait template.
|
inline |
Couple a VObject's input slot to a render parameter, in particular uniform shader variables, according to createRenderParameter(); Synopsis:
Note that the return type of the function may differ from the slot type, i.e. this function may perform type conversations.
| what | The name of a shader's uniform variable, or some special name as handled by the implementation of createRenderParameter() as provided by some derived VRenderContext . |
|
inline |
Convenience function to load coordinates as vertex attribute that is known as fixed standard attribute in older OpenGL (discouraged, modern OpenGL and shader code should use entirely user-defined names).
Calls the generic createVertexAttribute() function.
|
pure virtual |
Create a storage buffer tentacle, which is a reference to an OpenGL storage buffer.
For further usage the storage buffer tentacle neds to be bound to a Program with the name under which it is used there ( bindToProgram() ), and inserted to an Anemone that handles the entity. bindStorageBuffer() is a high-level alternative that does these three steps in one call.
| theStorageData | Pointer to initial data for uploading to the GPU, can be a nullptr if none is needed. |
Implemented in Wizt::VGLRenderContext.
Referenced by bindStorageBuffer().
|
pure virtual |
Application call to the Render Context to create a Texture.
| TextureData | actual data to be loaded |
| TF | The type of the texture |
| rank | The dimensionality of the data |
| Dimensions | The extension of the data in each dimension, must match the provided TextureData |
| TextureUnit | The OpenGL texture unit in which to load these data |
| TSF | The internal storage format of the texture, affects memory utilization. |
| OldTT | An optional old texture tentacle which would be updated with the data instead of creating a new one. |
|
pure virtual |
Create a texture buffer, which are basically 1D arrays of data that can be accessed randomly in OpenGL.
These texture buffer objects do not provide 2D or 3D access with interpolation, neither do they provide on-the-fly compression on the GPU, so they occupy lots of memory of the benefit of random access from shader code.
Implemented in Wizt::VGLRenderContext.
|
inline |
Convenience function to load texture coordinates as vertex attribute.
|
pure virtual |
| name | A name to be associated with this buffer RenderBasin&myContext;
Anemone RenderAnemone;
|
Implemented in Wizt::WebGLRenderContext, and Wizt::VGLRenderContext.
|
pure virtual |
Return a painter object suitable for insertion to an Anemone. It is supposed to draw all stored Tentacles once called through Anemone::wave().
| howmany | The number of elements that will be shown. If none specified here, then all that have been loaded into the Anemone . |
Implemented in Wizt::WebGLRenderContext, and Wizt::VGLRenderContext.
|
pure virtual |
Virtual OpenGL call to enable some rendering flag.
Give some OpenGL flag as string, for instance:
instead of
Note that inclusion of OpenGL headers is not required to call this function.
Implemented in Wizt::WebGLRenderContext, and Wizt::VGLRenderContext.
|
inline |
Insert into newly created Anemone objects, for instance via feedAnemone().
The Lighting is stored at the Seagrass Cache that is associated with this RenderBasin as persistent storage location.
When constructing a new RenderAnemone, include code like this:
Use in conjunction with lightingHasChanged() to check whether shaders need to be recompiled.
The Illumination tentacle manages all global shader variables (i.e., uniforms) that are used throughout all light sources. Light sources do not compile shader code on their own; all shader code is compiled within lit objects. These lit objects have to
call a function
which implements the iteration and summation over all light sources at the given vertex, which must be known to the LightFunction in coordinates that this function understands.
For explicit manual treatment of some Program call
or
instead. Both version do the same, the first one is shorter and faster.
| WeakPtr< Interactor > Wizt::RenderBasin::getInteractor | ( | ) | const |
Get the current Interactor .
It is a weak pointer, meaning that the Interactor must be referenced by external means such as stored with in a VObject's state (the preferred method). Once the VObject dies, and thus its State, then the Interactor gets automatically removed from the Seagrass cache and thus from the RenderBasin including derived classes.
| RefPtr< Interactor > Wizt::RenderBasin::makeInteractor | ( | ) | const |
Receive the current Interactor, if one is set already, and create a new one if that is not the case.
The Interactor is set to the Seagrass Cache and is persistently available as long as it is kept alive externally via its reference pointers.
|
static |
Lighting management: Similar in spirit to the semantics of light sources in OpenGL 1.0, Light Source objects via shaders are global and independent from lit objects, rather than squeezed into one single shader per object that also includes light sources.
The RenderBasin manages a list of light sources, each one providing their own shader code fragment, and glues them together as one contiguous shader code that is then applied to each lit object.
The net effect is similar to how it was in OpenGL 1.0, but more flexible since everything is based on shaders instead of the fixed pipeline.
References Wizt::RenderNamespace::ProgramVariables::merge(), Wizt::RenderNamespace::Lighting::placeholder, and Wizt::RenderNamespace::ProgramVariables::remove().
Referenced by mergeIlluminationUniforms().
| void Wizt::RenderBasin::mergeIlluminationUniforms | ( | RenderBasin::Program & | P | ) | const |
| RenderBasin::TextureStorageFormat Wizt::RenderBasin::MultichannelTexture | ( | int | nChannels, |
| int | Bits, | ||
| bool | Integer = false, |
||
| bool | Signed = false, |
||
| bool | Normalized = true, |
||
| bool | Compressed = true |
||
| ) |
< leave to driver implementation
References Wizt::RenderBasin::TextureStorageFormat::Bit12, Wizt::RenderBasin::TextureStorageFormat::Bit16, Wizt::RenderBasin::TextureStorageFormat::Bit32, Wizt::RenderBasin::TextureStorageFormat::Bit4, Wizt::RenderBasin::TextureStorageFormat::Bit5, Wizt::RenderBasin::TextureStorageFormat::Bit8, Wizt::RenderBasin::TextureStorageFormat::Float, Wizt::RenderBasin::TextureStorageFormat::HalfFloat, MultichannelTexture(), and Wizt::RenderBasin::TextureStorageFormat::Unspecified.
| RenderBasin::TextureStorageFormat Wizt::RenderBasin::MultichannelTexture | ( | int | nChannels, |
| TextureStorageFormat::BitPrecision | theBits = TextureStorageFormat::Unspecified, |
||
| bool | Integer = false, |
||
| bool | Signed = false, |
||
| bool | Normalized = true, |
||
| bool | Compressed = true |
||
| ) |
Create some texture matching the number of specified channels, it will be:
| nChannels | The number of channels that shall be in the texture. |
References Red(), RedGreen(), Rgb(), and RgbAlpha().
Referenced by MultichannelTexture().
| int Wizt::RenderBasin::NumberOfActiveLightSources |
The number of currently active light sources.
An implementation of the virtual render() function must reset this number to zero and count the number of light sources while traversing all objects. A light source is defined as an object derived from VLightSource.
Referenced by Wizt::VGLRenderContext::render(), and Wizt::VRenderContext::VRenderContext().