Fork me on GitHub
#off-topic
<
2016-12-22
>
johnmarinellii21:12:34

interesting intro to geometric algebra (builds off of linear algebra): https://bitworking.org/news/ga/2d

nikki22:12:23

@johnmarinellii i've been thinking about using a rendering method like http://iquilezles.org/www/articles/distfunctions/distfunctions.htm which allows you to specify geometry (specifically 2d manifolds in embedded in 3d in this case) as a signed distance function and is able to render it p quickly purely in a shader

nikki22:12:41

the nice thing about that is now you can introduce an algebra over the shapes like union and subtract over them and it's v intuitive

nikki22:12:43

^ as you can see, subtraction is just an intersection with the 'negative' of a shape which is really awesome, and then you render it purely in GLSL

nikki22:12:54

could be dope to write a compiler from a sexp algebra of the scene to GLSL in clojure

johnmarinellii22:12:15

i don’t understand how one can render with just a functioN?

johnmarinellii22:12:22

i have a very vague idea of it

nikki22:12:37

so how GLSL works is there are two parts (there can be more but for now let's look at two)

nikki22:12:50

the first part is you send 'vertices' and their connectivity to the gpu, and it is able to transform them

nikki22:12:05

the second part defines how each pixel (actually an abstraction over a pixel called a 'fragment') is colored

nikki22:12:21

this algo basically uses a trivial vertex shader that just renders a fullscreen quad, that's it

nikki22:12:25

and the whole rendering algo is in the frag shader

nikki22:12:36

so it uses the GPU to do parallel processing on the pixels

nikki22:12:45

and at each pixel we shoot a ray in the direction corresponding to that given your camera

nikki22:12:08

and given the signed distance function we can compute the surface: it basically steps forward by the minimum distance to the scene at each point until it hits the surface

nikki22:12:19

the nice thing is the gradient of the function at that point gives you the normal 😮

nikki22:12:31

and normal + position means lighting

johnmarinellii22:12:01

that’s really cool

johnmarinellii22:12:28

i actually started learning ogl a couple of months ago, so this is very intriguing to me

johnmarinellii22:12:36

so is this raytracing?

nikki22:12:56

people put a lot of algos under the general umbrella of raytracing

nikki22:12:06

there are things like path tracing, photon mapping, etc. etc.

nikki22:12:15

this is a form of raytracing yea, the main difference is the intersection algo and the way the scene is stored

nikki22:12:28

a lot of ones assume a normal scenegraph storage and do usual tree style intersections

nikki22:12:39

this one stores the scene implicitly in a mathematical descritpion of it

nikki22:12:46

which allows you to transform the scene by transforming the /space/ around it

nikki22:12:06

so like if you have dist(x, y, z) if you do dist(x, y, mod(z, 10)) you actually repeat the same scene every 10 units of z

nikki22:12:13

which is like such a higher order transform for a scenegraph description... lol

nikki22:12:20

and it repeats it infinitely in finite memory

nikki22:12:29

(it's like how u store infinite lazy sequences implicitly)

johnmarinellii22:12:05

i see, so it’s kind of like a negative imprint

nikki22:12:09

want to play with this eventually but right now i'm working on a layer below it, and just thinking about this haha

johnmarinellii22:12:22

are you doing it in clojure ?

nikki22:12:34

if you want to play with ogl in cljs, http://regl.party is a good way imo

nikki22:12:15

it removes the need to do all the stateful calls like gl.createShader and gl.bind<Blah> etc. and just have a data-ific description of your rendering pipeline

nikki22:12:33

but it has the same surface area as straight WebGL, just in much more abbreviated and declarative form

nikki22:12:54

yeah -- i'm still learning clojurescript and going through the "Living Clojure" book

nikki22:12:15

I work on (at 'work') a javascript runtime basically and the last thing i was doing was exposing OpenGL to it in a WebGL API

nikki22:12:40

the runtime allows you to run clojurescript too (it's totally agnostic of it, just works) and binds react-native to do native UI, i just added the opengl part

nikki22:12:59

but i need to learn clojurescript to use it well 😅