public static Utils.FloatPackingPrecision GetFloatPackingPrecision() { if (Utils.ms_FloatPackingPrecision == Utils.FloatPackingPrecision.Undef) { Utils.ms_FloatPackingPrecision = (SystemInfo.graphicsShaderLevel >= 35 ? Utils.FloatPackingPrecision.High : Utils.FloatPackingPrecision.Low); } return(Utils.ms_FloatPackingPrecision); }
public void UpdateMaterialAndBounds() { object obj; Debug.Assert(this.m_Master); this.material.renderQueue = Config.Instance.geometryRenderQueue; float mMaster = this.m_Master.coneAngle * 0.0174532924f / 2f; this.material.SetVector("_ConeSlopeCosSin", new Vector2(Mathf.Cos(mMaster), Mathf.Sin(mMaster))); Vector2 vector2 = new Vector2(Mathf.Max(this.m_Master.coneRadiusStart, 0.0001f), Mathf.Max(this.m_Master.coneRadiusEnd, 0.0001f)); this.material.SetVector("_ConeRadius", vector2); float single = Mathf.Sign(this.m_Master.coneApexOffsetZ) * Mathf.Max(Mathf.Abs(this.m_Master.coneApexOffsetZ), 0.0001f); this.material.SetFloat("_ConeApexOffsetZ", single); if (this.m_Master.colorMode != ColorMode.Gradient) { this.material.DisableKeyword("VLB_COLOR_GRADIENT_MATRIX_HIGH"); this.material.DisableKeyword("VLB_COLOR_GRADIENT_MATRIX_LOW"); this.material.SetColor("_ColorFlat", this.m_Master.color); } else { Utils.FloatPackingPrecision floatPackingPrecision = Utils.GetFloatPackingPrecision(); this.material.EnableKeyword((floatPackingPrecision == Utils.FloatPackingPrecision.High ? "VLB_COLOR_GRADIENT_MATRIX_HIGH" : "VLB_COLOR_GRADIENT_MATRIX_LOW")); this.m_ColorGradientMatrix = this.m_Master.colorGradient.SampleInMatrix((int)floatPackingPrecision); } if (!Consts.BlendingMode_AlphaAsBlack[this.m_Master.blendingModeAsInt]) { this.material.DisableKeyword("ALPHA_AS_BLACK"); } else { this.material.EnableKeyword("ALPHA_AS_BLACK"); } this.material.SetInt("_BlendSrcFactor", (int)Consts.BlendingMode_SrcFactor[this.m_Master.blendingModeAsInt]); this.material.SetInt("_BlendDstFactor", (int)Consts.BlendingMode_DstFactor[this.m_Master.blendingModeAsInt]); this.material.SetFloat("_AlphaInside", this.m_Master.alphaInside); this.material.SetFloat("_AlphaOutside", this.m_Master.alphaOutside); this.material.SetFloat("_AttenuationLerpLinearQuad", this.m_Master.attenuationLerpLinearQuad); this.material.SetFloat("_DistanceFadeStart", this.m_Master.fadeStart); this.material.SetFloat("_DistanceFadeEnd", this.m_Master.fadeEnd); this.material.SetFloat("_DistanceCamClipping", this.m_Master.cameraClippingDistance); this.material.SetFloat("_FresnelPow", Mathf.Max(0.001f, this.m_Master.fresnelPow)); this.material.SetFloat("_GlareBehind", this.m_Master.glareBehind); this.material.SetFloat("_GlareFrontal", this.m_Master.glareFrontal); Material material = this.material; if (this.m_Master.geomCap) { obj = 1; } else { obj = null; } material.SetFloat("_DrawCap", (float)obj); if (this.m_Master.depthBlendDistance <= 0f) { this.material.DisableKeyword("VLB_DEPTH_BLEND"); } else { this.material.EnableKeyword("VLB_DEPTH_BLEND"); this.material.SetFloat("_DepthBlendDistance", this.m_Master.depthBlendDistance); } if (!this.m_Master.noiseEnabled || this.m_Master.noiseIntensity <= 0f || !Noise3D.isSupported) { this.material.DisableKeyword("VLB_NOISE_3D"); } else { Noise3D.LoadIfNeeded(); this.material.EnableKeyword("VLB_NOISE_3D"); this.material.SetVector("_NoiseLocal", new Vector4(this.m_Master.noiseVelocityLocal.x, this.m_Master.noiseVelocityLocal.y, this.m_Master.noiseVelocityLocal.z, this.m_Master.noiseScaleLocal)); this.material.SetVector("_NoiseParam", new Vector3(this.m_Master.noiseIntensity, (this.m_Master.noiseVelocityUseGlobal ? 1f : 0f), (this.m_Master.noiseScaleUseGlobal ? 1f : 0f))); } this.ComputeLocalMatrix(); }
public void UpdateMaterialAndBounds() { Debug.Assert(Object.op_Implicit((Object)this.m_Master)); this.material.set_renderQueue(Config.Instance.geometryRenderQueue); float num = (float)((double)this.m_Master.coneAngle * (Math.PI / 180.0) / 2.0); this.material.SetVector("_ConeSlopeCosSin", Vector4.op_Implicit(new Vector2(Mathf.Cos(num), Mathf.Sin(num)))); Vector2 vector2; ((Vector2) ref vector2).\u002Ector(Mathf.Max(this.m_Master.coneRadiusStart, 0.0001f), Mathf.Max(this.m_Master.coneRadiusEnd, 0.0001f)); this.material.SetVector("_ConeRadius", Vector4.op_Implicit(vector2)); this.material.SetFloat("_ConeApexOffsetZ", Mathf.Sign(this.m_Master.coneApexOffsetZ) * Mathf.Max(Mathf.Abs(this.m_Master.coneApexOffsetZ), 0.0001f)); if (this.m_Master.colorMode == ColorMode.Gradient) { Utils.FloatPackingPrecision packingPrecision = Utils.GetFloatPackingPrecision(); this.material.EnableKeyword(packingPrecision == Utils.FloatPackingPrecision.High ? "VLB_COLOR_GRADIENT_MATRIX_HIGH" : "VLB_COLOR_GRADIENT_MATRIX_LOW"); this.m_ColorGradientMatrix = this.m_Master.colorGradient.SampleInMatrix((int)packingPrecision); } else { this.material.DisableKeyword("VLB_COLOR_GRADIENT_MATRIX_HIGH"); this.material.DisableKeyword("VLB_COLOR_GRADIENT_MATRIX_LOW"); this.material.SetColor("_ColorFlat", this.m_Master.color); } if (Consts.BlendingMode_AlphaAsBlack[this.m_Master.blendingModeAsInt]) { this.material.EnableKeyword("ALPHA_AS_BLACK"); } else { this.material.DisableKeyword("ALPHA_AS_BLACK"); } this.material.SetInt("_BlendSrcFactor", (int)Consts.BlendingMode_SrcFactor[this.m_Master.blendingModeAsInt]); this.material.SetInt("_BlendDstFactor", (int)Consts.BlendingMode_DstFactor[this.m_Master.blendingModeAsInt]); this.material.SetFloat("_AlphaInside", this.m_Master.alphaInside); this.material.SetFloat("_AlphaOutside", this.m_Master.alphaOutside); this.material.SetFloat("_AttenuationLerpLinearQuad", this.m_Master.attenuationLerpLinearQuad); this.material.SetFloat("_DistanceFadeStart", this.m_Master.fadeStart); this.material.SetFloat("_DistanceFadeEnd", this.m_Master.fadeEnd); this.material.SetFloat("_DistanceCamClipping", this.m_Master.cameraClippingDistance); this.material.SetFloat("_FresnelPow", Mathf.Max(1f / 1000f, this.m_Master.fresnelPow)); this.material.SetFloat("_GlareBehind", this.m_Master.glareBehind); this.material.SetFloat("_GlareFrontal", this.m_Master.glareFrontal); this.material.SetFloat("_DrawCap", this.m_Master.geomCap ? 1f : 0.0f); if ((double)this.m_Master.depthBlendDistance > 0.0) { this.material.EnableKeyword("VLB_DEPTH_BLEND"); this.material.SetFloat("_DepthBlendDistance", this.m_Master.depthBlendDistance); } else { this.material.DisableKeyword("VLB_DEPTH_BLEND"); } if (this.m_Master.noiseEnabled && (double)this.m_Master.noiseIntensity > 0.0 && Noise3D.isSupported) { Noise3D.LoadIfNeeded(); this.material.EnableKeyword("VLB_NOISE_3D"); this.material.SetVector("_NoiseLocal", new Vector4((float)this.m_Master.noiseVelocityLocal.x, (float)this.m_Master.noiseVelocityLocal.y, (float)this.m_Master.noiseVelocityLocal.z, this.m_Master.noiseScaleLocal)); this.material.SetVector("_NoiseParam", Vector4.op_Implicit(new Vector3(this.m_Master.noiseIntensity, this.m_Master.noiseVelocityUseGlobal ? 1f : 0.0f, this.m_Master.noiseScaleUseGlobal ? 1f : 0.0f))); } else { this.material.DisableKeyword("VLB_NOISE_3D"); } this.ComputeLocalMatrix(); }