00001 #ifndef OIV_SHADER_VARIABLES_H
00002 #define OIV_SHADER_VARIABLES_H
00003
00005
00013
00016 #if (OIV_SHADER_STAGE == OIV_FRAGMENT_SHADER)
00017
00023 vec4 OivFragmentColor()
00024 {
00025 return gl_Color;
00026 }
00027
00033 vec4 OivFragmentTexCoord( in int unit )
00034 {
00035 #if !defined(OIV_USE_NVIDIA)
00036 switch (unit)
00037 {
00038 default:
00039 case 0:
00040 return gl_TexCoord[0];
00041 case 1:
00042 return gl_TexCoord[1];
00043 case 2:
00044 return gl_TexCoord[2];
00045 case 3:
00046 return gl_TexCoord[3];
00047 case 4:
00048 return gl_TexCoord[4];
00049 case 5:
00050 return gl_TexCoord[5];
00051 case 6:
00052 return gl_TexCoord[6];
00053 case 7:
00054 return gl_TexCoord[7];
00055 }
00056 #else
00057 return gl_TexCoord[unit];
00058 #endif
00059 }
00060
00061 #endif // OIV_SHADER_STAGE
00062
00063 #if (OIV_SHADER_STAGE == OIV_VERTEX_SHADER) || (OIV_SHADER_STAGE == OIV_FRAGMENT_SHADER)
00064
00070 float OivFogFragCoord()
00071 {
00072 #if (OIV_SHADER_STAGE == OIV_VERTEX_SHADER)
00073 return gl_FogCoord;
00074 #else
00075 return gl_FogFragCoord;
00076 #endif
00077 }
00078 #endif // OIV_SHADER_STAGE
00079
00080 #if (OIV_SHADER_STAGE == OIV_GEOMETRY_SHADER) || (OIV_SHADER_STAGE == OIV_TESSELLATION_CONTROL_SHADER) || (OIV_SHADER_STAGE == OIV_TESSELLATION_EVALUATION_SHADER)
00081
00088 vec4 OivFrontColor( in int index )
00089 {
00090 return gl_in[index].gl_FrontColor;
00091 }
00092
00100 vec4 OivBackColor( in int index )
00101 {
00102 return gl_in[index].gl_BackColor;
00103 }
00104
00112 vec4 OivTexCoord( in int index, in int unit )
00113 {
00114 #if !defined(OIV_USE_NVIDIA)
00115 switch (unit)
00116 {
00117 default:
00118 case 0:
00119 return gl_in[index].gl_TexCoord[0];
00120 case 1:
00121 return gl_in[index].gl_TexCoord[1];
00122 case 2:
00123 return gl_in[index].gl_TexCoord[2];
00124 case 3:
00125 return gl_in[index].gl_TexCoord[3];
00126 case 4:
00127 return gl_in[index].gl_TexCoord[4];
00128 case 5:
00129 return gl_in[index].gl_TexCoord[5];
00130 case 6:
00131 return gl_in[index].gl_TexCoord[6];
00132 case 7:
00133 return gl_in[index].gl_TexCoord[7];
00134 }
00135 #else
00136 return gl_in[index].gl_TexCoord[unit];
00137 #endif
00138 }
00139
00147 float OivFogFragCoord( in int index )
00148 {
00149 return gl_in[index].gl_FogFragCoord;
00150 }
00151
00152 #endif // OIV_SHADER_STAGE
00153
00154
00163 void OivInitVertexData()
00164 {
00165 }
00166
00167 #if (OIV_SHADER_STAGE != OIV_FRAGMENT_SHADER)
00168
00176 void OivSetFrontColor( in vec4 color )
00177 {
00178 #if (OIV_SHADER_STAGE == OIV_TESSELLATION_CONTROL_SHADER)
00179 gl_out[gl_InvocationID].gl_FrontColor = color;
00180 #else
00181 gl_FrontColor = color;
00182 #endif
00183 }
00184
00193 void OivSetBackColor( in vec4 color )
00194 {
00195 #if (OIV_SHADER_STAGE == OIV_TESSELLATION_CONTROL_SHADER)
00196 gl_out[gl_InvocationID].gl_BackColor = color;
00197 #else
00198 gl_BackColor = color;
00199 #endif
00200 }
00201
00210 void OivSetTexCoord( in int unit, in vec4 coord )
00211 {
00212 #if (OIV_SHADER_STAGE == OIV_TESSELLATION_CONTROL_SHADER)
00213 # if !defined(OIV_USE_NVIDIA)
00214 switch (unit)
00215 {
00216 default:
00217 case 0:
00218 gl_out[gl_InvocationID].gl_TexCoord[0] = coord;
00219 case 1:
00220 gl_out[gl_InvocationID].gl_TexCoord[1] = coord;
00221 case 2:
00222 gl_out[gl_InvocationID].gl_TexCoord[2] = coord;
00223 case 3:
00224 gl_out[gl_InvocationID].gl_TexCoord[3] = coord;
00225 case 4:
00226 gl_out[gl_InvocationID].gl_TexCoord[4] = coord;
00227 case 5:
00228 gl_out[gl_InvocationID].gl_TexCoord[5] = coord;
00229 case 6:
00230 gl_out[gl_InvocationID].gl_TexCoord[6] = coord;
00231 case 7:
00232 gl_out[gl_InvocationID].gl_TexCoord[7] = coord;
00233 }
00234 # else
00235 gl_out[gl_InvocationID].gl_TexCoord[unit] = coord;
00236 # endif
00237 #else
00238 # if !defined(OIV_USE_NVIDIA)
00239 switch (unit)
00240 {
00241 default:
00242 case 0:
00243 gl_TexCoord[0] = coord;
00244 case 1:
00245 gl_TexCoord[1] = coord;
00246 case 2:
00247 gl_TexCoord[2] = coord;
00248 case 3:
00249 gl_TexCoord[3] = coord;
00250 case 4:
00251 gl_TexCoord[4] = coord;
00252 case 5:
00253 gl_TexCoord[5] = coord;
00254 case 6:
00255 gl_TexCoord[6] = coord;
00256 case 7:
00257 gl_TexCoord[7] = coord;
00258 }
00259 # else
00260 gl_TexCoord[unit] = coord;
00261 # endif
00262 #endif
00263 }
00264
00273 void OivSetFogFragCoord( in float coord )
00274 {
00275 #if (OIV_SHADER_STAGE == OIV_TESSELLATION_CONTROL_SHADER)
00276 gl_out[gl_InvocationID].gl_FogFragCoord = coord;
00277 #else
00278 gl_FogFragCoord = coord;
00279 #endif
00280 }
00281
00282 #endif // OIV_SHADER_STAGE
00283
00284 #if (OIV_SHADER_STAGE == OIV_FRAGMENT_SHADER)
00285
00291 void OivFragmentOutput( in int bufferIndex, in vec4 outputValue )
00292 {
00293 gl_FragData[bufferIndex] = outputValue;
00294 }
00295
00302 void OivFragmentOutput( in vec4 outputValue )
00303 {
00304 OivFragmentOutput(0, outputValue);
00305 }
00306
00307 #endif // OIV_SHADER_STAGE
00308
00309 #endif
00310