Coding Adventure: Procedural Moons and Planets
Why Game Development Stack Exchange recommends it
Game Development Stack Exchange users link it when asking about or replicating planet generation, such as compute-shader mesh deformation, ocean depth shading, and cube-sphere meshes.
Recommended by 3 people across 2 different months, 2020 to 2024.
What it is
Sebastian Lague's Coding Adventure walks through building procedural moons and planets in Unity, covering sphere meshes, craters, noise, triplanar mapping, ocean and planet shading. It is a 23-minute narrated build with chapter timestamps, and the project files are on GitHub.
What people said
Recommends Glen Pierce · 2020-07 · Game Development Stack Exchange · on “Compute shader: Property at kernel index is not set”
I am trying to follow this excellent Coding Adventure: [this video] in order to get a very simple mesh deformation on a mesh using a compute shader. I'm getting an error that reads: Compute shader (NewComputeShader): Property (vertices) at kernel index (0) is not set UnityEngine.ComputeShader:Dispatch(Int32, Int32, Int32, Int32) MoonShader:runShader() (at Assets/MoonShader.cs:27) MoonShader:Update() (at Assets/MoonShader.cs:15) I'm calling runShader() in Update (maybe that's a terrible idea, but I don't think it's contributing to this specific problem yet). Do I need to somehow pass my mesh's vertices into StructuredBuffer<float3> vertices; ? If so, how am I supposed to do that? This is the call
Recommends Spaceguy99 · 2020-07 · Game Development Stack Exchange · on “Generating the distance of an intersection through a box from the camera in Unity C#”
So, I recently saw this fantastic video by Sebastian Lague about planetary generation- [this video] And I decided to replicate it, however, on a flat plane, not a sphere.In the video, (at timestamp linked) he uses some mathematical expression to figure out the distance of the camera's vector through an arbitrary sphere, and uses this to shade the ocean. I can't figure out how to write a similar estimator for an arbitrary rectangular prism. Anyone have any ideas? EDIT- I have shifted to using surface shaders, but I can't figure out how to compensate for distance in depth- Shader "Custom/SurfaceDepthShader" { Properties { _ColorShallow ("Color Shallow", Color) = (1,1,1,1) _ColorDeep ("Color Deep",
Recommends Basic · 2024-02 · Game Development Stack Exchange · on “Approach to rendering a planet texture”
The way I've approached this before is to use two cameras, one for "large scale" objects, another for the ship/foreground. You can use different coordinate systems, scale movement, etc... This may break down for certain visual interactions between foreground and large-scale objects. You may also find issues with the number of verts you'd need for a smooth horizon at that scale. An alternative approach to a sphere is the CubeSphere demo'd by Sebastian Lague here: [this video] (and throughout that series)
Cites Kevin · 2020-07 · Game Development Stack Exchange · on “Generating the distance of an intersection through a box from the camera in Unity C#”
@Spaceguy99 Based on skimming the video more, I think his water has the same side-effect: the appearance of the water varies with angle. It's just less obvious because his ocean is spherical instead of flat; see e.g. the camera movement around 18:01 [this video]
Cites Spaceguy99 · 2020-07 · Game Development Stack Exchange · on “Generating the distance of an intersection through a box from the camera in Unity C#”
I understandhow to do that, but of course, I don't want the entire screen. Sorry, this is the right timestamp- [this video]
Cites Spaceguy99 · 2020-07 · Game Development Stack Exchange · on “Generating the distance of an intersection through a box from the camera in Unity C#”
@DMGregory Sorry, wrong timestamp- [this video] This is sort of about cube ray intersection, but the samples I am seeing do not apply to a shader and also do not include a way to get distance travelled through the cube.
Cites Dmytro Brazhnyk · 2021-09 · Game Development Stack Exchange · on “Terrain Generation for Tile-Based 2D Platformer”
You need some kind of coherent noise function, I would recommend go with Perlin or OpenSimplex noise, it is well known algorithm and there many implementation of same functions for different languages: C/C++, C#, Python, Java, JS etc... Basically you just need to use noise function to generate value for x/y coordinate and apply math function on top of that to get desired effect. Than you can can generate many map for different type of tiles, and mix them. For example every type of minerals can have separate map. For example let's say you have mineral A and mineral B. Noise function with seed A for Mineral A, will give you certain value in point (x,y), and same way another noise value for Min