VR-Engage  2.2
Loading...
Searching...
No Matches
vreOsgEffectTextureController.h
Go to the documentation of this file.
1/******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4******************************************************************************/
5
6//! \file vreOsgEffectTextureController.h
7//! \brief Defines texture effect controllers for OSG rendering in VR-Engage
8//!
9//! This file contains the DtVreOsgEffectTextureController class and related
10//! components which provide texture swapping effects for the VR-Engage
11//! visualization system. These controllers allow for special visual effects
12//! like maps, HUDs, and other texture-based overlays to be applied to the
13//! rendering pipeline.
14
15#pragma once
16
18
19#include <vrvCore/DtDe.h>
20
21#include <vrvOsg/DtOsgEffectTextureController.h>
22#include <vrvOsg/DtOsgRenderer.h>
23#include <vrvOsg/DtEffectControllerCreatorTemplate.h>
24
25namespace makVre
26{
27//! \brief Extension of DtEffectTextureType enumeration for VR-Engage effects
28//!
29//! This enumeration extends the base DtEffectTextureType with VR-Engage specific
30//! effect texture types. These types are used to identify and register different
31//! kinds of texture effects in the rendering system.
33{
34 VRE_ET_MAP = 1100, //!< Map overlay effect texture type
35 VRE_HUD_ET_MAP = 1101 //!< HUD (Heads-Up Display) map effect texture type
36};
37
38
39//! \brief Controller for texture swapping visual effects in OSG rendering
40//!
41//! DtVreOsgEffectTextureController manages texture swapping effects in the
42//! OSG rendering pipeline. Based on VR-Vantage's exampleEffectTexturePlugin,
43//! it provides the ability to dynamically apply shader-based effects to textures
44//! during rendering. This enables features like map overlays, HUD elements,
45//! and other specialized visual effects.
46class PLAYERSTATION_DLL DtVreOsgEffectTextureController : public makVrv::DtOsgEffectTextureController
47{
48public:
49 //! \brief Constructor
50 //! \param de Reference to the display engine
51 //! \param effectTextureType Type identifier for this effect texture
52 //! \param typeString String identifier for this effect type
53 //! \param postfix Suffix for shader uniform names
54 //! \param fragFilename Filename of the fragment shader
55 //! \param vertFilename Filename of the vertex shader
56 //! \param fragFunction Name of the fragment shader function to call
57 //! \param vertFunction Name of the vertex shader function to call
58 //! \param effectUnitName Name of the texture unit for the effect
59 //! \param indirectTextureMapName Name of the indirect texture map
60 //! \param indirectTextureCoordName Name of the indirect texture coordinates
61 //!
62 //! Creates a new effect texture controller with the specified parameters.
63 //! These parameters define the shaders, texture units, and naming conventions
64 //! used by this effect controller.
65 DtVreOsgEffectTextureController(makVrv::DtDe& de, int effectTextureType, const std::string& typeString,
66 const std::string& postfix, const std::string& fragFilename, const std::string& vertFilename,
67 const std::string& fragFunction, const std::string& vertFunction, const std::string& effectUnitName,
68 const std::string& indirectTextureMapName, const std::string& indirectTextureCoordName);
69
70 //! \brief Virtual destructor
71 //!
72 //! Ensures proper cleanup of effect texture controller resources.
74
75 //! \brief Installs the effect shaders into a state set
76 //! \param baseUnit Base texture unit index
77 //! \param effectUnit Effect texture unit index
78 //! \param tex Pointer to the effect texture
79 //! \param stateSet State set to install the shaders into
80 //! \param baseTextureName Name of the base texture sampler
81 //! \return True if shaders were installed successfully, false otherwise
82 //!
83 //! Installs the effect shaders into the provided state set, configuring
84 //! the necessary uniforms and texture units for the effect. This is called
85 //! during the rendering process to apply the effect to the specified texture.
86 virtual bool installShaders(int baseUnit, int effectUnit, const osg::Texture* tex, osg::StateSet* stateSet,
87 const std::string& baseTextureName) const override;
88
89 //! \brief Gets the uniform used for toggling effect textures
90 //! \return Reference-counted pointer to the effects enabled uniform
91 //!
92 //! Returns the uniform that controls whether effect textures are enabled.
93 //! This can be used to globally toggle all effects of this type on or off.
94 static osg::ref_ptr<osg::Uniform> getEffectsEnabledUniform();
95
96private:
97 //! \brief Path to the fragment shader file
98 std::string myFragShader;
99
100 //! \brief Path to the vertex shader file
101 std::string myVertShader;
102
103 //! \brief Name of the fragment shader function to call
104 std::string myFragFunction;
105
106 //! \brief Name of the vertex shader function to call
107 std::string myVertFunction;
108
109 //! \brief Name of the texture unit for the effect
110 std::string myEffectUnitName;
111
112 //! \brief Shared uniform for enabling/disabling all effect textures
113 static osg::ref_ptr<osg::Uniform> effectsEnabledUniform;
114};
115
116
117//! \brief Factory creator for standard effect texture controllers
118//!
119//! DtVreOsgEffectTextureControllerCreator is a factory class that creates
120//! standard effect texture controller instances for registration with the
121//! DtEffectControllerFactory. This allows the effect controllers to be
122//! created on demand using the factory pattern.
123class PLAYERSTATION_DLL DtVreOsgEffectTextureControllerCreator : public makVrv::DtEffectControllerCreator
124{
125public:
126 //! \brief Creates a new effect texture controller
127 //! \param de Reference to the display engine
128 //! \return Pointer to a newly created effect texture controller
129 //!
130 //! Factory method that creates a new standard effect texture controller
131 //! instance for the specified display engine.
132 virtual DtVreOsgEffectTextureController* create(makVrv::DtDe& de) override;
133};
134
135//! \brief Factory creator for HUD-specific effect texture controllers
136//!
137//! DtVreOsgHudEffectTextureControllerCreator is a factory class that creates
138//! HUD-specific effect texture controller instances for registration with the
139//! DtEffectControllerFactory. These controllers are specially configured for
140//! use with Heads-Up Display elements in the rendering pipeline.
141class PLAYERSTATION_DLL DtVreOsgHudEffectTextureControllerCreator : public makVrv::DtEffectControllerCreator
142{
143public:
144 //! \brief Creates a new HUD effect texture controller
145 //! \param de Reference to the display engine
146 //! \return Pointer to a newly created HUD effect texture controller
147 //!
148 //! Factory method that creates a new HUD-configured effect texture controller
149 //! instance for the specified display engine.
150 virtual DtVreOsgEffectTextureController* create(makVrv::DtDe& de) override;
151};
152} // namespace makVre
Factory creator for standard effect texture controllers.
Definition vreOsgEffectTextureController.h:124
virtual DtVreOsgEffectTextureController * create(makVrv::DtDe &de) override
Creates a new effect texture controller.
Controller for texture swapping visual effects in OSG rendering.
Definition vreOsgEffectTextureController.h:47
virtual bool installShaders(int baseUnit, int effectUnit, const osg::Texture *tex, osg::StateSet *stateSet, const std::string &baseTextureName) const override
Installs the effect shaders into a state set.
std::string myVertFunction
Name of the vertex shader function to call.
Definition vreOsgEffectTextureController.h:107
virtual ~DtVreOsgEffectTextureController() override
Virtual destructor.
static osg::ref_ptr< osg::Uniform > effectsEnabledUniform
Shared uniform for enabling/disabling all effect textures.
Definition vreOsgEffectTextureController.h:113
std::string myVertShader
Path to the vertex shader file.
Definition vreOsgEffectTextureController.h:101
DtVreOsgEffectTextureController(makVrv::DtDe &de, int effectTextureType, const std::string &typeString, const std::string &postfix, const std::string &fragFilename, const std::string &vertFilename, const std::string &fragFunction, const std::string &vertFunction, const std::string &effectUnitName, const std::string &indirectTextureMapName, const std::string &indirectTextureCoordName)
Constructor.
std::string myFragFunction
Name of the fragment shader function to call.
Definition vreOsgEffectTextureController.h:104
std::string myFragShader
Path to the fragment shader file.
Definition vreOsgEffectTextureController.h:98
static osg::ref_ptr< osg::Uniform > getEffectsEnabledUniform()
Gets the uniform used for toggling effect textures.
std::string myEffectUnitName
Name of the texture unit for the effect.
Definition vreOsgEffectTextureController.h:110
Factory creator for HUD-specific effect texture controllers.
Definition vreOsgEffectTextureController.h:142
virtual DtVreOsgEffectTextureController * create(makVrv::DtDe &de) override
Creates a new HUD effect texture controller.
Defines export macros for the VR-Engage Player Station library.
#define PLAYERSTATION_DLL
Definition export.h:24
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
DtVreEffectTextureType
Extension of DtEffectTextureType enumeration for VR-Engage effects.
Definition vreOsgEffectTextureController.h:33
@ VRE_HUD_ET_MAP
HUD (Heads-Up Display) map effect texture type.
Definition vreOsgEffectTextureController.h:35
@ VRE_ET_MAP
Map overlay effect texture type.
Definition vreOsgEffectTextureController.h:34
makVrv::DtDe * de()
Gets the display element pointer used by the plugin.