SebLague / Solar-System

Simple solar system experiment
https://www.youtube.com/watch?v=7axImc1sxa0
MIT License
1.15k stars 315 forks source link

How to use celestial body generator? #24

Open ddeneau opened 3 years ago

ddeneau commented 3 years ago

I keep getting this error whenever I update any values in the generator or click one of the generate options:

IndexOutOfRangeException: Invalid kernelIndex (0) passed, must be non-negative less than 1. ComputeHelper.GetThreadGroupSizes (UnityEngine.ComputeShader compute, System.Int32 kernelIndex) (at Assets/Script Utilities/ComputeHelper.cs:109) ComputeHelper.Run (UnityEngine.ComputeShader cs, System.Int32 numIterationsX, System.Int32 numIterationsY, System.Int32 numIterationsZ, System.Int32 kernelIndex) (at Assets/Script Utilities/ComputeHelper.cs:15) CelestialBodyShading.GenerateShadingData (UnityEngine.ComputeBuffer vertexBuffer) (at Assets/Celestial Body/Scripts/Shading/CelestialBodyShading.cs:45) CelestialBodyGenerator.GenerateTerrainMesh (UnityEngine.Mesh& mesh, System.Int32 resolution) (at Assets/Celestial Body/Scripts/CelestialBodyGenerator.cs:240) CelestialBodyGenerator.HandleEditModeGeneration () (at Assets/Celestial Body/Scripts/CelestialBodyGenerator.cs:115) CelestialBodyGenerator.Update () (at Assets/Celestial Body/Scripts/CelestialBodyGenerator.cs:48)

I just attached the script to the Mesh Holder under Constant Companion, then selected Constant Companion at the body.

What is the correct way to use it? also, is there anyway to resize the planets/moons

Delofon commented 3 years ago

This error isn't related to generating celestial bodies, really. Its roots is in one of the compute shaders not compiling. Judging by the name Constant Companion, it is a MoonShading.compute shader. (located in Assets/Scripts/Celestial/Shaders/Compute/Shading) Possible solution: at line 23, change this float sphereNoise = 1.#INF; to this float sphereNoise = 3.402823466e+38F; To change the planets' size, select the planet you want to resize, then in Inspector in Celestial Body (Script) change its radius. P.S. Also guessing by what you described, CelestialBodyGenerator isn't supposed to be added manually as a script to a celestial body - it's a script that will get attached to an object automatically afterwards in the process of creating a Solar System. What you really should be doing is creating new (or editing existing) Celestial Body Settings. There is a scene Planet to make that process easier.