コード例 #1
0
        void LateUpdate()
        {
            if (_colorMap == null || _positionMap == null)
            {
                return;
            }
            if (_baseMaterial == null)
            {
                return;
            }

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

            if (_slitToAlpha >= 0.9999f || _sliderToAlpha > 0.9999f)
            {
                return;
            }

            var xc = _positionMap.width / 4;
            var yc = _positionMap.height / 4;

            _props.SetTexture("_BaseColorMap", _colorMap);
            _props.SetTexture("_PositionMap", _positionMap);

            _props.SetInt("_XCount", xc);
            _props.SetInt("_YCount", yc);

            _props.SetColor("_BaseColor", _baseColor);
            _props.SetFloat("_Metallic", _metallic);
            _props.SetFloat("_Smoothness", _smoothness);

            _props.SetColorHsv("_RcamEmission", _effectColor);
            _props.SetFloat("_RcamHueShift", _hueShift);

            _props.SetVector("_RcamLine", _lineToAlpha, _lineToEmission);
            _props.SetVector("_RcamSlit", _slitToAlpha, _slitToEmission);
            _props.SetVector("_RcamSlider", _sliderToAlpha, _sliderToEmission);

            var tref = _sensorOrigin != null ? _sensorOrigin : transform;

            _props.SetMatrix("_LocalToWorld", tref.localToWorldMatrix);

            Graphics.DrawProcedural(
                _baseMaterial,
                new Bounds(Vector3.zero, Vector3.one * 1000),
                MeshTopology.Points, xc * yc, 1,
                null, _props,
                ShadowCastingMode.On, true, gameObject.layer
                );
        }