Notes from the path of creating a 3D geometry engine

Hello, Sakari here, aka inDigiNeous. For the past 2 years I have been building my own 3D engine, from the ground up, using C++11 and modern OpenGL.

In this post I am going through the motivation to build my own 3D engine, technical details about the process and what is driving me to do this work. Work that is ultimately leading to the development of next version of GeoKone (“GeoKone 3D”) and later also to http://Geometrify.net.

The desire to see how things work

First some background on why I decided to create my own 3D engine, how I got here and why I ultimately didn’t just use a ready made solution like Unity or Unreal Engine, or any of the other more lightweight engines out there.

My personal goal has always been to understand things deeply, and to see behind things, how they operate on their core levels. I get satisfaction from understanding things thoroughly. I like to take apart stuff, build, re-build and see how the pieces fit together in different ways. This is where I get my kicks from.

To understand, to learn, to see what makes things tick.

My graphics background

When I started developing http://GeoKone.NET, I had some experience in programming graphics, but nothing on a really deep level. I first learned graphics programming back in the 90s in the MS-DOS days, doing some simple Turbo Pascal, assembler and C -based demo effects, but I never released anything or never did anything really cool.

I tinkered during the years with 2D -graphics programming, mostly on the Javascript side of things, so I had some experience with that. But nothing on a really deep level.

During the development of GeoKone I noticed that  many of the visions I wanted to implement, I just couldn’t do with Javascript and the 2D canvas, because of performance reasons and just the limitations of the platform.

Back in 2011 when I started working on GeoKone, and during the couple of years following that, there was no viable option to do hardware graphics processing in the browser, WebGL wasn’t really a viable option, and in a way it still even isn’t, although it is gaining popularity, stability and support now, but it is still limited to new powerful machines to get smooth frame rates and nice support.

So I stuck with Javascript and 2D canvas programming for a while there, and it worked perfectly fine for what GeoKone is .. but I knew I needed more close-to-the-metal programming in order to get the visions out of my head that I wanted to see.

Enter Virtual Reality

In December 2013 when the Oculus Rift DK1 became available to purchase for any developer, I could hear my intuition proclaiming loudly “Order!” “Do it!”.

I still remembered in the early 2000s when my intuition told me, as a engineering student,  “purchase Apple stock” .. and I didn’t, so this time I decided to listen ;)

I ordered the first development kit, and the moment I first tested it, I knew that this is  the environment where Geokone 3D has to be made.

The Oculus Rift DK1 :: Hello Androids

Hello Androids :: Wearing the Oculus DK1

I  decided to dedicate my time then to start learning C++ and OpenGL more and to get something showing with the DK1.

I had already prototyped core parts of GeoKone with C++, Java and even Objective-C, just to test out what would fit best for the case, so I had some code already to work on, but not much.

Development of libgeokone, very early stages, C++ & OpenGL

Development of libgeokone, very early stages, C++ & OpenGL

Back then there was no integrated support in Unity or Unreal Engine like now, so the only way to see something in stereo 3D, was to implement  it using Oculus’s own C/C++ SDK.

Learning 3D basics

And I had no real experience in doing 3D programming, no understanding of how the math and the principles behind it worked. But I just decided, screw this, I’m gonna learn this while I go, and so I began.

Implementing and understanding basic 3D math and translations, projections and such took a while to understand, and matrix operations also still a bit difficult, but the more I program this stuff and really just teach it to myself, the more I start to see this geometry everywhere, how things are built, and understand the math and physics of space and light also while learning it, which is really interesting to notice.

Using a grid to verify 3D functionalities

Using a grid to verify 3D functionalities

Had one experience of walking outside after really grasping the 3D fundamentals and getting code working, I walked outside and could see their vector versions projected on top of the physical objects for a while there, like green matrixes of the physical objects, my mind mapping them out with the rules I just programmed for them. Woah! As Keanu Reeves would say.

Programming the Oculus Rift

It took me 4 months of work to get anything even showing properly with the DK1, mainly due to learning the basics of 3D programming, vectors, matrixes, projections, the whole third dimension and the complexity that comes with it. Luckily, for vector math I could use the great GLM library, which is really nice for working with OpenGL.

I had done simple 3D programming before this, but nothing that I could substantially understand, and this time I wanted to understand each thing I was doing, in order to really grasp what is going on here.

In these months of learning modern C++, OpenGL, GLSL, browsing the Oculus Forums to understand the SDK and just taking in all of this new information, I got to the state where I would get stereo rendering working properly finally, and man, it felt good at that point :)

