private void UpdateColorMapFromControls(bool forceUpdate = false) { if (colorMapEditorType != ColorMapEditorType.Controls) { return; } AllocateColorMapData(); if (forceUpdate || !colorMapEditorGradient.Equals(colorMapEditorGradientOld) || colorMapEditorContrast_ != colorMapEditorContrast || colorMapEditorBrightness_ != colorMapEditorBrightness || colorMapEditorPosterize_ != colorMapEditorPosterize) { colorMapEditorGradientOld.CopyFrom(colorMapEditorGradient); colorMapEditorContrast_ = colorMapEditorContrast; colorMapEditorBrightness_ = colorMapEditorBrightness; colorMapEditorPosterize_ = colorMapEditorPosterize; AllocateColorMapData(); // Populate colorMapData for (int i = 0; i < 256; i++) { // Apply contrast, brightness and posterization on the grayscale value double value = (double)i / 255.0; // Constrast and brightness double contrastFactor = colorMapEditorContrast + 1; // UI runs from -1 to 1 value = (value - 0.5) * contrastFactor + 0.5 + colorMapEditorBrightness; // Posterization if (colorMapEditorPosterize > 0.0f) { // The posterization slider feels more useful if the progression is exponential. The function is emprically tuned. const double posterizationBase = 50.0; double posterize = (Math.Pow(posterizationBase, colorMapEditorPosterize) - 1.0) / (posterizationBase - 1.0); value = Math.Round(value / posterize) * posterize; } // Clamp to [0, 1] value = Math.Min(Math.Max(value, 0.0), 1.0); // Map to value to color Color color = colorMapEditorGradient.Evaluate((float)value); WriteColorToColorMap(i, ref color); } styleDirty = true; } }
public bool Equals(Param other) { if (other.type != type || other.name != name) { return(false); } switch (type) { case ParamType.AngleLimits: return(angleLimitsValue == other.angleLimitsValue); case ParamType.Bool: return(boolValue == other.boolValue); case ParamType.Color: return(colorValue == other.colorValue); case ParamType.Object: return(objectValue == other.objectValue); case ParamType.Gradient: return(gradientValue.Equals(other.gradientValue)); case ParamType.Curve: return(curveValue.Equals(other.curveValue)); case ParamType.Float: return(floatValue == other.floatValue); case ParamType.String: return(stringValue == other.stringValue); case ParamType.Vector3: return(vector3Value == other.vector3Value); case ParamType.Rotation: return(quaternionValue == other.quaternionValue); case ParamType.Integer: return(intValue == other.intValue); case ParamType.Layer: return(layerValue == other.layerValue); } throw new System.NotImplementedException(); }
public static bool GradientField(ref Gradient curValue, string label, params GUILayoutOption[] guiLayout) { Gradient newValue = new Gradient { colorKeys = curValue.colorKeys, alphaKeys = curValue.alphaKeys, }; BeginIndentSpaces(); newValue = EditorGUILayout.GradientField(label, newValue, guiLayout); EndIndentSpaces(); FinishedElementDrawingCall(); if (!newValue.Equals(curValue)) { ShouldBeDirty(); curValue = newValue; return(true); } return(false); }
// Start is called before the first frame update void Start() { colorKey = new GradientColorKey[3]; colorKey[0].color = ColorLeft[0]; colorKey[0].time = 0.33f; colorKey[1].color = ColorLeft[1]; colorKey[1].time = 0.67f; colorKey[2].color = ColorLeft[2]; colorKey[2].time = 1f; alphaKey = new GradientAlphaKey[3]; alphaKey[0].alpha = 1f; alphaKey[0].time = 0.33f; alphaKey[1].alpha = 1f; alphaKey[1].time = 0.67f; alphaKey[2].alpha = 1f; alphaKey[2].time = 1f; gradientLeft.mode = GradientMode.Fixed; gradientLeft.SetKeys(colorKey, alphaKey); //meshF = GetComponent<MeshFilter>(); //mesh = meshF.mesh; //vertices = mesh.vertices; Debug.Log(gradientBack.Equals(gradientForward)); //foreach (var item in vertSort) //{ // Instantiate(Point, new Vector3(item.x, item.y, item.z), Quaternion.identity); //} }
public override void CommonRender(LightweightRenderPipeline pipelineInstance, ScriptableRenderContext context, Camera cameraSrp) { #endif if (!MapsAreAssigned()) { return; } var roll = cameraSrp.transform.localEulerAngles.z; Shader.SetGlobalFloat(CameraRoll, roll); Shader.SetGlobalMatrix(InvViewProjection, (GL.GetGPUProjectionMatrix(cameraSrp.projectionMatrix, false) * cameraSrp.worldToCameraMatrix).inverse); //// Water matrix //const float quantizeValue = 6.25f; //const float forwards = 10f; //const float yOffset = -0.25f; //var newPos = cameraSrp.transform.TransformPoint(Vector3.forward * forwards); //newPos.y = yOffset; //newPos.x = quantizeValue * (int)(newPos.x / quantizeValue); //newPos.z = quantizeValue * (int)(newPos.z / quantizeValue); //var matrix = Matrix4x4.TRS(newPos + transform.position, Quaternion.identity, Vector3.one); // transform.localToWorldMatrix; //Debug.Log("draw mesh"); //foreach (var mesh in defaultWaterMeshes) //{ // Graphics.DrawMesh(mesh, // matrix, // defaultSeaMaterial, // gameObject.layer, // cameraSrp, // 0, // null, // ShadowCastingMode.Off, // true, // null, // LightProbeUsage.Off, // null); //} //reinitalize the waves etc. if any value changes if (_waterDepthVisibility != WaterDepthVisibility || !_absorptionRamp.Equals(AbsorptionRamp) || !_scatterRamp.Equals(ScatterRamp) || _basicWaveSettings.amplitude != BasicWaveSettings.amplitude || _basicWaveSettings.direction != BasicWaveSettings.direction || _basicWaveSettings.numWaves != BasicWaveSettings.numWaves || _basicWaveSettings.wavelength != BasicWaveSettings.wavelength) { Debug.Log("Water waves init called again..."); _waterDepthVisibility = WaterDepthVisibility; _absorptionRamp = new Gradient { alphaKeys = AbsorptionRamp.alphaKeys, colorKeys = AbsorptionRamp.colorKeys, mode = AbsorptionRamp.mode }; _scatterRamp = new Gradient { alphaKeys = ScatterRamp.alphaKeys, colorKeys = ScatterRamp.colorKeys, mode = ScatterRamp.mode }; _basicWaveSettings = new BasicWaves(BasicWaveSettings.amplitude, BasicWaveSettings.direction, BasicWaveSettings.wavelength); _basicWaveSettings.numWaves = BasicWaveSettings.numWaves; Init(); } foreach (var shade in Shades) { if (shade.MaterialToChange.HasProperty("_BumpScale")) { shade.MaterialToChange.SetFloat("_BumpScale", WaveDetail); } if (shade.MaterialToChange.HasProperty("_WaveRefraction")) { shade.MaterialToChange.SetFloat("_WaveRefraction", WaveRefraction); } if (WaterShadow) { shade.MaterialToChange.DisableKeyword("_RECEIVE_SHADOWS_OFF"); } else { shade.MaterialToChange.EnableKeyword("_RECEIVE_SHADOWS_OFF"); } if (UseCustomDepth) { shade.MaterialToChange.EnableKeyword("DO_NOT_USE_DEPTH"); } else { shade.MaterialToChange.DisableKeyword("DO_NOT_USE_DEPTH"); } //if (shade.MaterialToChange.HasProperty("_ManualDistanceSurface")) // shade.MaterialToChange.SetFloat("_ManualDistanceSurface", ManualDistanceForSurface); //if (shade.MaterialToChange.HasProperty("_ManualDistanceDepth")) // shade.MaterialToChange.SetFloat("_ManualDistanceDepth", ManualDistanceForDepth); } }
/// <inheritdoc /> public bool Equals([AllowNull] Marker other) { if (other == null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Symbol == other.Symbol || Symbol != null && Symbol.Equals(other.Symbol) ) && ( Equals(SymbolArray, other.SymbolArray) || SymbolArray != null && other.SymbolArray != null && SymbolArray.SequenceEqual(other.SymbolArray) ) && ( Opacity == other.Opacity || Opacity != null && Opacity.Equals(other.Opacity) ) && ( Equals(OpacityArray, other.OpacityArray) || OpacityArray != null && other.OpacityArray != null && OpacityArray.SequenceEqual(other.OpacityArray) ) && ( Size == other.Size || Size != null && Size.Equals(other.Size) ) && ( Equals(SizeArray, other.SizeArray) || SizeArray != null && other.SizeArray != null && SizeArray.SequenceEqual(other.SizeArray) ) && ( MaxDisplayed == other.MaxDisplayed || MaxDisplayed != null && MaxDisplayed.Equals(other.MaxDisplayed) ) && ( SizeRef == other.SizeRef || SizeRef != null && SizeRef.Equals(other.SizeRef) ) && ( SizeMin == other.SizeMin || SizeMin != null && SizeMin.Equals(other.SizeMin) ) && ( SizeMode == other.SizeMode || SizeMode != null && SizeMode.Equals(other.SizeMode) ) && ( Line == other.Line || Line != null && Line.Equals(other.Line) ) && ( Gradient == other.Gradient || Gradient != null && Gradient.Equals(other.Gradient) ) && ( Color == other.Color || Color != null && Color.Equals(other.Color) ) && ( Equals(ColorArray, other.ColorArray) || ColorArray != null && other.ColorArray != null && ColorArray.SequenceEqual(other.ColorArray) ) && ( CAuto == other.CAuto || CAuto != null && CAuto.Equals(other.CAuto) ) && ( CMin == other.CMin || CMin != null && CMin.Equals(other.CMin) ) && ( CMax == other.CMax || CMax != null && CMax.Equals(other.CMax) ) && ( CMid == other.CMid || CMid != null && CMid.Equals(other.CMid) ) && ( ColorScale == other.ColorScale || ColorScale != null && ColorScale.Equals(other.ColorScale) ) && ( AutoColorScale == other.AutoColorScale || AutoColorScale != null && AutoColorScale.Equals(other.AutoColorScale) ) && ( ReverseScale == other.ReverseScale || ReverseScale != null && ReverseScale.Equals(other.ReverseScale) ) && ( ShowScale == other.ShowScale || ShowScale != null && ShowScale.Equals(other.ShowScale) ) && ( ColorBar == other.ColorBar || ColorBar != null && ColorBar.Equals(other.ColorBar) ) && ( ColorAxis == other.ColorAxis || ColorAxis != null && ColorAxis.Equals(other.ColorAxis) ) && ( SymbolSrc == other.SymbolSrc || SymbolSrc != null && SymbolSrc.Equals(other.SymbolSrc) ) && ( OpacitySrc == other.OpacitySrc || OpacitySrc != null && OpacitySrc.Equals(other.OpacitySrc) ) && ( SizeSrc == other.SizeSrc || SizeSrc != null && SizeSrc.Equals(other.SizeSrc) ) && ( ColorSrc == other.ColorSrc || ColorSrc != null && ColorSrc.Equals(other.ColorSrc) )); }
public void SwitchColors() { _currentColor = _currentColor.Equals(gradientA) ? gradientB : gradientA; }
void Update() { if (Input.GetKeyDown(KeyCode.Keypad1)) { LerpToColourIndex(1, 3); } if (Input.GetKeyDown(KeyCode.Keypad2)) { LerpToColourIndex(2, 3); } if (Input.GetKeyDown(KeyCode.Keypad3)) { LerpToColourIndex(3, 3); } if (bIsGradientLerping) { trailRenderer.colorGradient = Util.Gradient.Lerp(trailRenderer.colorGradient, targetGradient /*TODO: Use array index*/, Time.deltaTime / gradientLerpDivider); gradientLerpTimer += (Time.deltaTime / gradientLerpDivider); if (Gradient.Equals(trailRenderer.colorGradient, targetGradient)) { bIsGradientLerping = false; } } if (useWobble) { if ((targetWobblePos + targetYPos) > (targetYPos + wobbleRange) || (targetYPos + targetWobblePos) < (targetYPos - wobbleRange)) { invertWobble = !invertWobble; } if (!invertWobble) { targetWobblePos += (Time.deltaTime * wobbleMultiplier); } else { targetWobblePos -= (Time.deltaTime * wobbleMultiplier); } } if (useLerp) { if (isLerping) { lerpPosSpeed = Mathf.Lerp(lerpPosSpeedMinMax.x, lerpPosSpeedMinMax.y, 0.5f /*0 - 1*/); lerpPosTimer += Time.deltaTime * lerpPosSpeed; transform.localPosition = Vector3.Lerp(startPos, endPos, Mathf.Clamp01(lerpPosTimer)); if (lerpPosTimer >= 1) { lerpPosTimer -= 1; if (forward) { currentNumber += stepSize; currentIt++; } else { currentNumber -= stepSize; currentIt--; } if (currentIt > 0 && currentIt < maxIt) { SetLerpPosition(); } else // current iteration has hit 0 or maxiteration { if (repeat) { if (invert) { forward = !forward; SetLerpPosition(); } else { currentNumber = numberStart; currentIt = 0; SetLerpPosition(); } } else { isLerping = false; } } } } } if (!useLerp) { phyllotaxisPos = CalculatePhyllotaxis(degree, scale, currentNumber); transform.localPosition = new Vector3(phyllotaxisPos.x, Mathf.Lerp(this.transform.position.y, Mathf.Lerp(transform.position.y, targetYPos + targetWobblePos, Time.deltaTime), Time.deltaTime * 5), phyllotaxisPos.y); //Debug.Log("targetYPos + targetWobblePos = " + targetYPos + targetWobblePos); currentNumber += stepSize; currentIt++; } }
public bool Equals(Gradient gradient) { return(gradientSource.Equals(gradient)); }