uniforms.glsl 4.27 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
/**************************************************************************************/
/*                                                                                    */
/*  Copyright (c) 2005-2016, Michele Bosi.                                            */
/*  All rights reserved.                                                              */
/*                                                                                    */
/*  This file is part of Visualization Library                                        */
/*  http://visualizationlibrary.org                                                   */
/*                                                                                    */
/*  Released under the OSI approved Simplified BSD License                            */
/*  http://www.opensource.org/licenses/bsd-license.php                                */
/*                                                                                    */
/**************************************************************************************/

14 15
// Standard VL uniforms

16
// <automatic>
17
uniform mat4 vl_WorldMatrix;
18 19 20 21
uniform mat4 vl_ModelViewMatrix;
uniform mat4 vl_ProjectionMatrix;
uniform mat4 vl_ModelViewProjectionMatrix;
uniform mat4 vl_NormalMatrix;
22

Michele Bosi's avatar
Michele Bosi committed
23 24 25
// Texture Mapping

// <automatic>
26 27 28
uniform sampler1D vl_UserTexture1D; // Always set to vl::VividRendering::UserTexture
uniform sampler2D vl_UserTexture2D; // Always set to vl::VividRendering::UserTexture
uniform sampler3D vl_UserTexture3D; // Always set to vl::VividRendering::UserTexture
Michele Bosi's avatar
Michele Bosi committed
29

30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
// Smart Fog Stage

struct vl_SmartFogParameters {
    int mode;   // 0 = OFF, 1 = Linear, 2 = Exp, 3 = Exp2
    int target; // 0 = Color, 1 = Alpha, 2 = Saturation
};

// Smart Clip Stage

const int VL_SMART_CLIP_SIZE = 4;

struct vl_SmartClipParameters {
    int mode;        // 0=OFF, 1=Sphere, 2=Box, 3=Plane
    int target;      // 0=Color, 1=Alpha, 2=Saturation
    float fadeRange; // 0=Abrupt Transition, 0..X=Fuzzy Transition
    bool reverse;    // Reverse the clipping inside-out
    vec4 color;      // Use by VL_CLIP_TARGET == 0
    vec4 sphere;     // Sphere X,Y,Z,Radius (World Coords)
    vec3 boxMin;     // AABB min edge (World Coords)
    vec3 boxMax;     // AABB max edge (World Coords)
50
    vec4 plane;      // Nx, Ny, Nz, Pd (distance from origin) (World Coords)
51 52
};

53
// Outline
54

55
struct OutlineParameters {
Michele Bosi's avatar
Michele Bosi committed
56
    // <per-Shader>
57 58 59
    // Clipping plane for Slice Outline mode in World Coordinates
    vec4 slicePlane;

Michele Bosi's avatar
Michele Bosi committed
60
    // <per-Shader>
61
    // Outline color
62 63
    vec4 color;

Michele Bosi's avatar
Michele Bosi committed
64
    // <per-Shader>
65
    // Outline width
Michele Bosi's avatar
Michele Bosi committed
66
    float width;
67

68
    // <automatic>
69 70
    // Offset in camera space
    // 0.25mm OK for VTK scenes
71
    // Only for Outline3D modes
72 73
    float eyeOffset;

74
    // <automatic>
75 76
    // Offset in Normalized Device Coordinates
    // 0.0005 more general but can create artifacts
77
    // Only for Outline3D modes
78 79 80 81 82 83
    float clipOffset;
};

// Stencil Texture

struct vl_StencilParameters {
84
    // <automatic>
85 86 87
    // Stencil feature is enabled
    bool enabled;

88
    // <automatic>
89 90 91
    // Border smoothness
    int smoothness;

92
    // <automatic>
93 94 95
    // Color of the stencil background
    vec4 backgroundColor;

96
    // <automatic>
97 98 99 100 101
    // Texture where the stencil is stored
    sampler2DRect texture;
};

struct vl_VividParameters {
Michele Bosi's avatar
Michele Bosi committed
102
    // <per-Shader>
103
    // 0=Polys, 1=Outline3D, 2=Polys+Outline3D, 3=Slice, 4=Outline2D, 5=Polys+Outline2D
104 105
    int renderMode;

Michele Bosi's avatar
Michele Bosi committed
106
    // <per-Shader>
107 108
    // If lighting is disabled Geometry must have a color array
    bool enableLighting;
109

Michele Bosi's avatar
Michele Bosi committed
110
    // <per-Shader>
Michele Bosi's avatar
Michele Bosi committed
111 112 113
    // Whether to use texture mapping or not
    bool enableTextureMapping;

114 115 116 117
    // <automatic>
    // Whether the texture is a 1D, 2D or 3D texture
    bool textureDimension;

Michele Bosi's avatar
Michele Bosi committed
118
    // <per-Shader>
Michele Bosi's avatar
Michele Bosi committed
119 120 121 122
    // Whether to render points as textured point sprites
    // Requires enableTextureMapping=1
    bool enablePointSprite;

123
    // <automatic>
124 125 126
    // Whether the current shader is rendering a 3D outline
    bool outline3DRendering;

127
    // <automatic>
128
    // Global opacity
129
    float opacity;
130

131
    // <automatic>
132 133
    vl_StencilParameters stencil;

Michele Bosi's avatar
Michele Bosi committed
134
    // <automatic> / <per-Shader>
135
    OutlineParameters outline;
136

Michele Bosi's avatar
Michele Bosi committed
137
    // <per-Shader>
138 139
    vl_SmartFogParameters smartFog;

Michele Bosi's avatar
Michele Bosi committed
140
    // <per-Shader>
141 142 143 144
    vl_SmartClipParameters smartClip[ VL_SMART_CLIP_SIZE ];
};

uniform vl_VividParameters vl_Vivid;