41 #include <osg/Material>
42 #include <osg/ShapeDrawable>
43 #include <osg/StateAttribute>
45 #include "WDemoGeometry.h"
46 #include "WMTemplateShaders.h"
47 #include "core/graphicsEngine/WGEGeodeUtils.h"
48 #include "core/graphicsEngine/WGEImage.h"
49 #include "core/graphicsEngine/WGEManagedGroupNode.h"
50 #include "core/graphicsEngine/WGERequirement.h"
51 #include "core/graphicsEngine/WGETexture.h"
52 #include "core/graphicsEngine/WGETextureUtils.h"
53 #include "core/graphicsEngine/WGEUtils.h"
54 #include "core/graphicsEngine/callbacks/WGEShaderAnimationCallback.h"
55 #include "core/graphicsEngine/shaders/WGEPropertyUniform.h"
56 #include "core/graphicsEngine/shaders/WGEShader.h"
57 #include "core/graphicsEngine/shaders/WGEShaderDefineOptions.h"
58 #include "core/graphicsEngine/shaders/WGEShaderPropertyDefine.h"
59 #include "core/graphicsEngine/shaders/WGEShaderPropertyDefineOptions.h"
60 #include "core/kernel/WKernel.h"
84 return "Template Shaders";
90 return "Show some shader programming examples.";
109 m_planeColor =
m_properties->addProperty(
"Plane Color",
"Color of the plane", WColor( 90, 95, 100, 255 ) / 255.0 );
112 m_aWeight =
m_properties->addProperty(
"Light Intensity",
"The intensity of light on the spheres.", 1.0 );
120 m_possibleSelections->addItem(
"Bump Mapping",
"Make the brain pop out." );
121 m_possibleSelections->addItem(
"Transparent Plane",
"Make the base plane transparent." );
122 m_possibleSelections->addItem(
"LSD Mode",
"Make it a bit more colorful." );
124 m_modeSelection =
m_properties->addProperty(
"Plane Render Modes",
"Choose what you like.", m_possibleSelections->getSelectorAll() );
159 osg::ref_ptr< WGEGroupNode > rootNode =
new WGEGroupNode();
163 rootNode->setMatrix( osg::Matrixd::rotate( 1.57, 1.0, 0.0, 0.0 ) );
170 plane->getOrCreateStateSet()->setMode( GL_BLEND, osg::StateAttribute::ON );
171 plane->getOrCreateStateSet()->setRenderingHint( osg::StateSet::TRANSPARENT_BIN );
174 rootNode->insert( spheres );
175 rootNode->insert( plane );
188 osg::ref_ptr< WGEShader > sphereShader(
190 "WMTemplateShaders-Spheres",
223 sphereShader->apply( spheres );
228 osg::ref_ptr< WGEShader > planeShader(
new WGEShader(
"WMTemplateShaders-Plane",
m_localPath ) );
229 planeShader->apply( plane );
253 osg::Uniform* animationTime(
259 spheres->getOrCreateStateSet()->addUniform( animationTime );
260 plane->getOrCreateStateSet()->addUniform( animationTime );
271 spheres->getOrCreateStateSet()->addUniform(
314 bwSwitch->setActive(
false );
331 sphereShader->addPreprocessor( bwMode );
333 bwMode->activateOption( 3 );
336 bwMode->activateOption( 1 );
337 bwMode->activateOption( 3,
true );
349 sphereShader->addPreprocessor(
360 sphereShader->addPreprocessor(
376 planeShader->addPreprocessor(
381 "BUMPMAPPING_ENABLED",
382 "TRANSPARENTPLANE_ENABLED",
399 const size_t size = 64;
424 uniform float u_gradientsMin = 0;
427 uniform float u_gradientsScale = 1;
430 uniform float u_gradientsAlpha;
433 uniform bool u_gradientsClipZeroEnabled = false;
436 uniform float u_gradientsThresholdLower;
439 uniform float u_gradientsThresholdUpper;
442 uniform bool u_gradientsThresholdEnabled = false;
445 uniform bool u_gradientsWindowEnabled = false;
448 uniform vec2 u_gradientsWindow = vec2( 0.0, 1.0 );
451 uniform int u_gradientsColormap;
454 uniform bool u_gradientsActive = false;
virtual void wait() const
Wait for the condition.
void setResetable(bool resetable=true, bool autoReset=true)
Sets the resetable flag.
virtual void add(std::shared_ptr< WCondition > condition)
Adds another condition to the set of conditions to wait for.
Class to encapsulate boost::condition_variable_any.
Class to wrap around the osg Group node and providing a thread safe add/removal mechanism.
static WGEImage::SPtr createFromFile(boost::filesystem::path file)
Load an image from a file.
std::shared_ptr< WGEImage > SPtr
Convenience typedef for a std::shared_ptr< WGEImage >.
This requirement ensures an up and running WGE.
This is a uniform callback setting the uniform to the current time in milliseconds,...
This GLSL preprocessor is able to set one define from a list of defines depending on the active optio...
std::shared_ptr< WGEShaderDefineOptions > SPtr
Shared pointer for this class.
void setValue(const ValueType &value)
Sets the new value for this define.
std::shared_ptr< WGEShaderDefine< ValueType > > SPtr
Shared pointer for this class.
std::shared_ptr< WGEShaderPreprocessor > SPtr
Shared pointer for this class.
This is a WGEShaderDefineOptions class which additionally uses a property to automatically control th...
This class is able to provide arbitrary values as define statements in GLSL code.
Class encapsulating the OSG Program class for a more convenient way of adding and modifying shader.
This calls serves a simple purpose: have a texture and its scaling information together which allows ...
osg::ref_ptr< WGETexture< TextureType > > SPtr
Convenience type for OSG reference pointer on WGETextures.
A class containing a list of named items.
std::shared_ptr< WItemSelection > SPtr
Convenience typedef for a std::shared_ptr< WItemSelection >
static WKernel * getRunningKernel()
Returns pointer to the currently running kernel.
std::shared_ptr< WGraphicsEngine > getGraphicsEngine() const
Returns pointer to currently running instance of graphics engine.
std::shared_ptr< WCondition > m_propCondition
A condition for property updates.
WPropColor m_planeColor
Color of the plane.
WPropBool m_flicker
Turn on/off animation.
virtual void properties()
Initialize the properties for this module.
WPropSelection m_modeSelection
Switch between several modes.
WPropDouble m_sphereScaler
Allow scaling the spheres.
virtual void moduleMain()
Entry point after loading the module.
WMTemplateShaders()
Constuctor.
virtual ~WMTemplateShaders()
Destructor.
virtual const std::string getName() const
Gives back the name of this module.
WPropColor m_spheresColor
Color of the spheres.
virtual void requirements()
Initialize requirements for this module.
virtual void connectors()
Initialize the connectors this module is using.
virtual const std::string getDescription() const
Gives back a description of this module.
WPropDouble m_aWeight
Some weight.
virtual std::shared_ptr< WModule > factory() const
Due to the prototype design pattern used to build modules, this method returns a new instance of this...
Class representing a single module of OpenWalnut.
boost::filesystem::path m_localPath
The path where the module binary resides in.
Requirements m_requirements
The list of requirements.
virtual void properties()
Initialize properties in this function.
wlog::WStreamedLogger debugLog() const
Logger instance for comfortable debug logging.
virtual WModuleMetaInformation::ConstSPtr getMetaInformation() const
The meta information of this module.
std::shared_ptr< WProperties > m_properties
The property object for the module.
void ready()
Call this whenever your module is ready and can react on property changes.
WConditionSet m_moduleState
The internal state of the module.
virtual void connectors()
Initialize connectors in this function.
WBoolFlag m_shutdownFlag
Condition getting fired whenever the thread should quit.
osg::ref_ptr< osg::Node > createSphereGeometry()
Create several spheres.
osg::ref_ptr< osg::Node > createPlaneGeometry()
Create a plane.
void addTo(WPropSelection prop)
Add the PC_NOTEMPTY constraint to the property.
osg::ref_ptr< WGETexture< osg::Texture1D > > genWhiteNoiseTexture(size_t sizeX, size_t channels)
This generates an 1D texture only containing white noise in its channels.
void bindTexture(osg::ref_ptr< osg::Node > node, osg::ref_ptr< WDataTexture3D > texture, size_t unit=0, std::string prefix="")
Binds the specified texture to the specified unit.