public NoiseModule() { eType = eNoiseType.Perlin; bFBM = false; iPeriod = 4; iOctaves = 4; fPersistence = 0.5f; fScale = 2f; fRandomSeed = 114514.1515f; }
void OnGUI() { if (window == null) { GUILayout.Label("Missing window reference!"); return; } EditorGUILayout.BeginVertical("Box"); IntPow2Field("Noise Texture Size", ref mTexSize); mTexPeriod = EditorGUILayout.IntSlider("Noise Texture Period", mTexPeriod, 2, 10); EditorGUILayout.EndVertical(); EditorGUILayout.BeginHorizontal("Box"); EditorGUILayout.LabelField("Random Seed:", mRandomSeed.ToString()); if (GUILayout.Button("Random")) { mRandomSeed = UnityEngine.Random.Range(0.001f, 200000f); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginVertical("Box"); mType = (eNoiseType)EditorGUILayout.EnumPopup("Noise Type:", mType); mDim = (eNoiseDim)EditorGUILayout.EnumPopup("Noise Dimension:", mDim); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Box"); mFBM = EditorGUILayout.Toggle("Use fBm", mFBM); if (mFBM == true) { mOctaves = EditorGUILayout.IntSlider("fBm Octaves", mOctaves, 2, 10); mPersistence = EditorGUILayout.Slider("fBm Persistence", mPersistence, 0f, 1f); mScale = EditorGUILayout.Slider("fBm Scale", mScale, 1f, 10f); } EditorGUILayout.EndVertical(); if (GUILayout.Button("Generate")) { switch (mDim) { case eNoiseDim.Dimension2: GenerateNoise2D(); break; case eNoiseDim.Dimension3: GenerateNoise3D(); break; } } }
bool EnableFBM(eNoiseType _type) { bool enabledFBM = true; switch (_type) { case eNoiseType.None: case eNoiseType.WhiteNoise: enabledFBM = false; break; } return(enabledFBM); }
bool GetComputerShader_3D(eNoiseType _type, out string _path, out string _kanel, out RandomTable _randFunc) { bool res = false; _path = string.Empty; _kanel = string.Empty; _randFunc = null; switch (_type) { case eNoiseType.Perlin: _path = "TiliedPerlinNoise3D"; _kanel = "CS_PerlinNoise3D"; _randFunc = SetPerlinRandomTable; res = true; break; case eNoiseType.Voronoi: _path = "TiliedVoronoi3D"; _kanel = "CS_Voronoi3D"; _randFunc = SetCommonRandomTable; res = true; break; case eNoiseType.Cellular: _path = "TiliedCellularNoise3D"; _kanel = "CS_CellularNoise3D"; _randFunc = SetCommonRandomTable; res = true; break; case eNoiseType.PerlinWorley: _path = "TiliedPerlinWorley3D"; _kanel = "CS_PerlinWorley3D"; _randFunc = SetPerlinWorleyRandomTable; res = true; break; case eNoiseType.WhiteNoise: _path = "WhiteNoise3D"; _kanel = "CS_WhiteNoise3D"; _randFunc = SetCommonRandomTable; res = true; break; } return(res); }