Skip to content

Instantly share code, notes, and snippets.

@codeanticode
Last active June 13, 2023 11:28
Show Gist options
  • Save codeanticode/020cc4f25acc820acefce6774cd4893e to your computer and use it in GitHub Desktop.
Save codeanticode/020cc4f25acc820acefce6774cd4893e to your computer and use it in GitHub Desktop.
uniform samplerCube cubemap;
uniform float aperture;
varying vec4 vertTexCoord;
const float PI = 3.1415926535897932384626433832795;
const float DEG_TO_RAD = PI/180;
void main() {
vec2 thetaphi = ((vertTexCoord.xy * 2.0) - vec2(1.0)) * vec2(PI, PI/2);
vec3 rayDirection = vec3(cos(thetaphi.x), tan(aperture* DEG_TO_RAD)*thetaphi.y, sin(thetaphi.x));
vec3 color = vec3(textureCube(cubemap, rayDirection));
gl_FragColor = vec4(color, 1.0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment