Coder Social home page Coder Social logo

seblague / procedural-planets Goto Github PK

View Code? Open in Web Editor NEW
586.0 43.0 319.0 23.52 MB

Home Page: https://www.youtube.com/watch?v=QN39W020LqU&index=2&t=0s&list=PLFt_AvWsXl0cONs3T0By4puYy6GM22ko8

License: MIT License

C# 100.00%
procedural-generation unity-tutorial

procedural-planets's Introduction

Procedural-Planets

Simple procedural planet generation in Unity. Watch tutorial series here.

procedural-planets's People

Contributors

seblague avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

procedural-planets's Issues

Getting an error when trying to change cube/sphere resolution in inspector [EP02]

Error:

`NullReferenceException: Object reference not set to an instance of an object
Planet.GenerateMesh () (at Assets/Planet.cs:66)
Planet.GeneratePlanet () (at Assets/Planet.cs:49)
PlanetEditor.OnInspectorGUI () (at Assets/editor/PlanetEditor.cs:17)
UnityEditor.UIElements.InspectorElement+<CreateIMGUIInspectorFromEditor>c__AnonStorey1.<>m__0 () (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorElement.cs:501)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr) (at C:/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179)

Relevant code (plus context. I tried to put the line numbers in but it messes with formatting, rip):
Planet.cs:
lines 47-51

    public void GeneratePlanet() {
        Initialize();
        GenerateMesh();
        GenerateColours();
    }

and
lines 64-68

    void GenerateMesh() {
        foreach (TerrainFace face in terrainFaces) {
            face.ConstructMesh();
        }
    }

PlanetEditor.cs:
line 17
planet.GeneratePlanet();

TerrainFace.cs

public void ConstructMesh() {
        Vector3[] vertices = new Vector3[resolution * resolution];
        int[] triangles = new int[(resolution - 1) * (resolution - 1) * 6];
        int triIndex = 0;

        for (int y = 0; y < resolution; y++) {
            for (int x = 0; x < resolution; x++) {
                int i = x + y * resolution;
                Vector2 percent = new Vector2(x, y) / (resolution - 1);
                Vector3 pointOnUnitCube = localUp + (percent.x - .5f) * 2 * axisA + (percent.y - .5f) * 2 * axisB;
                Vector3 pointOnUnitSphere = pointOnUnitCube.normalized;
                vertices[i] = shapeGenerator.CalculatePointOnPlanet(pointOnUnitSphere);

                if (x != resolution - 1 && y != resolution - 1) {
                    triangles[triIndex] = i;
                    triangles[triIndex + 1] = i + resolution + 1;
                    triangles[triIndex + 2] = i + resolution;

                    triangles[triIndex + 3] = i;
                    triangles[triIndex + 4] = i + 1;
                    triangles[triIndex + 5] = i + resolution + 1;
                    triIndex += 6;
                }
            }
        }
        mesh.Clear();
        mesh.vertices = vertices;
        mesh.triangles = triangles;
        mesh.RecalculateNormals();
    }

I'm only at the end of EP02, but I should be able to change the color, radius, and resolution of the sphere in real time. This is the error I get when I try to change the resolution. I haven't even tried to change radius or color yet. This error has persisted in a few forms throughout EP01 and EP02 (I have not once been able to change resolution with the slider in the inspector). I've included my entire assets folder in case you want to check it out for a solution for me. Thanks in advance!
Assets.zip

ChangeCheckScope error

Ref: E02 - Planet editor
while creatinng the Planet Editor GUI the line:
"using (var check = new EditorGUI.ChangeCheckScope())"
Keeps throwing back the error that the name "ChangeCCheckSCope" doesnt exist in the type "EditorGUI"
My code is identical to the code shown on screen, does anyone know a fix for this?

Update i accidently had an outdated Unity engine installed lmao

Shader resetting to gray scale on Run or Save

Hey!

I am getting an issue with Unity 2019.x

After generating the planet, the shader works perfectly fine. But, as soon as you save the scene or press Run, the planet goes back to using what seems to be the default material and becomes all grey?

Im attaching the images that show this:

After clicking Generate Planet:

image

After clicking Save (or pressing CTRL + S):

image

Any hints of why this is happening?

EP05 | Vector4 & PBRGraph

Hello! I'm absolutely having a blast with your tutorial.

I just wanted to point out that with the current version of the lightweight render pipeline I'm getting an error when using a Vector2 property for _elevationMinMax and had to use a Vector4 like in the ColorGenerator.cs script to get the shader to compile right.

Again, so much fun. Keep making awesome stuff!

(Question) Mesh Terrain Faces Dynamic with Planet Resolution

The planet is generated with 6 terrain faces but lets say we wanted to generate a massive sphere and only generate parts of the planet at a time. In order to do this we would need more then 6 meshes, this is where it would be nice to make the terrain faces (meshes) dynamic with the planets resolution.

When I looked at the Planet.cs code, I saw that each terrain face used its own vector.

Vector3[] directions = { Vector3.up, Vector3.down, Vector3.left, Vector3.right, Vector3.forward, Vector3.back };

How could we create more vector directions in this array to account for more terrain faces?

My planet turns black on play/after play

Hi so this is how my planet looks and this is the message I get after clicking on the material on the planet script.

This is how it normally looks:

image

After play and clicking on the gradient customizer:

image

Thanks for any help!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.