Planet Generator banner

Planet Generator

19 devlogs
81h 31m 39s

A little C++ project with OpenGL and GLFW3 to render some procedural planets made from scratch

Repository

Loading README...

Hat Dealer

Making a child

This update was mostly fixes and stuff but there are some interenting things added

Added

  • Rendering a specific part of the G-Buffer (2nd picture)
  • Parent-child relations
    • A child follows its parents position, rotation etc

Reworked

  • Framebuffers can now have the type of their depth buffer set easily
Attachment
Attachment
0
Hat Dealer

Virtual pottery with model loading

Added

  • Rendering of models, not just meshes
  • Model loading with assimp
  • FPS counter and other minor stuff

Reworked

  • Wireframe mode now always works

Utah teapot

The model shown here is called the Utah teapot. It is commonly known as the “hello world” of graphical programming
It is the first proper model ever made. It was sketched on paper and vertices calculated by hand but the version here is a bit more modern with normals and CCW vertices winding

Attachment
Attachment
1

Comments

Simon
Simon 5 days ago

Super cool stuff, keep going
This looks like it has potential

Hat Dealer

Culling my frustum, TAA and spinning in 4D

Added

  • Frustum culling to not render objects I cannot see
  • TAA - Temporal anti-aliasing (the coolest one out of the 3 I did)

Reworked

  • Quaternion rotation. It used to be really wierd and now its less wierd
    • it was so much pain to do since quaternions are 4D dimensional matrices and are wierd. the rotation thats implemented now isnt perfect and I will have to look at it again later

Images

The first image is of the velocity buffer used for TAA and the second image is a representation of a quaternion

Attachment
Attachment
0
Hat Dealer

Who made that mess?

During this update I mainly fixed up stuff I broke switching to deferred rendering
Also worked on anti-aliasing and the current solutions arent perfect but when I add TAA it should make everything 1000x better

Added

  • FXAA (fast approximate anti-aliasing) and MLAA (Morphological anti-aliasing)
    • I used to have MSAA (multisampled anti-aliasing) but that would not work well with deferred shading
  • Rendering should now be properly done in sRGB instead of RGB

Fixed

  • The post-processing pipeline
  • phong rendering (and specular lighting inside of it)

