Skip to content

Instantly share code, notes, and snippets.

@headstash
Last active July 1, 2019 20:43
Show Gist options
  • Save headstash/e84096c86f992bdd0f30d93acae8d875 to your computer and use it in GitHub Desktop.
Save headstash/e84096c86f992bdd0f30d93acae8d875 to your computer and use it in GitHub Desktop.
synesthesia_equirectangular.synScene
/*{
"CONTROLS" : [
{
"DEFAULT" : 0.5,
"DESCRIPTION" : "Smoothly switch between normal perspective and Equirectangular coordinates. Best results with this slider at 0% or 100%.",
"IS_META" : false,
"MAX" : 1,
"MIN" : 0,
"NAME" : "perspective",
"PARAMS" : 0.0099999997764825821,
"TYPE" : "slider smooth",
"UI_GROUP" : "camera"
},
{
"DEFAULT" : 0,
"DESCRIPTION" : "Just move the X-axis to spin about your main axis, or move the Y-axis to tilt forwards or backwards.",
"IS_META" : false,
"MAX" : 1,
"MIN" : -1,
"NAME" : "lookXY",
"PARAMS" : 0.0099999997764825821,
"TYPE" : "xy smooth",
"UI_GROUP" : "camera"
}
],
"CREDIT" : "shadyheadstash",
"DESCRIPTION" : "Equirectangular projection as a filter.",
"HEIGHT" : 2160,
"IMAGES" : [],
"IMAGE_PATH" : "equirec.png",
"TITLE" : "Equirec",
"WIDTH" : 3840
}
*/
//vec4 iMouse = vec4(MouseXY*RENDERSIZE, MouseClick, MouseClick);
#define twpi 6.283185307179586 // two pi, 2*pi
#define pi 3.141592653589793 // pi
#define time TIME
vec4 renderMainImage() {
vec4 fragColor = vec4(0.0);
vec2 fragCoord = _xy;
vec2 v = (_xy.xy / RENDERSIZE.xy) + RENDERSIZE.y;
v.y -= 0.5;
float th = v.y * pi, ph = v.x * twpi;
vec3 sp = vec3( sin(ph) * cos(th), sin(th), cos(ph) * cos(th) );
vec3 pos = vec3( pi, 0, 0);
sp = mix(sp, normalize(vec3(_uvc, 1.0)), perspective);
sp.yz = _rotate(sp.yz, lookXY.y*PI);
sp.xy = _rotate(sp.xy, lookXY.x*PI);
if (_exists(syn_UserImage)) {
fragColor = texture(syn_UserImage, (vec2(dot(pos, sp.zxy), dot(pos.yzx, sp.zxy))));
}
return fragColor;
}
vec4 renderMain(){
if(PASSINDEX == 0){
return renderMainImage();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment