Live data from Hacker News

Write shaders for the (sim) Vegas sphere

whenistheweekend.com

71–80 of 91 posts

Re: Write shaders for the (sim) Vegas sphere

#71
post #56

Now we need to run these on a small spherical display like the Gakken Worldeye https://youtu.be/85rs0WHnUy0?feature=shared&t=53 Here's an animated eyeball (hat tip chatgpt): uniform float time; varying vec2 vUv; vec3 lighting(vec3 normal, vec3 eyeDirection, vec3 lightDirection) { float diffuse = max(dot(normal, lightDirection), 0.0); vec3 reflected = reflect(-lightDirection, normal); float specular = pow(max(dot(refl…

Nice job!

Re: Write shaders for the (sim) Vegas sphere

#73

Earlier quoted context omitted.

> cone For physical tiles, clearly not as the curvature would be wrong. I'm sure there remain interesting questions, but it's not sufficiently obvious to me what projection makes sense that I'm able to get further into the problem.

A cone has the same curvature as the plane.

How do you define the curvature for a cone when it has a singularity at the apex? From the definion that I know (angle defect), the tip of the cone will have curvature

Re: Write shaders for the (sim) Vegas sphere

#75
post #38

Never played with shaders before, made a spinning watermelon. uniform float time; varying vec2 vUv; void main() { vec2 st = vUv.xy; float f1 = length(abs(2.0*st)/2.0 - .1*time); float stripe = fract(f1*10.0); float stripe2 = stripe*stripe*stripe; float stripe3 = fract(-f1*10.0); float stripe4 = stripe3*stripe3*stripe3; float f2 = length(abs(4.0*st)/2.0 - .2*time); float stripe5 = fract(f2*10.0); float stripe6 = strip…

The GPU takes model space objects (a long list of vertexes representing the 3 corners of triangles), a camera position and a vertex shader that transforms them into screen space. Then it splits the triangles into fragments (pixels), and runs the provided fragment shader (also called pixel shader in dx-land) on each fragment.

The inputs provided are defined by the programmer, and in this case, they are an uniform float (same value given to every fragment) called time, and a varying vec2 (different value given to each fragment, the vertex shader outputs a value for this at every vertex, and when the fragments are created, a value is linearly interpolated between the three relevant vertexes based on the position of the fragment on the triangle) called vUv, which is just the co-ordinates of a pixel on the sphere.

gl_FragColor is the single output, a rgba vector that represents color that is applied for that fragment.

The only things missing from the more typical shaders used in all games and, for example, google earth is texturing and lighting -- normally you provide the fragment shader a texture handle, which it then uses with texture co-ordinates provided from the vertex shader to sample the texture, and for lighting the vertex shader provides a surface normal, which you can use with an uniform argument for the location of the light source to correctly shade the fragment.

If the idea of running a program for each and every separate pixel individually sounds inefficient, it would be, but the programming model here is actually SIMT. That is, you give the program as if you are working on a single pixel, but it is converted to actually work on a wide SIMD array, doing 32 (NVidia) or 64 (AMD) pixels at the same time. The cost of this is that all conditional branches are essentially converted into conditional operations, meaning that as a first approximation, you always execute both sides of any if statement.

Re: Write shaders for the (sim) Vegas sphere

#76

Here's a static penrose tiling. https://gist.github.com/vjeranc/265db912d4004c7c0b0f16ae5fda... Interestingly, sphere is not infinite so having this aperiodic tiling is pointless (still looks nice). Although, I never found out if there's a similar set of tiles (or a monotile) that can tile an infinite cone.

> cone For physical tiles, clearly not as the curvature would be wrong. I'm sure there remain interesting questions, but it's not sufficiently obvious to me what projection makes sense that I'm able to get further into the problem.

I now realized I wanted to say cylinder, not cone haha.

Re: Write shaders for the (sim) Vegas sphere

#78

This reminds me of when Matt Parker let his viewers control his Christmas tree lights: https://youtu.be/v7eHTNm1YtU?si=GqK6oSZVHBJkjcib

How does this have anything to do with that?

It's also a way for the public to try visualizations in a 3D space. If you're interested in trying out some shaders and seeing what other people have created it's another vector to explore.

Re: Write shaders for the (sim) Vegas sphere

#80

Earlier quoted context omitted.

How does this have anything to do with that?

It's also a way for the public to try visualizations in a 3D space. If you're interested in trying out some shaders and seeing what other people have created it's another vector to explore.

How are someone's christmas lights a "visualization in 3D space?". You realize this is just a sphere model in opengl and doesn't affect anything in the real world right?

By this definition, someone flipping their light switches on and off is a "visualization in 3D space".

Post reply on HN