All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jogamp.opengl.oculusvr.shader.dist01_timewarp_chroma.vp Maven / Gradle / Ivy

//Copyright 2014 JogAmp Community. All rights reserved.

#if __VERSION__ >= 130
  #define attribute in
  #define varying out
#endif

uniform vec2    ovr_EyeToSourceUVScale;
uniform vec2    ovr_EyeToSourceUVOffset;
uniform mat4    ovr_EyeRotationStart;
uniform mat4    ovr_EyeRotationEnd;

attribute vec2  ovr_Position;
attribute vec2  ovr_Params;
attribute vec2  ovr_TexCoordR;
attribute vec2  ovr_TexCoordG;
attribute vec2  ovr_TexCoordB;

varying vec3    ovv_Fade;
varying vec2    ovv_TexCoordR;
varying vec2    ovv_TexCoordG;
varying vec2    ovv_TexCoordB;

void main(void)
{
    gl_Position = vec4(ovr_Position.xy, 0.0, 1.0);
    ovv_Fade = vec3(ovr_Params.r); // vignetteFade
    
    // 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.
    vec3 TanEyeAngleR = vec3 ( ovr_TexCoordR, 1.0 );
    vec3 TanEyeAngleG = vec3 ( ovr_TexCoordG, 1.0 );
    vec3 TanEyeAngleB = vec3 ( ovr_TexCoordB, 1.0 );
    
    // Accurate time warp lerp vs. faster
    // Apply the two 3x3 timewarp rotations to these vectors.
	vec3 TransformedRStart = (ovr_EyeRotationStart * vec4(TanEyeAngleR, 0)).xyz;
	vec3 TransformedGStart = (ovr_EyeRotationStart * vec4(TanEyeAngleG, 0)).xyz;
	vec3 TransformedBStart = (ovr_EyeRotationStart * vec4(TanEyeAngleB, 0)).xyz;
	vec3 TransformedREnd   = (ovr_EyeRotationEnd * vec4(TanEyeAngleR, 0)).xyz;
	vec3 TransformedGEnd   = (ovr_EyeRotationEnd * vec4(TanEyeAngleG, 0)).xyz;
	vec3 TransformedBEnd   = (ovr_EyeRotationEnd * vec4(TanEyeAngleB, 0)).xyz;

    // And blend between them.
    vec3 TransformedR = mix ( TransformedRStart, TransformedREnd, ovr_Params.g /* timewarpLerpFactor */ );
    vec3 TransformedG = mix ( TransformedGStart, TransformedGEnd, ovr_Params.g /* timewarpLerpFactor */ );
    vec3 TransformedB = mix ( TransformedBStart, TransformedBEnd, ovr_Params.g /* timewarpLerpFactor */ );
    
    // Project them back onto the Z=1 plane of the rendered images.
    float RecipZR = 1.0 / TransformedR.z;
    float RecipZG = 1.0 / TransformedG.z;
    float RecipZB = 1.0 / TransformedB.z;
    vec2 FlattenedR = vec2 ( TransformedR.x * RecipZR, TransformedR.y * RecipZR );
    vec2 FlattenedG = vec2 ( TransformedG.x * RecipZG, TransformedG.y * RecipZG );
    vec2 FlattenedB = vec2 ( TransformedB.x * RecipZB, TransformedB.y * RecipZB );
    
    // These are now still in TanEyeAngle space.
    // Scale them into the correct [0-1],[0-1] UV lookup space (depending on eye)
    ovv_TexCoordR = FlattenedR * ovr_EyeToSourceUVScale + ovr_EyeToSourceUVOffset;
    ovv_TexCoordR.y = 1.0-ovv_TexCoordR.y;
    ovv_TexCoordG = FlattenedG * ovr_EyeToSourceUVScale + ovr_EyeToSourceUVOffset;
    ovv_TexCoordG.y = 1.0-ovv_TexCoordG.y;
    ovv_TexCoordB = FlattenedB * ovr_EyeToSourceUVScale + ovr_EyeToSourceUVOffset;
    ovv_TexCoordB.y = 1.0-ovv_TexCoordB.y;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy