Last active
May 5, 2022 11:26
-
-
Save mattebb/2d41cea6897aa9099681 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma opname fisheyelens | |
#pragma oplabel "Fisheye Lens" | |
#pragma hint x hidden | |
#pragma hint y hidden | |
#pragma hint Time hidden | |
#pragma hint dofx hidden | |
#pragma hint dofy hidden | |
#pragma hint aspect hidden | |
#pragma hint P hidden | |
#pragma hint I hidden | |
#pragma range fov 0 360 | |
#include "math.h" | |
cvex | |
fisheyelens( | |
// Inputs | |
float x = 0; | |
float y = 0; | |
float Time = 0; | |
float dofx = 0; | |
float dofy = 0; | |
float aspect = 1; | |
// Outputs | |
export vector P = 0; | |
export vector I = 0; | |
// Shader arguments | |
float fov = 180; | |
) | |
{ | |
float r = sqrt(x*x + y*y); | |
float phi = atan2(y, x); | |
float rfov = radians(fov); | |
float theta = r * (rfov / 2.0); | |
P = {0,0,0}; | |
I = set( sin(theta)*cos(phi), | |
sin(theta)*sin(phi), | |
cos(theta) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment