Ejemplo n.º 1
0
        private void UpdateBlade()
        {
            float distance = Vector3.Distance(BladeEnd.transform.position, BladeStart.transform.position);
            float percent  = distance / bladeHeight;

            BladeSwordRenderer.transform.localScale = new Vector3(1.0f, percent, 1.0f);
            if (percent < 0.01f)
            {
                BladeSwordRenderer.gameObject.SetActive(false);
                BladeGlowRenderer.gameObject.SetActive(false);
            }
            else
            {
                BladeSwordRenderer.gameObject.SetActive(true);
                BladeGlowRenderer.gameObject.SetActive(true);
            }
            BladeSwordRenderer.GetPropertyBlock(swordBlock);
            if (Profile.BladeTexture != null)
            {
                swordBlock.SetTexture("_MainTex", Profile.BladeTexture);
            }

            float jitterBladeIntensity = percent * (1.0f + UnityEngine.Random.Range(0.0f, Profile.FlickerIntensity));

            swordBlock.SetColor("_TintColor", Profile.BladeColor * jitterBladeIntensity);
            swordBlock.SetFloat("_Intensity", Profile.BladeIntensity * jitterBladeIntensity);
            swordBlock.SetColor("_RimColor", Profile.BladeRimColor);
            swordBlock.SetFloat("_RimPower", Profile.BladeRimPower);
            swordBlock.SetFloat("_RimIntensity", Profile.BladeRimIntensity * jitterBladeIntensity);
            BladeSwordRenderer.SetPropertyBlock(swordBlock);

            BladeGlowRenderer.GetPropertyBlock(glowBlock);
            glowBlock.SetColor("_Color", Profile.GlowColor * jitterBladeIntensity);
            glowBlock.SetVector("_CapsuleStart", BladeStart.transform.position);
            glowBlock.SetVector("_CapsuleEnd", BladeEnd.transform.position);
            glowBlock.SetVector("_CapsuleScale", BladeGlowRenderer.transform.lossyScale);
            glowBlock.SetFloat("_GlowIntensity", Profile.GlowIntensity * jitterBladeIntensity);
            glowBlock.SetFloat("_GlowPower", Profile.GlowPower);
            glowBlock.SetFloat("_GlowFade", Profile.GlowFade);
            glowBlock.SetFloat("_GlowLengthPower", Profile.GlowLengthPower);
            glowBlock.SetFloat("_GlowDither", Profile.GlowDither);
            glowBlock.SetFloat("_GlowMaxRayLength", Profile.GlowMaxRayLength);
            glowBlock.SetFloat("_GlowMax", Profile.GlowMax);
            BladeGlowRenderer.SetPropertyBlock(glowBlock);
            BladeGlowRenderer.transform.position   = BladeStart.transform.position + ((BladeEnd.transform.position - BladeStart.transform.position) * 0.5f);
            BladeGlowRenderer.transform.up         = (BladeEnd.transform.position - BladeStart.transform.position).normalized;
            BladeGlowRenderer.transform.localScale = new Vector3(Profile.GlowScale, (BladeEnd.transform.position - BladeStart.transform.position).magnitude * 0.5f, Profile.GlowScale);
            Light.intensity = jitterBladeIntensity;
            Light.color     = Profile.GlowColor;
        }
    public void SetBrightness(float value)
    {
        if (mr == null)
        {
            return;
        }

        if (alwaysBright)
        {
            return;
        }

        mr.GetPropertyBlock(materialProperties);
        materialProperties.SetFloat("_SectorLight", value);
        mr.SetPropertyBlock(materialProperties);
    }
Ejemplo n.º 3
0
 void StartFlash()
 {
     if (meshRender == null)
     {
         Debug.LogError("mesh renderer missing"); return;
     }
     tweenFlash.Rewind(false);
     tweenFlash.Play().OnUpdate(delegate
     {
         matBlock.SetFloat("_StateIntensity", flashIns);
         if (meshRender != null)
         {
             meshRender.SetPropertyBlock(matBlock);
         }
     });
 }
Ejemplo n.º 4
0
        protected override void ProcessInternal()
        {
            if (beamGeometry)
            {
                if (materialPropertyBlock == null)
                {
                    materialPropertyBlock = new MaterialPropertyBlock();
                }


                beamGeometry.GetPropertyBlock(materialPropertyBlock);
                materialPropertyBlock.SetColor("_Color", color);
                materialPropertyBlock.SetFloat("_Intensity", intensity * intensityMultiplier);
                beamGeometry.SetPropertyBlock(materialPropertyBlock);
            }
        }