One of the first stereo rendered scenes I did

One of the first stereo rendered scenes I did

Finally in beginning of May 2014 I had most of my geometry core from GeoKone ported to C++, with very simple GLSL shaders. This meant I could now draw recursive geometry in 3D space, with support for stereo rendering.

This would produce this kind of images:

Early stereo images

Early stereo images

One of the very first scenes for verifying stereo rendering I did

One of the very first scenes for verifying stereo rendering I did

Another stereo image

Another stereo image

Developing the first Demo

I also got the DK1 rendering properly, so I now had this kind of images produced by my program, animated in 60 fps, zooming through the geometry:

Geokone geometry engine rendered in stereo with C++ & OpenGL

Geokone geometry engine rendered in stereo with C++ & OpenGL

I continued from there to develop this demo, tested it with different music, and finally added music from my good friend Miika Kuisma. This lead to the development of the first demo of Geometrify, which we demoed together with Tommi Ullgren, Samuel Aarnio and many others helping us, ultimately us showcasing this potential of sacred geometry in VR at over 20 events and offering probably over a 1000 people their first VR experience ..

But that is a story for another blog post :)

From demo to engine

The first demo I did was just only a technical demo, made in a way that really didn’t support building flexible software around it, so I had to spend a lot of time figuring out how to get a proper framework of C++11 & OpenGL, built in a way that allowed configuration of a 3D world designed to render recursive geometry in a 3D space.

C++11 and OpenGL was chosen in order to support cross platform from the get go. No other language really offers bindings to all the libraries on all major three platforms, Mac Os X, Windows & Linux, and also mobile devices, and with the rock solid performance that this kind of experience would require to be really solid and feel smooth as silk.

Modern C++ practices

Modern C++ practices

I spent lot of time in just learning OpenGL and C++11 best practices. C++11 is a very nice language, but to understand how to use it, you have to wade through maybe 15-20 years of legacy practices in order to find how things are done currently, and how to apply modern techniques.

Implementing beautiful line rendering

One of the key aspects of rendering recursive geometry, is how to get beautiful lines rendered. Turns out this is not as simple as just using a ready made library, as there really doesn’t exist such a thing.

I waded through different methods, read through many papers and found out people have implemented something already, like the VASE -renderer. Ultimately I decided to implement the line rendering method researched and implemented by Nicolas P. Rougier with python, described in his paper here: http://jcgt.org/published/0002/02/08/paper.pdf

Getting this to work I now had lines like this renderer in OpenGL:

Antialiased Polygon Lines

First version of the antialiased polygon lines I implenented

Showing how these lines are tesselated from triangles

Showing how these lines are tesselated from triangles

More recent example of the linerendering

A More recent example of the line rendering method.

Need for a scripting language

One of the really annoying things about C++ is the need to compile the source code all the time even if you just change one number. Trying to implement program logic with this limitation was getting really on my nerves, as usually it took at least 2 – 3 seconds to compile the classes I was working on, and when doing this hundreds of times really takes a toll in the iteration times.

I reached the same conclusion that many others before me have done, and saw that I need to add scripting language support for my engine to really get anywhere in a reasonable time and not loose my mind while doing it.

I prototyped different approaches, first considering using QT5 with it’s built in Google V8 javascript engine, but came to the conclusion that I don’t need such a beast of software just do add scripting.

I also looked at several other scripting options, but really the only other one that can be taken seriously is Lua, so I bit the bullet, learned yet another new language and bound my C++ engine to the Lua -side with the assistance of the great lua-intf interface.

Controlling scenes with Lua

Controlling scenes with Lua

To be able to write programs that have the iteration speed of javascript, combined with the raw power of C++11 and Modern OpenGL, felt super good. Unlimited power!! ;)

Base work almost done

So finally I’ve reached a state of development in my engine, now named PSITriangle Engine™, where I can run program logic in scripts in Lua, and keep the parts requiring performance on the C++ side.

It’s been a long way to this state, to implement a very specific use-case 3D Geometry Engine, using modern C++11 and modern OpenGL + GLSL techniques, all the while learning how to do this while developing the actual engine.

The feeling of getting here, controlling all the pixels on the screen, using the power of math and geometry, and skills I had accumulated over the years to produce this virtual space, felt like pure creation coming into life.

I’m glad I didn’t know how much work implementing a 3D engine properly is, because I might have not chosen that path if I had known :D

Finally  I can just quickly script and prototype ideas quickly. This brings development speeds up significantly and helps test and development massively easier from now.

