Created
January 5, 2012 20:04
-
-
Save ofTheo/1566967 to your computer and use it in GitHub Desktop.
try this in the shader code of this link: http://notlion.github.com/streetview-stereographic/#o=0.409,-0.207,0.681,0.571&z=1.553&mz=15&p=22.27844,114.16438
This file contains 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
uniform sampler2D texture; | |
uniform float scale, aspect, time; | |
uniform mat3 transform; | |
varying vec2 v_texcoord; | |
#define PI 3.141592653589793 | |
#define PI_2 1.570796326794897 | |
vec2 tc_offset[9]; | |
void main(){ | |
int doEdge = 1; | |
vec2 rads = vec2(PI * 2., PI); | |
float x = (v_texcoord.x - .5) * scale; | |
float y = (v_texcoord.y - .5) * scale * aspect; | |
// Project to Sphere | |
vec3 sphere_pnt = vec3( | |
(2. * x) / (1. + x*x + y*y), | |
(2. * y) / (1. + x*x + y*y), | |
(x*x + y*y - 1.) / (1. + x*x + y*y) | |
); | |
sphere_pnt *= transform; | |
// Convert to Spherical Coordinates | |
float r = length(sphere_pnt); | |
float lon = atan(sphere_pnt.y, sphere_pnt.x); | |
float lat = acos(sphere_pnt.z / r); | |
if( doEdge == 1 ){ | |
vec4 sample[9]; | |
tc_offset[0] = vec2(-1.0, -1.0); | |
tc_offset[1] = vec2(0.0, -1.0); | |
tc_offset[2] = vec2(1.0, -1.0); | |
tc_offset[3] = vec2(-1.0, 0.0); | |
tc_offset[4] = vec2(0.0, 0.0); | |
tc_offset[5] = vec2(1.0, 0.0); | |
tc_offset[6] = vec2(-1.0, 1.0); | |
tc_offset[7] = vec2(0.0, 1.0); | |
tc_offset[8] = vec2(1.0, 1.0); | |
//color2 = texture2D(texture, vec2(lon, lat) / rads); | |
for(int i = 0; i < 9; i++){ | |
sample[i] = texture2D(texture, (vec2(lon, lat) / rads) + tc_offset[i] * 0.001); | |
} | |
vec4 horizEdge = sample[2] + (2.0*sample[5]) + sample[8] - | |
(sample[0] + (2.0*sample[3]) + sample[6]); | |
vec4 vertEdge = sample[0] + (2.0*sample[1]) + sample[2] - | |
(sample[6] + (2.0*sample[7]) + sample[8]); | |
vec3 s3 = sqrt((horizEdge.rgb * horizEdge.rgb) + (vertEdge.rgb * vertEdge.rgb)); | |
float brightness = (s3.r + s3.g + s3.b) / 3.0; | |
if( brightness > 0.35 ){ | |
brightness = 0.0; | |
}else{ | |
brightness = 1.0; | |
} | |
vec4 color = texture2D(texture, vec2(lon, lat) / rads); | |
color.rgb *= brightness; | |
gl_FragColor = color; | |
} | |
} |
yeah - for sure! that would be so nice to be able to share a modification.
super nice work though!!
oh nice. will you add a permalink button to the project to generate the url?
The URL actually changes every time the shader successfully compiles, so you should be able to just copy it.
oh I didn't notice thats awesome!
btw is it possible to include fullscreen in the url? ( currently if I have a fullscreen view it doesn't save the fullscreen into the url )
sorry for putting the feature requests here :-)
Haha no problem. I had thought about that but wasn't sure if it would be confusing to arrive at the page fullscreen. I suppose it's a good thing to save, though.
Made an issue so I don't forget later..
notlion/streetview-stereographic#1
haha - the proper way to do it :)
…On Jan 9, 2012, at 3:37 PM, Ryan Alexander wrote:
Made an issue so I don't forget later..
notlion/streetview-stereographic#1
---
Reply to this email directly or view it on GitHub:
https://gist.github.com/1566967
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Rad! Man, I need to make shaders permalink.