Ejemplo n.º 1
0
            public static CmdDraw create(uiMeshMesh mesh = null, TextBlobMesh textMesh = null, int pass = 0,
                                         MaterialPropertyBlockWrapper properties = null, int?layerId = null, Material material = null,
                                         Image image         = null, Mesh meshObj = null,
                                         bool meshObjCreated = false)
            {
                CmdDraw newCmd = ObjectPool <CmdDraw> .alloc();

                newCmd.mesh           = mesh;
                newCmd.textMesh       = textMesh;
                newCmd.pass           = pass;
                newCmd.properties     = properties;
                newCmd.layerId        = layerId;
                newCmd.material       = material;
                newCmd.image          = image;
                newCmd.meshObj        = meshObj;
                newCmd.meshObjCreated = meshObjCreated;

                return(newCmd);
            }
Ejemplo n.º 2
0
        static void _getShaderPassAndProps(
            PictureFlusher.RenderLayer layer, uiPaint paint, uiMatrix3?meshMatrix, float alpha, float strokeMult,
            out int pass, out MaterialPropertyBlockWrapper props)
        {
            Vector4 viewport = layer.viewport;

            props = ObjectPool <MaterialPropertyBlockWrapper> .alloc();

            props.SetVector(_viewportId, viewport);
            props.SetFloat(_alphaId, alpha);
            props.SetFloat(_strokeMultId, strokeMult);

            switch (paint.shader)
            {
            case null:
                pass = 0;
                props.SetVector(_colorId, _colorToVector4(paint.color));
                return;

            case _LinearGradient linear:
                pass = 1;
                props.SetMatrix(_shaderMatId, linear.getGradientMat(
                                    _getShaderMatBase(layer.currentState, meshMatrix)).toMatrix4x4());
                props.SetTexture(_shaderTexId, linear.gradientTex.texture);
                props.SetVector(_leftColorId, _colorToVector4(linear.leftColor));
                props.SetVector(_rightColorId, _colorToVector4(linear.rightColor));
                props.SetInt(_tileModeId, (int)linear.tileMode);
                return;

            case _RadialGradient radial:
                pass = 2;
                props.SetMatrix(_shaderMatId, radial.getGradientMat(
                                    _getShaderMatBase(layer.currentState, meshMatrix)).toMatrix4x4());
                props.SetTexture(_shaderTexId, radial.gradientTex.texture);
                props.SetVector(_leftColorId, _colorToVector4(radial.leftColor));
                props.SetVector(_rightColorId, _colorToVector4(radial.rightColor));
                props.SetInt(_tileModeId, (int)radial.tileMode);
                return;

            case _SweepGradient sweep:
                pass = 3;
                props.SetMatrix(_shaderMatId, sweep.getGradientMat(
                                    _getShaderMatBase(layer.currentState, meshMatrix)).toMatrix4x4());
                props.SetTexture(_shaderTexId, sweep.gradientTex.texture);
                props.SetVector(_leftColorId, _colorToVector4(sweep.leftColor));
                props.SetVector(_rightColorId, _colorToVector4(sweep.rightColor));
                props.SetInt(_tileModeId, (int)sweep.tileMode);
                props.SetFloat(_biasId, sweep.bias);
                props.SetFloat(_scaleId, sweep.scale);
                return;

            case ImageShader image:
                pass = 4;
                props.SetMatrix(_shaderMatId, image.getShaderMat(
                                    _getShaderMatBase(layer.currentState, meshMatrix)).toMatrix4x4());
                props.SetTexture(_shaderTexId, image.image.texture);
                props.SetInt(_tileModeId, (int)image.tileMode);
                return;

            default:
                throw new Exception("Unknown paint.shader: " + paint.shader);
            }
        }