I am implementing the Summed-Area Table algorithm. There is a statement
float4 uv[8]:TEXCOORD0;
in the shader code originally written in HLSL in Slide 9 in the following slides Summed-Area Table AMD
When complied in GLSL, it failed and said “OpenGL does not allow Cg-style semantics”.
Is there any way in GLSL to achieve the same effect?
Since that seems to be part of their VSoutput, I would hazard a guess that it is a vertex shader and that uv thing is a texcoordinate input for your vertex shader.
In GLSL version 1.10
you use gl_MultiTexCoord0
This is from AMD’s RenderMonkey Earth example
#version 110
// Earth vertex shader computes lighting coefficients.
//
// Note: For optimal light animation set the RenderMonkey cycle time
// for predefined variables to 20 seconds. (Found in the Edit->Preferences).
// predefined variables used to animate light direction
uniform float cos_time_0_2PI, sin_time_0_2PI;
// artist variable to control season
uniform float season;
// varying variables passed to fragment shader
varying float Diffuse;
varying vec3 Specular;
varying vec2 TexCoord;
void main(void)
{
// calculate vertex position in eye coordinates
vec4 ecPosition = gl_ModelViewMatrix * gl_Vertex;
// compute the transformed normal
vec3 tnorm = normalize(gl_NormalMatrix * gl_Normal);
// compute the light vector pointing toward the sun, in model coordinates
// x,y compose the longitude and z the (seasonal) lattitude of the nadir point.
vec3 lightVec = normalize(gl_NormalMatrix * vec3(cos_time_0_2PI, season,sin_time_0_2PI));
// compute the reflection vector
vec3 reflectVec = reflect(-lightVec, tnorm);
// compute a unit vector in direction of viewing position
vec3 viewVec = normalize(vec3 (-ecPosition));
// Calculate specular light intensity, scale down and
// apply a slightly yellowish tint.
float specIntensity = pow(max(dot(reflectVec, viewVec), 0.0), 8.0);
specIntensity = 0.3 * specIntensity;
Specular = specIntensity * vec3 (1.0, 0.941, 0.898);
// Calculate a diffuse light intensity
Diffuse = dot(lightVec, tnorm);
// Pass texture coordinates fragment shader
TexCoord = vec2 (gl_MultiTexCoord0);
TexCoord.x = TexCoord.x;
// output final vertex information
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
That’s because the statement has no meaning for OpenGL.
With the exception of separate shaders, the connection between shader outputs and inputs is done by name. If your vertex shader has a out vec4 uv[8], then your fragment shader needs a corresponding in vec4 uv[8] to match.
Separate shader objects allows the intersection to be made via an index, but that only works when doing dynamic linking between separate programs.