Wizt::SplatRenderObject Class Reference
[The Fish Eye Retina - Fiber Bundle to OpenGL Gateway via Vish API]

Base class for render object that draw a splat for each vertex of a Grid object. More...

#include <SplatRenderObject.hpp>

Inheritance diagram for Wizt::SplatRenderObject:
Wizt::VertexRenderObject Wizt::Iris Wizt::VRenderObject Wizt::Fish< Fiber::Slice > Wizt::Fish< Fiber::Skeleton > Wizt::Fish< Fiber::FragmentCluster > Wizt::FragmentPainter Wizt::Fish< VObject > Wizt::VStateCreatorBase Wizt::Fish< double > Wizt::TimeDependent Wizt::Fish< double > Wizt::Fish< VObject > Wizt::VStateCreatorBase Wizt::Fish< VObject > Wizt::VertexFieldCollection Wizt::Fish< VObject > Wizt::Fish< VObject > Wizt::Fish< VObject > Wizt::Fish< Fiber::Grid > Wizt::Fish< double > Wizt::Fish< VObject >

List of all members.

Classes

Public Member Functions

Static Public Member Functions

Public Attributes


Detailed Description

Base class for render object that draw a splat for each vertex of a Grid object.

Subclasses may define the way how such splats are drawn, and parameterize them based on the given input fields.


Member Function Documentation

string Wizt::SplatRenderObject::fragment_shader ( VRenderContext Context  )  const [virtual]

Default fragment shader code, must derive from to get this 2D texture.

           uniform sampler2D PSFTexture;
           void main (void)
           {
           vec4 psf  = texture2D( PSFTexture, gl_TexCoord[0].st);
           gl_FragColor = psf*gl_Color;
           }

When creating the shader program, do

And in function setRendererParameters() call

const char * Wizt::SplatRenderObject::setPointAttenuation (  )  [static]

A vertex shader fragment defining a function that will set the gl_PointSize to some value suitable for splats that get smaller in distance.

Also it will let them fade out once too small. Add this code to the prefix of some vertex shader.

void main(void)
{
        gl_FrontColor.rgb = vec3(0.5,0.5,0.3);
        gl_Position = ftransform();

        gl_FrontColor.a = setPointAttenuation();
 }

This function will return the following GLGS code:

uniform float size;

float setPointAttenuation()
{
vec4 eyeCoord = gl_ModelViewMatrix * gl_Vertex;
float dist = distance(eyeCoord, vec4(0.0, 0.0, 0.0, 1.0));
float att = 1.0/dist;
float diameter = clamp(size* att, 0.0,100.0);

float   fadeThreshold = 1.0;
float   fadePower = 1.5;
        gl_PointSize = max(diameter, fadeThreshold);
float   fade = min(diameter, fadeThreshold)/fadeThreshold;
        return pow(fade, fadePower)
}
void Wizt::SplatRenderObject::setRendererParameters ( VRenderContext Context,
const RefPtr< VBO::Renderer > &  theRenderer,
const RefPtr< CreativeArrayBase > &  VertexCoordinates 
) const [virtual]

Update a renderer object, in case the fragment selector is newer.

Render function: set parameters in the renderer that don't need re-creation of the VBO

Reimplemented from Wizt::FragmentPainter.

References Wizt::VRenderContext::isCancelled().

void Wizt::SplatRenderObject::setShaderVariables ( VRenderContext Context,
const RefPtr< Program > &  ShaderProgram 
) const [virtual]

Virtual function to set variables in the shader program, such as parameters from the Vish inputs.

Typical code might just assign slots to uniform variables:

           struct       MySplatter : SplatRenderObject
           {
                TypedSlot<double>   Value;

                MySplatter(...)
                : SplatRenderObject(...)
                , Value(this, "value", 0.23)
                {}

                override string vertex_shader(VRenderContext&Context) const
                {
                        return "uniform float value; ....";
                }

                override void setShaderVariables(VRenderContext&Context, const RefPtr<Program>&ShaderProgram) const
                {
                        Value << Context > ShaderProgram;
                }
           };

Note that the name of the slot must be equal to the name of the uniform variable in the shader program for this to work. If the names don't match, then an OpenGL error exception will be thrown.

string Wizt::SplatRenderObject::vertex_shader ( VRenderContext Context  )  const [virtual]

Default vertex shader code that sets point size and transparency attenuation for very small points.

To make use of this functionality, the code returned by setPointAttenuation() must be included in the code provided by an implementation of this function, and the setPointAttenuation() function needs to be called in the vertex shader. Its return value is a transparency factor that is supposed to be used to attenuate the alpha value of the given colors. The default main function as returned by the vertex_shader function is

void main(void)
{
        gl_FrontColor.rgb = vec3(0.5,0.5,0.3);
        gl_Position = ftransform();
        gl_FrontColor.a = setPointAttenuation();
}

Generated on Sun Oct 18 12:17:07 2009 for FiberVISH by  doxygen 1.6.1