Ejemplo n.º 5
0
    // Start is called before the first frame update
    void Start()
    {
        MaterialPropertyBlock props = new MaterialPropertyBlock();
        MeshRenderer          renderer;
        int x = 0;

        foreach (GameObject obj in cacti)
        {
            cactiAmounts.Add(Random.Range(50f, 100f));
            props.SetFloat("_Amount", cactiAmounts[x]);

            renderer = obj.GetComponent <MeshRenderer>();
            renderer.SetPropertyBlock(props);
            x++;
        }
    }
    IEnumerator UpdateBattery()
    {
        while (Application.isPlaying)
        {
            f = OpenVR.System.GetFloatTrackedDeviceProperty(deviceIndex, ETrackedDeviceProperty.Prop_DeviceBatteryPercentage_Float, ref err);

            if (err == ETrackedPropertyError.TrackedProp_Success)
            {
                // Debug.Log("Battery level: " + f + " " + deviceIndex);
                materialPropertyBlock.SetFloat("Charge_", f);
                meshRenderer.SetPropertyBlock(materialPropertyBlock);
            }

            yield return(new WaitForSeconds(5));
        }
    }
Ejemplo n.º 7
0
    // Update is called once per frame
    void Update()
    {
        float dTime      = Time.deltaTime;
        int   frame      = (int)((_time + _offset) * Clip.frameRate);
        int   frameCount = (int)(Clip.frameRate * Clip.length);
        int   frameIdx   = frame % frameCount;

        _time += dTime;


        MaterialPropertyBlock mb = new MaterialPropertyBlock();

        mb.SetFloat("_FrameIdx", frameIdx);
        ;
        Graphics.DrawMeshInstanced(TargetMesh, 0, m, ml, mb);
    }
Ejemplo n.º 8
0
        protected override void Execute(CustomPassContext ctx)
        {
            if (ctx.hdCamera.camera != targetCamera)
            {
                return;
            }

            // For color we don't need to do anything
            if (mode != PrefabCaptureNode.OutputMode.Color)
            {
                properties.SetTexture("_NormalBufferTexture", ctx.cameraNormalBuffer);
                properties.SetFloat("_OutputMode", (int)mode);
                CoreUtils.SetRenderTarget(ctx.cmd, ctx.cameraColorBuffer, ClearFlag.Color, Color.clear);
                CoreUtils.DrawFullScreen(ctx.cmd, outputBufferMaterial, properties, shaderPassId: 0);
            }
        }
Ejemplo n.º 9
0
        void BlitCubemap(CommandBuffer cmd, Cubemap source, RenderTexture dest)
        {
            var propertyBlock = new MaterialPropertyBlock();

            for (int i = 0; i < 6; ++i)
            {
                CoreUtils.SetRenderTarget(cmd, dest, ClearFlag.None, 0, (CubemapFace)i);
                propertyBlock.SetTexture("_MainTex", source);
                propertyBlock.SetFloat("_faceIndex", (float)i);
                cmd.DrawProcedural(Matrix4x4.identity, m_BlitCubemapMaterial, 0, MeshTopology.Triangles, 3, 1, propertyBlock);
            }

            // Generate mipmap for our cubemap
            Debug.Assert(dest.autoGenerateMips == false);
            cmd.GenerateMips(dest);
        }
Ejemplo n.º 10
0
    void OnEnable()
    {
        m_MeshRenderer = GetComponent <MeshRenderer>();

        m_SpeedModID          = Shader.PropertyToID("SpeedMod");
        m_SpinDirectionID     = Shader.PropertyToID("SpinDirection");
        m_SpinIntensityID     = Shader.PropertyToID("SpinIntensity");
        m_BubbleSpawnAmountID = Shader.PropertyToID("BubbleSpawnAmount");

        m_Block = new MaterialPropertyBlock();
        m_Block.SetFloat(m_SpeedModID, m_CurrentTime);

        m_CurrentTime = 0;

        m_MeshRenderer.SetPropertyBlock(m_Block);
    }
Ejemplo n.º 11
0
    void Update()
    {
        _DirectionDisorder = _DirectionDisorderPos.position;

        m_PropertyBlock.SetFloat("_Value", _Value);
        m_PropertyBlock.SetFloat("_Speed", _Speed);
        m_PropertyBlock.SetFloat("_Outline", _Outline);
        m_PropertyBlock.SetFloat("_Width", _Width);
        m_PropertyBlock.SetFloat("_Test1", _Test1);
        m_PropertyBlock.SetFloat("_Test2", _Test2);
        m_PropertyBlock.SetFloat("_Disorder", _Disorder);
        m_PropertyBlock.SetVector("_DirectionDisorder", _DirectionDisorder);
        myRenderer.SetPropertyBlock(m_PropertyBlock);
    }
Ejemplo n.º 12
0
        protected override void OnTweenUpdate(float factor)
        {
            if (_CachedTarget != null)
            {
                float value = Mathf.Lerp(_CachedFromValue, _CachedToValue, factor);

                if (_Block == null)
                {
                    _Block = new MaterialPropertyBlock();
                }

                _Block.SetFloat(_CachedPropertyName, value);

                _CachedTarget.SetPropertyBlock(_Block);
            }
        }
Ejemplo n.º 13
0
    void Init()
    {
        Debug.Log("Init");
        if (_nodePositionsRead != null)
        {
            _nodePositionsRead.Release();
        }
        if (_nodePositionsWrite != null)
        {
            _nodePositionsWrite.Release();
        }
        if (_edgeListBuffer != null)
        {
            _edgeListBuffer.Release();
        }
        if (_drawArgsBuffer != null)
        {
            _drawArgsBuffer.Release();
        }

        _nodePositionsRead  = new ComputeBuffer(_maxNodes, Marshal.SizeOf(typeof(Vector4)));
        _nodePositionsWrite = new ComputeBuffer(_maxNodes, Marshal.SizeOf(typeof(Vector4)));
        _edgeListBuffer     = new ComputeBuffer(_maxNodes, Marshal.SizeOf(typeof(Edge)));

        _drawArgsBuffer = new ComputeBuffer(
            1, 5 * sizeof(uint), ComputeBufferType.IndirectArguments
            );

        _numNodes = 2;
        _numEdges = 1;

        _drawArgsBuffer.SetData(new uint[5] {
            _mesh.GetIndexCount(0),
            (uint)NodeCount,
            0, 0, 0
        });

        // This property block is used only for avoiding a bug (issue #913828)
        _props = new MaterialPropertyBlock();
        _props.SetFloat("_UniqueID", Random.value);

        var initKernel = _compute.FindKernel("InitNodes");

        _compute.SetBuffer(initKernel, "NodeListWrite", _nodePositionsWrite);
        _compute.Dispatch(initKernel, ThreadGroupCount, 1, 1);
        // SwapBuffer(ref _nodePositionsRead, ref _nodePositionsWrite);
    }
Ejemplo n.º 14
0
        private IEnumerator Fade()
        {
            if (_isFading)
            {
                yield break;
            }

            var mr = GetComponent <MeshRenderer>();

            if (mr == null)
            {
                yield break;
            }

            _isFading = true;

            const float fadeRate = 2f;

            var pb = new MaterialPropertyBlock();

            var val = IsVisible ? 0f : -1f;

            for (; ;)
            {
                var dest = IsVisible ? 1f : 0f;
                var sign = Math.Sign(dest - val);
                val += sign * fadeRate * Time.deltaTime;

                if (sign == 0 || sign == 1 && val >= dest || sign == -1 && val <= dest)
                {
                    break;
                }

                pb.SetFloat(FadeId, (float)val);
                mr.SetPropertyBlock(pb);
                yield return(new WaitForEndOfFrame());
            }

            mr.SetPropertyBlock(null);

            if (!IsVisible)
            {
                gameObject.SetActive(false);
            }

            _isFading = false;
        }
        private void SetMaterialPropertyBlock()
        {
            if (_Mesh == null || _MatProps == null)
            {
                _Mesh     = GetComponent <MeshRenderer>();
                _MatProps = new MaterialPropertyBlock();
                _Mesh.GetPropertyBlock(_MatProps);
            }

            if (_MatProps != null)
            {
                if (Properties != null && Properties.Count > 0)
                {
                    _MatProps.Clear();

                    foreach (MaterialProperty property in Properties)
                    {
                        if (property.Change)
                        {
                            switch (property.Type)
                            {
                            case "Color":
                                _MatProps.SetColor(property.Name, property.ColorValue);
                                break;

                            case "Texture":
                                if (property.TextureValue != null)
                                {
                                    _MatProps.SetTexture(property.Name, property.TextureValue);
                                }
                                break;

                            case "Float":
                                _MatProps.SetFloat(property.Name, property.FloatValue);
                                break;

                            case "Vector":
                                _MatProps.SetVector(property.Name, property.VectorValue);
                                break;
                            }
                        }
                    }

                    _Mesh.SetPropertyBlock(_MatProps);
                }
            }
        }
Ejemplo n.º 16
0
        public virtual void SetUniforms(MaterialPropertyBlock target)
        {
            // TODO : How to set these values per quad avoiding material property block and material uniforms?
            // NOTE : So, only these uniforms are variable per quad, but i don't know how to vary avoiding mpb and material uniforms, maybe instancing?
            //_Elevation_Tile
            //_Ortho_Tile
            //_Color_Tile
            //_Normals_Tile
            //_Deform_Offset
            //_Deform_Camera
            //_Deform_ScreenQuadCornerNorms
            //_Deform_ScreenQuadCorners
            //_Deform_ScreenQuadVericals
            //_Deform_TangentFrameToWorld

            if (target == null)
            {
                return;
            }

            SetEclipses(target);
            SetShine(target);
            SetSuns(target);

            target.SetFloat("_Globals_RadiusOffset", SizeOffset);

            target.SetVector("_Body_WorldCameraPosition", GodManager.Instance.View.WorldCameraPosition - Origin);
            target.SetVector("_Body_Origin", -Origin);

            if (Atmosphere != null)
            {
                Atmosphere.SetUniforms(target);
            }

            if (Ocean != null)
            {
                Ocean.SetUniforms(target);
            }

            if (Ring != null)
            {
                Ring.SetShadows(MPB, ShadowCasters);
            }

            //if (Manager.GetPlantsNode() != null)
            //    Manager.GetPlantsNode().SetUniforms(target);
        }
Ejemplo n.º 17
0
    void LateUpdate()
    {
        if (_renderers == null || _renderers.Length == 0)
        {
            return;
        }

        if (_sheet == null)
        {
            _sheet = new MaterialPropertyBlock();
        }

        var plane = EffectorPlane;
        var time  = LocalTime;

        // Filter out large deltas.
        if ((_prevEffectorPlane - plane).magnitude > 100)
        {
            _prevEffectorPlane = plane;
        }

        var vparams   = new Vector2(_density, _scale);
        var aparams   = new Vector3(_stretch, _fallDistance, _fluctuation);
        var emission1 = ColorToHsvm(_emissionColor1);
        var emission2 = ColorToHsvm(_emissionColor2);

        foreach (var renderer in _renderers)
        {
            if (renderer == null)
            {
                continue;
            }
            renderer.GetPropertyBlock(_sheet);
            _sheet.SetVector(ShaderIDs.VoxelParams, vparams);
            _sheet.SetVector(ShaderIDs.AnimParams, aparams);
            _sheet.SetVector(ShaderIDs.EmissionHsvm1, emission1);
            _sheet.SetVector(ShaderIDs.EmissionHsvm2, emission2);
            _sheet.SetColor(ShaderIDs.TransitionColor, _transitionColor);
            _sheet.SetColor(ShaderIDs.LineColor, _lineColor);
            _sheet.SetVector(ShaderIDs.EffectorPlane, plane);
            _sheet.SetVector(ShaderIDs.PrevEffectorPlane, _prevEffectorPlane);
            _sheet.SetFloat(ShaderIDs.LocalTime, time);
            renderer.SetPropertyBlock(_sheet);
        }

        _prevEffectorPlane = plane;
    }
Ejemplo n.º 18
0
        private void bindModel(MaterialPropertyBlock material, Model model)
        {
            model.BindToMaterial(material);
            material.SetVector("_PlanetCenter", model.PlanetCenter);
            material.SetFloat("_Radius", (float)(model.BottomRadius / model.LengthUnitInMeters));
            material.SetVector("_SunDirection", model.SunDirection);
            material.SetColor("_LightColor", settings.LightColor.value);

            material.SetFloat("_Timer", Time.realtimeSinceStartup);

            material.SetFloat("_R0", settings.R0.value);
            material.SetFloat("_R2", settings.R2.value);
            material.SetFloat("_S0", settings.S0.value);
            material.SetFloat("_S1", settings.S1.value);

            material.SetFloat("_MaxDisplacement", (float)(settings.MaxDisplacement.value / model.LengthUnitInMeters));
            material.SetFloat("_ShoreHardness", settings.ShoreHardness.value);

            material.SetColor("_WaterColor", settings.WaterColor.value);
            material.SetVector("_Extinction", Vector3.Normalize(settings.ExtinctionRatio.value));
            material.SetFloat("_Clarity", (float)(settings.WaterClarity.value / model.LengthUnitInMeters));
        }
Ejemplo n.º 19
0
    void UpdateColor(Color _replacementRed, float _redTo,
                     Color _replacementGreen, float greenTo,
                     Color _replacementBlue, float blueTo)
    {
        float _valueBoolToFloat;

        if (EnableSwap)
        {
            _valueBoolToFloat = 1;
        }
        else
        {
            _valueBoolToFloat = 0;
        }

        MaterialPropertyBlock _mpb = new MaterialPropertyBlock();

        SpriteRenderer.GetPropertyBlock(_mpb);
        _mpb.SetFloat("_EnableSwapColor", _valueBoolToFloat);
        //
        _mpb.SetColor("_BlinkColor", blinkColor);
        //R
        _mpb.SetColor("_ColorReplacement1", replacementRed);
        _mpb.SetFloat("_LerpValue1", redTo);
        //G
        _mpb.SetColor("_ColorReplacement2", replacementGreen);
        _mpb.SetFloat("_LerpValue2", greenTo);
        //B
        _mpb.SetColor("_ColorReplacement3", replacementBlue);
        _mpb.SetFloat("_LerpValue3", blueTo);
        //C
        _mpb.SetColor("_ColorReplacement6", replacementCyan);
        _mpb.SetFloat("_LerpValue6", cyanTo);
        //M
        _mpb.SetColor("_ColorReplacement5", replacementPurple);
        _mpb.SetFloat("_LerpValue5", purpleTo);
        //Y
        _mpb.SetColor("_ColorReplacement4", replacementYellow);
        _mpb.SetFloat("_LerpValue4", yellowTo);
        //W
        _mpb.SetColor("_ColorReplacement7", replacementCustom);
        _mpb.SetFloat("_LerpValue7", customTo);
        SpriteRenderer.SetPropertyBlock(_mpb);
    }
Ejemplo n.º 20
0
        public static void setOpacityRecursive(Transform tr, float opacity)
        {
            Renderer renderer = tr.GetComponent <Renderer>();

            if (renderer != null && renderer.sharedMaterial != null)
            {
                sharedBlock.Clear();
                renderer.GetPropertyBlock(sharedBlock);
                sharedBlock.SetFloat(PropertyIDs._Opacity, opacity);
                renderer.SetPropertyBlock(sharedBlock);
                renderer.sharedMaterial.renderQueue = opacity >= 1f ? -1 : 6000;
            }
            foreach (Transform child in tr)
            {
                setOpacityRecursive(child, opacity);
            }
        }
Ejemplo n.º 21
0
    static void ApplyNewProperties()
    {
        var objs = ftBuildGraphics.atlasOnlyObj;

        if (objs == null)
        {
            return;
        }
        var scaleOffset   = ftBuildGraphics.atlasOnlyScaleOffset;
        var size          = ftBuildGraphics.atlasOnlySize;
        var ids           = ftBuildGraphics.atlasOnlyID;
        var existingLmaps = LightmapSettings.lightmaps.ToList();

        tempTextures = new List <Texture2D>();
        for (int i = 0; i < objs.Count; i++)
        {
            if (objs[i] == null)
            {
                continue;
            }
            objs[i].lightmapScaleOffset = scaleOffset[i];
            if (objs[i].lightmapIndex < 0 || objs[i].lightmapIndex >= existingLmaps.Count ||
                existingLmaps[objs[i].lightmapIndex] == null ||
                existingLmaps[objs[i].lightmapIndex].lightmapColor == null || existingLmaps[objs[i].lightmapIndex].lightmapColor.width != size[i])
            {
                int s   = 1;//Math.Max(size[i],1);
                var tex = new Texture2D(s, s);
                tempTextures.Add(tex);
                tex.SetPixels32(new Color32[s * s]);
                tex.Apply();
                var ldata = new LightmapData();
                ldata.lightmapColor = tex;
                existingLmaps.Add(ldata);
                objs[i].lightmapIndex = existingLmaps.Count - 1;
            }

            var prop = new MaterialPropertyBlock();
            objs[i].GetPropertyBlock(prop);
            prop.SetFloat("bakeryLightmapSize", size[i]);
            UnityEngine.Random.InitState(ids[i]);
            prop.SetVector("bakeryLightmapID", UnityEngine.Random.ColorHSV(0, 1, 0.3f, 0.3f, 1, 1));
            objs[i].SetPropertyBlock(prop);
        }

        LightmapSettings.lightmaps = existingLmaps.ToArray();
    }