From now on my plan is to finish this base of the engine and actually start implementing the program logic for what is going to become “GeoKone 3D” as the project name for now! :)

My Custom 3D Engine Rendering Geometry

Video

Short clip I wanted to share, showing some recent rendering example of the custom 3D Engine, PsiTriangle Engine, I am developing is capable of doing.

This is just one testing example, rendering circular shapes, but the engine can render GeoKone -style recursive geometry. Check out http://GeoKone.NET for examples.

Creating software for Creators

Would you like to feel like a Creator ?

 

Feeling I want to Create with Geometrify Creator

Feeling I want to Create with Geometrify Creator

This picture (by http://sacredvisions.co.uk) pretty well sums up the feeling of the software that I want to build. It will be called Geometrify Creator, and to over simplify things I’m going to describe it as Geokone 2.0 + 3D for now.

 
Native speed OpenGL, VR support, Intuitive Touch/Motion Interface.
Designed to be so easy to use that a child can understand and feel the fun, and learn geometry and math in practice while doing it, supported with visual cues and realtime feedback of what is happening on every action.
 

No luck with funding

For the past year, we have been building this vision and demoing our concept / tech demo for the Oculus Rift DK1 at various events ranging from biohacking events in Finland, psychedelic gatherings at Ozora Hungary and consciousness hacking meetups in Silicon Valley, USA.

It’s been one big adventure and lesson in just letting go and flowing with whatever comes, and dedicating myself for the cause of building something that will blow peoples minds.

This has been proven with the DK1 -demo already, but what has been difficult has been the realization that I cannot build this vision alone, and we don’t have the resources to hire another fulltime programmer to help.

Making it happen

I’ve been fortunate enough to be on this path for 3 years already, first building GeoKone.NET into a more finalized state and now focusing on bringing a VR -supported version of new version of this vision into reality.

Too bad dedication is not enough, and I am now running out of money. How to continue working on this and figuring out a place to get income or funding is now really pushing me. I really wish a person would come that could give us 30,000 euros right now so we could continue working on this, but if this doesn’t manifest into reality, I really have to start thinking about getting a day job again.

Planning right now just to release everything we have done with Geometrify, like the Oculus Rift DK1 -demo we have now demoed at least to 1000 people already, and also our unfinished DK2 -demo which we never got ready.

Technical Challenges

It turns out building a custom 3D engine from scratch is pretty freaking difficult! Especially being the only one programming it.

I have a strong reasoning to build our own tech, because we have such a specialized case of generating geometry on the fly, and I see many use cases for such an engine. My vision spans 10 years, not just one application in one place.

Everything has been designed in such a way that this geometry engine, called PsiTriangle Engine for now, can be added to many different projects where recursive, interactive, living GeoKone.NET style recursive natural geometry is needed.


Also, I really want to understand everything about the process and not just use some ready made engine. This means a steep learning curve, but on the long run I will win through sheer perseverance and deep understanding what is happening on a hardware level of things.

Wanting to share the knowledge

I trule believe that Sacred Geometry represents the structure of the world we live in, and by understanding that structure, we can understand so much more of the world we live in.

This is my goal, to share this knowledge. I wish it was easier, but seems creating anything different than what people are used to doing, is met with great resistance on some subconscious level.

Its not safe, it’s not another Call Of Duty or another ‘match 3’ game, it’s something different. And seems many people are not ready for that. I hope to find those people who are ready for this.

Moving On

I have still held back in communicating this more honestly and directly, so now I feel is the time to really start just putting the vision out there and not care what some stuck up businessmen think about it.

With Geometrify we have tried too much to fit our vision into something existing, when I feel it is time to just be brave and communicate more from the heart what we want to create.

Anyway. I just wanted to shortly update what is going on right now and what I have been thinking. Will be updating more when I get more of what I want to down on paper.

Geokone Tutorial Video :: Creating Sacred Geometry Live

I did an quick’n’sleek tutorial video on how to create beautiful Geometry with  GeoKone.NET., check out the video here:

In this video I go through the basics, while creating art and explaining what I am doing.

Just watching somebody create geometry can also be quite relaxing, especially with great music by Miika Kuisma in this video.

More Rainbow GeoKone Generated Fractal Geometry Art

Image

Some recently discovered look from GeoKone.NET.
Fore more art, Check out my tumblr page at http://indigineous.tumblr.com/

export_4_stamped

8 loop, infinity, heart energy, torus

SomethingDifferentForAWhile_stamped

Vesica Pisces, Duality, Balance

export_5_stamped

Opening Up, DMT, Spiritual


export_6_stamped

Love, Purity, Bliss

export_3_stamped

Discovery, Construction

What do you think ?

Created utilizing the Rotate Hue animation option in GeoKone.NET.

 

Playing the startup game with Geometrify, probably going mad

Pushing the limits of my mental health

Past 3 weeks have been crazy. Crazy depressing and stressful, trying to push Geometrify forwards, in a rushed mad man craze feeling of trying to reach a goal of releasing our new demo and crowdfunding campaign on 11.11.15, in order to match with the release of GeoKone on 11.11.11 (ha, that post has 11 comments)

And then realizing all this was just some imaginary deadline we had setup for ourselves, and that our direction is not exactly aligned on what is possible to implement right now. Gah.

I have been driving myself to the limits, drinking too much black tea, coffee, then needing something to calm me down after that, and continuing this vicious cycle until I was completely exhausted and not even remembering who I am anymore. This completely drained me physicall and mentally, and I was ready to give up the whole thing.

But then suddenly, I saw something in the midst of it all ..

A diamond shines in the darkness

In this self developed chaos shit storm, a diamond of perfection shone in the midst of it all:

Diamond in the Center

Diamond in the Center

Looking at it, just observing, and using GeoKone while being in the darkness I could see it more clearly. GeoKone has helped to suppress depression, to channel my self in the darkest moments so many times that I really wish I could somehow bring this program to the masses better. There I was again, creating art with GeoKone, feeling like shit, when suddenly I could see beauty coming out of darkness, forming slowly, reminding me that there is always a solution, even if I’m not seeing it in the middle of all the crap flying around.

Not sure if this can be seen only by travelling to the centre of it all, going through all that chaos around it first, or is there an easier way maybe ? Who knows. I dont know. I can read a thousand books, hear a thousand stories, and none are the one I am travelling. There are no ready answers or solutions to those walking their own path.

Startup mantras

I hope I don’t have to do this again ever. So that I might learn when to just keep calm, and focus on the task at hand, and not project into the future to fulfill some deadline that might as well be total bullshit in 2 weeks.

Fail fast, fail often. If you fail at first, try again. These are the mantras repeated in the startup world, and I can see now why. This has been a total surrender trip since 2012 december when I left my dayjob and pursued GeoKone full time.

My psyche has been put to the test, still working alone as programmer on Geometrify. Not having anybody to talk to on the technical aspect daily, not having anybody to wait at the workplace for me, or not anybody to even expect me to be there at time. It can get very depressing.

And still, the comments from people who have tried our first demo (which will be released at some point for the Oculus DK1, hopefully) like “most interesting usage of VR”, or “most deep experience of geometry”, or the mind baffling comment after a private demo “I realized what happens after I die”, these keep me going.

Glimpses to another world

Yeah, somebody saw glimpses of what happens when he dies by just trying our demo.

Think about that for a while. Let it sink in.

The possibilities with this project are endless. And yet, how to communicate this what we are buildling, seems impossible. There are no words to describe it. It slips through the rationality and structure of words. Like a spiritual experience, it is really difficult to share.

And this has been our challenge for the whole time we have been developing Geometrify Experience. How to communicate this to people, when it is really personal, can be meditative, immersive, but can also not be meditative, can just be annoying for minority of people trying it out, or it can be something completely different for each person.

Catching small fish

I think we have been trying to catch a too big of a fish, we now need really to narrow down our grids and focus on something that can be also implemented, and explained, and still utilizing our top of the line geometry engine, which might I say, is getting really nice.

I’m starting to get the hang of C++11 finally, and OpenGL too, so things are starting to look good on the technical side.

Still, no funding, no coding partners, although I have help from many people now, and we are now an officially registered Co-Op in Finland now, so a lot of progress happening also!

I am hopeful to continue working. Fail fast, fail often, get up, grind up, fuck that shit up and show them that following our hearts something truly extraordinary can be achieved!

Ready to get up again!

Ready to get up again!

Now this is inDigiNeous, signing off again!

Geokone 0.99.64 Released :: Active Layer Indicator & Much Polish

Today saw the release of GeoKone.NET version 0.99.64. This release is just about small polish and one new major feature: Active layer indicator. These indicators show what is the active layer visually, so you don’t have to go guessing.

Here is a video showing off some new features and high level geokone usage:

Keyboard focus is now also indicated with a small icon, and last command entered is also shown to give exact feedback on what you gave GeoKone.