still broken :(

  • TAA (Temporal Anti-Aliasing) is still not implemented
  • the MLAA is a bit wierd but I have no idea if it should look like that or no
  • The lighting is still a bit hack-y until I do a big lighting rework
Attachment
1

Comments

Hat Dealer
Hat Dealer 12 days ago

the image compression is not doing the best for the image showcase lol
nothing I can do sadly

Hat Dealer

Deferred shading with a side of vectors

Added

  • Deferred shading pipeline - WIP
  • Pipeline for transparent and special shaders since they cant be used with deferred shading
  • Quaternion rotation is now a lot more influential
    • I can for example set my feet to point towards the planet and move like normal

Reworked

  • a lot of shaders were reorganised

Broke

with the new rendering pipeline I broke the following:

  • anti-aliasing
  • post-processing effects

Deferred shading?

Deferred shading is a different rendering pipeline which renders a scene into several buffers and then computes shading for them as another step. It can be somewhat more efficient and versitile but rn its really WIP and holding with ducktape but it works!

Attachment
Attachment
1

Comments

kewlcactus13
kewlcactus13 22 days ago

this is so cool! i love the way you’ve setup the depth colouring for water, sand, grass and mountains!

Hat Dealer

Sky in a box

Added

  • Ability to set exposure (kinda similar to gamma)
  • An OpenGL wrapper for 2D textures
  • An OpenGL wrapper for cubemaps
  • Skybox

Reworked

  • Reworked the README so its not just some basic info with compilation steps
Attachment
0
Hat Dealer

Mild shader preprocessor rework

Added

  • Added a #var preprocessor directive which allows me to specify a variable that can change on the CPU and it will get automatically updated on the GPU
    • In the gif it can be seen as the ambient color changing and it instantly updating the planets tint without any syncing code for the color specifically

Reworked

  • Tidied up some shaders and the preprocessor code

Fixed

  • Rendering of the planet is now correct no matter where it is positioned
Attachment
2

Comments

hack.clubber
hack.clubber 26 days ago

Awesome project dude. pretty cool Idea too.
It would be better if you added more docs to your repo.

Hat Dealer
Hat Dealer 26 days ago

tyy <3 im totally planing to add more stuff to the readme before shipping

Hat Dealer

Framing my buffer

Added

  • Added a Framebuffer OpenGL wrapper so I can easily create and manipulate frame buffers
    • This needed quite a lot of work to integrate with MSAA multisampling
  • Thanks to framebuffers I added a very basic compatibility for post-processing effects
  • Gamma correction
    • It looks bad with my color palette so I won’t be using it too much but its there

Framebuffers?

Framebuffers are a type of buffer used for rendering where all draw calls render to that specific framebuffer (specifically its textures/renderbuffers). Making my own allows me to make my own post-processing effects etc.

“But the image is ugly! :< I hate you!” I hear you say

The image is using a really basic shader I slapped together in like 5 minutes to have something to showcase. It just inverts the colors on half of the screen and then puts the other half in grayscale. Its just the tip of the iceberg of what I can do and make now

Attachment
0
Hat Dealer

Atmospheric atmosphere

Added

  • Two separate rendering pipelines for the atmosphere
    • The atmosphere now uses two shaders, one for when inside the atmosphere and one for outside of the atmosphere

Reworked

  • Atmosphere shader and split them into two separate
    • I tried to make it as pretty as possible without any bugs but I am still not happy with how the atmosphere looks like from space but the transition between the shaders is pretty good I think
Attachment
Attachment
2

Comments

aloyak
aloyak about 1 month ago

this is pretty cool bro, you’re cooking!

Hat Dealer
Hat Dealer about 1 month ago

tyyy <3

Hat Dealer

Spheres with atmospheres

Added

  • ImGui support for all components
    • Any component can now display their own ImGui window
  • Added an atmosphere renderer along with shaders for it
  • Added support for transparent objects

Reworked

  • Reworked the planet generator to make the planet terrain and colors look even better
  • Planet terrain now uses proper materials for each layer instead of just colors
  • Reworked some shaders a bit to look somewhat better
Attachment
1

Comments

Hat Dealer
Hat Dealer about 1 month ago

also there are too many mountains in the gif, I fixed that shortly after for the terrain to be more grassy

Hat Dealer

Straight up shaderin’ it

Reworked

  • Reworked the planet rendering shader
    • It now uses a per-pixel color assignment instead of vertex
  • Updated the README to have a tutorial for compiling
  • The planet noise texture is now made from several overlayed noise textures for better detail

Added

  • A planet color palette for the reworked shader
Attachment
0
Hat Dealer

I made a basic planet

Added

  • Planet related components
  • Random and value noise
  • Basic ImGui
  • New rendering pipeline for planets with lighting interactions

Removed

  • Mesh components. The Mesh object is now directly linked to a rendering component instead of a mesh object inbetween
Attachment
0
Hat Dealer

Sphere mesh generation from spherifying a cube

Added

  • RGB(A) classes
  • Upgraded Phong lighting algorithm to Blinn-Phong which is a bit more realistic
  • A generator for spherified cube mesh with settable amount of subdivisions

Spherified cube??

When thinking of a cube some people may think about an Ico sphere or UV sphere but these all have their own downsides. A spherified cube is a cube with many subdivisions thats forced to have all the points the same lenght away from the center. This makes it a lot easier to later implement more subdivisions the closer it is to the player and its easier to map a noise map to it as it wont have artifacts

Attachment
0
Hat Dealer

Cube mesh generation

Added

  • directional light source
  • mesh and vertices generator
    • generates UV and normal maps
  • dependency checks for components

Mesh generator

The mesh generator can generate vertices and then calculate their normal maps, indices and UV maps. This will be later used to generate planets and their meshes

Dependency checks

A component now has a list of dependencies that it needs to have access to or else it throws an error. For example you cannot have a camera without a transform component as the transport components tell the camera component where it is and which direction its facing

Attachment
1

Comments

Hat Dealer
Hat Dealer about 2 months ago

also the lights have a color of the light they are emitting but thats a small change xd

Hat Dealer

Phong lighting

Added

  • Phong lighting algorithm
  • materials with different reflectivity, color, etc
  • point light attenuation

Point light attenuation

It basically means that the more away a light is, the less it shines based on three values which signify a constant, linear and quadratic dropoff

Attachment
0
Hat Dealer

Basic lighting

Added

  • ambient lighting
  • point light lighting
  • components related to light sources

Other

It took me a while to fix the rotation. The normal vectors were getting rotated wierdly but it turned out that the problem was me rotating it using a 4x4 matrix instead of 3x3

Attachment
0
Hat Dealer

Movement with camera

Added

  • An input system
  • movement component
  • camera rotation support
  • rotations updated from euler angles (3D) to quaternions (4D)

Quaternions

Quaternions are a 4D vector which is a special way to interpret rotation. Its more smooth and easier to work with in relation to OpenGL than normal euler angles (yaw, pitch, roll)

0
Hat Dealer

Going 3D

Added

  • Projections and views
  • A cube mesh
  • A camera which moves away
1

Comments

toderodavi
toderodavi about 2 months ago

This looks like a really cool idea! Gave it a follow!

Hat Dealer

Basic project

Added

  • ECS (Entity Component System)
  • OpenGL wrappers I made myself so I dont have to work with OpenGL directly
  • Some basic stuff to get things to render like a quad, shaders etc

ECS

Entity Component System allows me to make an object and then add components to it kinda similar to Unity. I can for example make an object with a transform component so that it has position, rotation etc, then add a rendering component and a mesh component and I will have an object that renders. Then I can later give it another component that for example makes it move with my inputs

Attachment
1

Comments

Hat Dealer
Hat Dealer about 2 months ago

the square is spinning btw lol