Ejemplo n.º 22
0
    //method to spawn cells
    public void Spawn()
    {
        for (int y1 = 0; y1 < majorDimension; y1++)
        {
            for (int x1 = 0; x1 < majorDimension; x1++)
            {
                // if majorCell is of type WALL spawn it with proper tiling otherwise spawn each minorCell
                if (grid[x1, y1].type == LabirynthCell.TYPE.WALL)
                {
                    GameObject majorWall = Instantiate(majorWallPrefab, transform);
                    majorWall.transform.localPosition = new Vector3(x1 * minorDimension * minorSize + ((minorDimension * minorSize) / 2) - (minorSize / 2), y1 * minorDimension * minorSize + ((minorDimension * minorSize) / 2) - (minorSize / 2), 0);
                    majorWall.transform.localScale    = new Vector3(minorDimension * minorSize, minorDimension * minorSize, 1);
                    MaterialPropertyBlock mpb = new MaterialPropertyBlock();
                    majorWall.GetComponent <SpriteRenderer>().GetPropertyBlock(mpb);
                    mpb.SetFloat("Vector1_A3318CCE", minorDimension);
                    majorWall.GetComponent <SpriteRenderer>().SetPropertyBlock(mpb);
                }
                else
                {
                    for (int y2 = 0; y2 < minorDimension; y2++)
                    {
                        for (int x2 = 0; x2 < minorDimension; x2++)
                        {
                            if (grid[x1, y1].minorGrid[x2, y2].type == LabirynthCell.TYPE.EMPTY)
                            {
                                continue;
                            }

                            if (grid[x1, y1].minorGrid[x2, y2].type == LabirynthCell.TYPE.PATH)
                            {
                                GameObject cell = (GameObject)Instantiate(pathPrefab, transform);
                                cell.transform.localPosition = new Vector3(x1 * minorDimension * minorSize + x2 * minorSize, y1 * minorDimension * minorSize + y2 * minorSize, 0);
                                cell.transform.localScale    = new Vector3(minorSize, minorSize, 1);
                            }
                            else
                            {
                                GameObject cell = (GameObject)Instantiate(wallPrefab, transform);
                                cell.transform.localPosition = new Vector3(x1 * minorDimension * minorSize + x2 * minorSize, y1 * minorDimension * minorSize + y2 * minorSize, 0);
                                cell.transform.localScale    = new Vector3(minorSize, minorSize, 1);
                            }
                        }
                    }
                }
            }
        }
    }
 private void UpdateRendererFade()
 {
     s_matPropBlock.SetFloat(s_propID_Fade, 1f - _transitionFade);
     for (var i = 0; i < _transitionRenderers.Length; i++)
     {
         _transitionRenderers[i].SetPropertyBlock(s_matPropBlock);
         if (_transitionRenderers[i].enabled && _transitionFade == 0f)
         {
             _transitionRenderers[i].enabled = false;
         }
         else if (!_transitionRenderers[i].enabled && _transitionFade > 0f)
         {
             _transitionRenderers[i].enabled = true;
         }
     }
     _ownedCamera.SetImageEffectFade(1f - _transitionFade);
 }
Ejemplo n.º 24
0
        private void Draw(float cur, float max, Matrix4x4 matrix, Color color)
        {
            MaterialPropertyBlock materialPropertyBlock = new MaterialPropertyBlock();

            materialPropertyBlock.SetVector("_BackgroundColor", BackgroundColor);
            materialPropertyBlock.SetVector("_Color", color);
            materialPropertyBlock.SetFloat("_Fill", cur / max);
            UnityEngine.Graphics.DrawMesh(
                mesh,
                matrix,
                Material,
                1,
                null,
                0,
                materialPropertyBlock
                );
        }
