I'm currently porting Oculus Rift's shaders to GLSL 330, but I'm getting strange errors:
ERROR: 0:36: error(#202) No matching overloaded function found: mix
ERROR: 0:36: error(#160) Cannot convert from: "const float" to: "highp 4X4 matrix of mat4"
ERROR: error(#273) 2 compilation errors. No code generated
At this line:
mat4 lerpedEyeRot = mix(u_EyeRotationStart, u_EyeRotationEnd, in_TimewarpLerpFactor);
I also tried to convert the last mix parameter to a mat4, with no luck
I'm using OpenGL 3.3 on Windows 7, my graphic card is an AMD Radeon HD 6670.
Here is the vertex shader at time of writing:
#version 330
layout (location = 0) in vec3 in_Position;
//layout (location = 1) in vec4 in_Color;
layout (location = 2) in vec2 in_TexCoord0; // R
layout (location = 3) in vec2 in_TexCoord1; // G
layout (location = 4) in vec2 in_TexCoord2; // B
layout (location = 5) in float in_Vignette;
layout (location = 6) in float in_TimewarpLerpFactor;
uniform vec2 u_EyeToSourceUVScale;
uniform vec2 u_EyeToSourceUVOffset;
uniform mat4 u_EyeRotationStart;
uniform mat4 u_EyeRotationEnd;
out float v_Vignette;
smooth out vec2 v_TexCoord0;
smooth out vec2 v_TexCoord1;
smooth out vec2 v_TexCoord2;
vec2 TimewarpTexCoord(vec2 TexCoord, mat4 rotMat)
{
// Vertex inputs are in TanEyeAngle space for the R,G,B channels (i.e. after chromatic
// aberration and distortion). These are now "real world" vectors in direction (x,y,1)
// relative to the eye of the HMD. Apply the 3x3 timewarp rotation to these vectors.
vec3 transformed = vec3( mul(rotMat, vec4(TexCoord.xy, 1.0, 1.0)).xyz);
// Project them back onto the Z=1 plane of the rendered images.
vec2 flattened = (transformed.xy / transformed.z);
// Scale them into ([0,0.5],[0,1]) or ([0.5,0],[0,1]) UV lookup space (depending on eye)
return u_EyeToSourceUVScale * flattened + u_EyeToSourceUVOffset;
}
void main()
{
mat4 lerpedEyeRot = mix(u_EyeRotationStart, u_EyeRotationEnd, in_TimewarpLerpFactor); // ERROR HERE
v_TexCoord0 = TimewarpTexCoord(in_TexCoord0, lerpedEyeRot);
v_TexCoord1 = TimewarpTexCoord(in_TexCoord1, lerpedEyeRot);
v_TexCoord2 = TimewarpTexCoord(in_TexCoord2, lerpedEyeRot);
gl_Position = vec4(in_Position.xy, 0.5, 1.0);
v_Vignette = in_Vignette; // For vignette fade
}