/// <summary> /// Sets up the provided Material to be used with this NoiseSettings instance. Some assumptions are made /// here as far as definitions and variable declarations in the Material's Shader go. /// float4 _NoiseTranslation, float4 _NoiseRotation, float4 _NoiseScale, and float4x4 _NoiseTransform are /// assumed to be declared. Sets up the Material using the NoiseType and FractalType SetupMaterial /// functions. /// </summary> /// <param name="mat"> The Material to set up for use with this NoiseSettings instance </param> public void SetupMaterial(Material mat) { INoiseType noiseType = NoiseLib.GetNoiseTypeInstance(domainSettings.noiseTypeName); IFractalType fractalType = NoiseLib.GetFractalTypeInstance(domainSettings.fractalTypeName); // set individual transform info mat.SetVector(ShaderStrings.translation, transformSettings.translation); mat.SetVector(ShaderStrings.rotation, transformSettings.rotation); mat.SetVector(ShaderStrings.scale, transformSettings.scale); // set full transform matrix mat.SetMatrix(ShaderStrings.transform, trs); noiseType?.SetupMaterial(mat, domainSettings.noiseTypeParams); fractalType?.SetupMaterial(mat, domainSettings.fractalTypeParams); if (useTextureForPositions) { mat.EnableKeyword("USE_NOISE_TEXTURE"); mat.SetTexture("_NoiseTex", positionTexture); } else { mat.DisableKeyword("USE_NOISE_TEXTURE"); } }
/// <summary> /// Returns a Material reference to the default blit material for the given NoiseSettings object. /// </summary> /// <remarks> /// Internally, this uses noise.domainSettings.fractalTypeName to get it's FractalType /// </remarks> /// <returns> A reference to the default blit Material for the specified NoiseSettings instance </returns> public static Material GetDefaultBlitMaterial(NoiseSettings noise) { IFractalType fractal = NoiseLib.GetFractalTypeInstance(noise.domainSettings.fractalTypeName); if (fractal == null) { return(null); } return(GetDefaultBlitMaterial(fractal.GetType())); }
private void DomainSettingsGUI() { noiseTypeName.stringValue = NoiseLib.NoiseTypePopup(Styles.noiseType, noiseTypeName.stringValue); INoiseType noiseType = NoiseLib.GetNoiseTypeInstance(noiseTypeName.stringValue); noiseTypeParams.stringValue = noiseType?.DoGUI(noiseTypeParams.stringValue); fractalTypeName.stringValue = NoiseLib.FractalTypePopup(Styles.fractalType, fractalTypeName.stringValue); IFractalType fractalType = NoiseLib.GetFractalTypeInstance(fractalTypeName.stringValue); fractalTypeParams.stringValue = fractalType?.DoGUI(fractalTypeParams.stringValue); }
/// <summary> /// Sets up the provided Material to be used with this NoiseSettings instance. Some assumptions are made /// here as far as definitions and variable declarations in the Material's Shader go. /// float4 _NoiseTranslation, float4 _NoiseRotation, float4 _NoiseScale, and float4x4 _NoiseTransform are /// assumed to be declared. Sets up the Material using the NoiseType and FractalType SetupMaterial /// functions. /// </summary> /// <param name="mat"> The Material to set up for use with this NoiseSettings instance </param> public void SetupMaterial(Material mat) { INoiseType noiseType = NoiseLib.GetNoiseTypeInstance(domainSettings.noiseTypeName); IFractalType fractalType = NoiseLib.GetFractalTypeInstance(domainSettings.fractalTypeName); // set individual transform info mat.SetVector(ShaderStrings.translation, transformSettings.translation); mat.SetVector(ShaderStrings.rotation, transformSettings.rotation); mat.SetVector(ShaderStrings.scale, transformSettings.scale); // set full transform matrix mat.SetMatrix(ShaderStrings.transform, trs); noiseType?.SetupMaterial(mat, domainSettings.noiseTypeParams); fractalType?.SetupMaterial(mat, domainSettings.fractalTypeParams); }
private TerrainToolsAnalytics.IBrushParameter[] UpdateAnalyticParameters() { m_AnalyticsData.Clear(); SerializedProperty transformSettings = noiseSettingsGUI.serializedNoise.FindProperty("transformSettings"); SerializedProperty domainSettings = noiseSettingsGUI.serializedNoise.FindProperty("domainSettings"); SerializedProperty fractalTypeName = domainSettings.FindPropertyRelative("fractalTypeName"); SerializedProperty fractalTypeParams = domainSettings.FindPropertyRelative("fractalTypeParams"); //Add Generic, Transform, and Domain type settings to be sent as analytic data m_AnalyticsData.AddRange(new TerrainToolsAnalytics.IBrushParameter[] { //Generic Settings new TerrainToolsAnalytics.BrushParameter <string> { Name = Styles.coordSpace.text, Value = m_toolSettings.coordSpace.ToString() }, //Transform Settings new TerrainToolsAnalytics.BrushParameter <Vector3> { Name = "Translation", Value = transformSettings.FindPropertyRelative("translation").vector3Value }, new TerrainToolsAnalytics.BrushParameter <Vector3> { Name = "Rotation", Value = transformSettings.FindPropertyRelative("rotation").vector3Value }, new TerrainToolsAnalytics.BrushParameter <Vector3> { Name = "Scale", Value = transformSettings.FindPropertyRelative("scale").vector3Value }, new TerrainToolsAnalytics.BrushParameter <bool> { Name = NoiseSettingsGUI.Styles.flipScaleX.text, Value = transformSettings.FindPropertyRelative("flipScaleX").boolValue }, new TerrainToolsAnalytics.BrushParameter <bool> { Name = NoiseSettingsGUI.Styles.flipScaleY.text, Value = transformSettings.FindPropertyRelative("flipScaleY").boolValue }, new TerrainToolsAnalytics.BrushParameter <bool> { Name = NoiseSettingsGUI.Styles.flipScaleZ.text, Value = transformSettings.FindPropertyRelative("flipScaleZ").boolValue }, //Domain new TerrainToolsAnalytics.BrushParameter <string> { Name = NoiseSettingsGUI.Styles.noiseType.text, Value = domainSettings.FindPropertyRelative("noiseTypeName").stringValue }, new TerrainToolsAnalytics.BrushParameter <string> { Name = NoiseSettingsGUI.Styles.fractalType.text, Value = domainSettings.FindPropertyRelative("fractalTypeName").stringValue } } ); //Add fractal specific settings to be sent as analytic data IFractalType fractalType = NoiseLib.GetFractalTypeInstance(fractalTypeName.stringValue); switch (domainSettings.FindPropertyRelative("fractalTypeName").stringValue) { case "Fbm": FbmFractalType.FbmFractalInput fbmFractalSettings = (FbmFractalType.FbmFractalInput)fractalType.FromSerializedString(fractalTypeParams.stringValue); m_AnalyticsData.AddRange(new TerrainToolsAnalytics.IBrushParameter[] { new TerrainToolsAnalytics.BrushParameter <float> { Name = FbmFractalType.Styles.octaves.text, Value = fbmFractalSettings.octaves }, new TerrainToolsAnalytics.BrushParameter <float> { Name = FbmFractalType.Styles.amplitude.text, Value = fbmFractalSettings.amplitude }, new TerrainToolsAnalytics.BrushParameter <float> { Name = FbmFractalType.Styles.persistence.text, Value = fbmFractalSettings.persistence }, new TerrainToolsAnalytics.BrushParameter <float> { Name = FbmFractalType.Styles.frequency.text, Value = fbmFractalSettings.frequency }, new TerrainToolsAnalytics.BrushParameter <float> { Name = FbmFractalType.Styles.lacunarity.text, Value = fbmFractalSettings.lacunarity }, new TerrainToolsAnalytics.BrushParameter <bool> { Name = FbmFractalType.Styles.domainWarpSettings.text, Value = fbmFractalSettings.warpEnabled }, new TerrainToolsAnalytics.BrushParameter <float> { Name = FbmFractalType.Styles.warpIterations.text, Value = fbmFractalSettings.warpIterations }, new TerrainToolsAnalytics.BrushParameter <float> { Name = FbmFractalType.Styles.warpStrength.text, Value = fbmFractalSettings.warpStrength }, new TerrainToolsAnalytics.BrushParameter <Vector4> { Name = FbmFractalType.Styles.warpOffsets.text, Value = fbmFractalSettings.warpOffsets }, }); break; case "Strata": StrataFractalType.StrataFractalInput strataFractalSettings = (StrataFractalType.StrataFractalInput)fractalType.FromSerializedString(fractalTypeParams.stringValue); m_AnalyticsData.AddRange(new TerrainToolsAnalytics.IBrushParameter[] { new TerrainToolsAnalytics.BrushParameter <float> { Name = StrataFractalType.Styles.octaves.text, Value = strataFractalSettings.octaves }, new TerrainToolsAnalytics.BrushParameter <float> { Name = StrataFractalType.Styles.amplitude.text, Value = strataFractalSettings.amplitude }, new TerrainToolsAnalytics.BrushParameter <float> { Name = StrataFractalType.Styles.persistence.text, Value = strataFractalSettings.persistence }, new TerrainToolsAnalytics.BrushParameter <float> { Name = StrataFractalType.Styles.frequency.text, Value = strataFractalSettings.frequency }, new TerrainToolsAnalytics.BrushParameter <float> { Name = StrataFractalType.Styles.lacunarity.text, Value = strataFractalSettings.lacunarity }, new TerrainToolsAnalytics.BrushParameter <bool> { Name = StrataFractalType.Styles.domainWarpSettings.text, Value = strataFractalSettings.warpEnabled }, new TerrainToolsAnalytics.BrushParameter <float> { Name = StrataFractalType.Styles.warpIterations.text, Value = strataFractalSettings.warpIterations }, new TerrainToolsAnalytics.BrushParameter <float> { Name = StrataFractalType.Styles.warpStrength.text, Value = strataFractalSettings.warpStrength }, new TerrainToolsAnalytics.BrushParameter <Vector4> { Name = StrataFractalType.Styles.warpOffsets.text, Value = strataFractalSettings.warpOffsets }, new TerrainToolsAnalytics.BrushParameter <float> { Name = StrataFractalType.Styles.strataOffset.text, Value = strataFractalSettings.strataOffset }, new TerrainToolsAnalytics.BrushParameter <float> { Name = StrataFractalType.Styles.strataScale.text, Value = strataFractalSettings.strataScale }, }); break; case "None": default: break; } return(m_AnalyticsData.ToArray()); }