Ejemplo n.º 25
0
        private void BlitCubemap(ScriptableRenderContext renderContext, Cubemap source, RenderTexture dest)
        {
            MaterialPropertyBlock propertyBlock = new MaterialPropertyBlock();

            for (int i = 0; i < 6; ++i)
            {
                Utilities.SetRenderTarget(renderContext, dest, ClearFlag.ClearNone, 0, (CubemapFace)i);
                var cmd = new CommandBuffer {
                    name = ""
                };
                propertyBlock.SetTexture("_MainTex", source);
                propertyBlock.SetFloat("_faceIndex", (float)i);
                cmd.DrawProcedural(Matrix4x4.identity, m_BlitCubemapMaterial, 0, MeshTopology.Triangles, 3, 1, propertyBlock);
                renderContext.ExecuteCommandBuffer(cmd);
                cmd.Dispose();
            }
        }
    void Update()
    {
        if (targetRenderer == null)
        {
            return;
        }
        if (mpb == null)
        {
            mpb = new MaterialPropertyBlock();
        }

        targetRenderer.GetPropertyBlock(mpb);
        mpb.SetVector("_LitPos", transform.position);
        mpb.SetFloat("_Intensity", intensity);
        mpb.SetColor("_LitCol", color);
        targetRenderer.SetPropertyBlock(mpb);
    }
        private void UpdateColor()
        {
            var renderers = GetComponentsInChildren <Transform>().Where(c => c.tag.Equals(OurTag)).Select(c => c.gameObject.GetComponent <MeshRenderer>()).Where(c => c != null)
                            .ToList();

            //var renderers = GetComponentsInChildren<MeshRenderer>();
            //var renderers = GetComponentsInChildren<MeshRenderer>();
            foreach (var aRenderer in renderers)
            {
                MaterialPropertyBlock properties = new MaterialPropertyBlock();

                aRenderer.GetPropertyBlock(properties);
                properties.SetColor("_BaseColor", BaseColor);
                properties.SetFloat("_Alpha", Alpha);
                aRenderer.SetPropertyBlock(properties);
            }
        }
Ejemplo n.º 28
0
 // Token: 0x060005DB RID: 1499 RVA: 0x00018546 File Offset: 0x00016746
 private IEnumerator startPrint(float maxPrintTime, float maxPrintHeight, MaterialPropertyBlock printPropertyBlock)
 {
     if (this.meshRenderer)
     {
         while (this.printHeight < maxPrintHeight)
         {
             this.printTime  += Time.deltaTime;
             this.printHeight = this.printTime / maxPrintTime * maxPrintHeight;
             this.meshRenderer.GetPropertyBlock(printPropertyBlock);
             printPropertyBlock.Clear();
             printPropertyBlock.SetFloat("_SliceHeight", this.printHeight);
             this.meshRenderer.SetPropertyBlock(printPropertyBlock);
             yield return(new WaitForEndOfFrame());
         }
     }
     yield break;
 }
Ejemplo n.º 29
0
    void RenderBox(Box box)
    {
        //change matrix based on box
        matrix[0, 0] = box.size.x;
        matrix[0, 3] = box.pos.x;
        matrix[1, 1] = box.size.y;
        matrix[1, 3] = box.pos.y;
        matrix[2, 3] = box.pos.z;
        // colors arnt working so next thing to fix

        block.SetColor("_Color", box.color);
        block.SetColor("_FrontColor", box.color);
        Graphics.DrawMesh(mesh, matrix, inside, 0, null, 0, block);
        block.SetColor("_FrontColor", box.color);
        block.SetFloat("_RemoveDiag", 1f);
        Graphics.DrawMesh(mesh, matrix, wire, 0, null, 0, block);
    }
Ejemplo n.º 30
0
    private void Start()
    {
        s_renderer = GetComponent <Renderer>();

        if (s_renderer == null)
        {
            enabled = false;
        }

        materialBlock = new MaterialPropertyBlock();

        s_renderer.GetPropertyBlock(materialBlock);

        materialBlock.SetColor(NoiseColorID, NoiseColor);

        materialBlock.SetFloat(ThresholdID, DefaultThreshold);
    }