Skip to content

Instantly share code, notes, and snippets.

@BryanChrisBrown
Created August 25, 2022 12:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BryanChrisBrown/1c417bde2cc8fb5615e8f4048f1a2a49 to your computer and use it in GitHub Desktop.
Save BryanChrisBrown/1c417bde2cc8fb5615e8f4048f1a2a49 to your computer and use it in GitHub Desktop.
#define QAA 2
const float sideAngle = radians(35.0);
const float horizontalAngle = radians(14.0);
const float cameraSize = 2.0;
const float aspectRatio = 0.75;
const vec3 VROffset = vec3(0, 0, 9);
float quiltColumns = 8.;
float quiltRows = 6.;
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec4 accColor = vec4(0.);
for( int m = 0; m < QAA; m++ )
for( int n = 0; n < QAA; n++ )
{
// pixel coordinates
vec2 o = (vec2(float(m), float(n)) / float(QAA) - 0.5) / iResolution.xy ;
vec2 coord = (fragCoord / iResolution.xy + o) * vec2(quiltColumns,quiltRows);
vec2 fract = fract(coord);
vec2 floor = floor(coord);
float imageId = floor.x + floor.y * quiltColumns;
float valueId = imageId / (quiltColumns * quiltRows - 1.);
float dist = (cameraSize / 2.) / tan(horizontalAngle / 2.);
float minCam = -(cameraSize / 2.) - tan(sideAngle / 2.) * dist;
vec3 camPos = mix(vec3(minCam,0,dist),vec3(-minCam,0,dist),valueId);
vec3 screenPos = vec3((fract.x-0.5)*cameraSize,(fract.y-0.5)*cameraSize/aspectRatio,0);
vec3 dir = normalize(screenPos - camPos);
vec4 color;
mainVR(color, fragCoord, camPos - VROffset, dir);
accColor += clamp(color, 0.0, 1.0);
}
fragColor = accColor / float(QAA*QAA);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment