Code: Select all
fragment_program phong_fp glsl
{
source phong.frag
preprocessor_defines NUM_LIGHTS=2
}
Code: Select all
// shader implementation
#ifndef NUM_LIGHTS
#define NUM_LIGHTS 1
#endif // NUM_LIGHTS
Code: Select all
fragment_program phong_fp glsl
{
source phong.frag
preprocessor_defines NUM_LIGHTS=2
}
Code: Select all
// shader implementation
#ifndef NUM_LIGHTS
#define NUM_LIGHTS 1
#endif // NUM_LIGHTS
Code: Select all
preprocessor_defines MYCOLOR=2
Code: Select all
uniform vec4 ambient;
/*
Basic ambient lighting vertex program
*/
#ifndef MYCOLOR
#define MYCOLOR 0
#endif
void main()
{
gl_Position = ftransform();
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_FrontColor = ambient;
#if MYCOLOR==0
gl_FrontColor = vec4(0.0, 0.0, 0.0, ambient.a);
#endif
#if MYCOLOR==1
gl_FrontColor = vec4(1.0, 0.0, 0.0, ambient.a);
#endif
#if MYCOLOR==2
gl_FrontColor = vec4(0.0, 1.0, 0.0, ambient.a);
#endif
#if MYCOLOR==3
gl_FrontColor = vec4(0.0, 0.0, 1.0, ambient.a);
#endif
}
Code: Select all
#define DEF 1
int value = 0;
#ifndef DEF
value = 1;
#endif
Code: Select all
#define DEF 0
#ifdef NOTDEF
#define DEF 1
#endif
#define DEF2 0
#ifndef DEF
#define DEF2 1
#endif
int value1 = DEF; //value1 will be 1, should be 0
int value2 = DEF2; //value2 will also be 1, should be 0
Code: Select all
bool testFunction(in out vec3 v0)
Code: Select all
bool testFunction(in vec3 v0)
Code: Select all
#define TEST_2
#if defined(TEST_1)
outcolor = vec4(1,0,0,1);
#elif defined(TEST_2)
outcolor = vec4(0,1,0,1);
#else
outcolor = vec4(0,0,1,1);
#endif
Code: Select all
#ifdef ABC
uniform float bar;
#endif
Code: Select all
fragment_program Foo_ABC_FP glsl
{
source Foo.fs
preprocessor_defines ABC
default_params
{
param_named bar float 1.75
}
}
Code: Select all
fragment_program_ref Foo_ABC_FP
{
param_named bar float 1.25
}
Code: Select all
10:27:22: OGRE EXCEPTION(2:InvalidParametersException): Parameter called bar does not exist. in GpuProgramParameters::_findNamedConstantDefinition at ..\..\ogre_src_v1-7-2\OgreMain\src\OgreGpuProgramParams.cpp (line 1433)
10:27:22: Compiler error: invalid parameters in Foo.material(549): setting of constant failed
Code: Select all
... fragment_program SkyX_Skydome_STARFIELD_LDR_FP_GLSL glsl
{
source SkyX_Skydome.fragment
preprocessor_defines LDR,STARFIELD
default_params
{
}
} ...
Code: Select all
...
#ifdef LDR
gl_FragColor = vec4((1 - exp(-uExposure * (rayleighPhase * vRayleighColor + miePhase * vMieColor))), vOpacity);
#else // HDR
gl_FragColor = vec4(rayleighPhase * vRayleighColor + miePhase * vMieColor, vOpacity);
#endif // LDR
...
#ifdef STARFIELD
gl_FragColor.xyz += nightmult *(vec3(0.05, 0.05, 0.1)*(2-0.75*clamp(-uLightDir.y, 0.0, 1.0))*pow(vHeight,3) + texture2D(uStarfield, vUV+uTime)*(0.35f + clamp(-uLightDir.y*0.45f, 0.0, 1.0)));
#else // NO STARFIELD
gl_FragColor.xyz += nightmult *(vec3(0.05, 0.05, 0.1)*(2-0.75*clamp(-uLightDir.y, 0.0, 1.0))*pow(vHeight,3));
#endif // STARFIELD
...
Code: Select all
#ifdef LDR
gl_FragColor = vec4((1 - exp(-uExposure * (rayleighPhase * vRayleighColor + miePhase * vMieColor))), vOpacity);
#else // HDR
gl_FragColor = vec4(rayleighPhase * vRayleighColor + miePhase * vMieColor, vOpacity);
#endif // LDR
Code: Select all
#ifdef NORMAL_TEXTURE
// transform view space to tangent space
vec3 L_ts = vec3( dot(L,T), dot(L,B), dot(L,N) );
vec3 H_ts = vec3( dot(H,T), dot(H,B), dot(H,N) );
// calculate the coefficients
float I_diffuse = clamp( dot(bump,L_ts), 0.0, 1.0 );
float I_specular = clamp( dot(bump,H_ts), 0.0, 1.0 );
#else // NORMAL_TEXTURE
// calculate the coefficients
float I_specular = max( dot(N,H), 0.0 );
float I_diffuse = max( dot(N,L), 0.0 );
#endif // NORMAL_TEXTURE