private void WriteShipViewer(BinaryWriter Writer)
        {
            foreach (GameObject g in Children)
            {
                if (g.GetType().Equals(typeof(ShipViewer)))
                {
                    ShipViewer s = (ShipViewer)g;

                    Writer.Write(s.model.getFullPath());
                    Writer.Write(s.effect.getFullPath());

                    ColorParameter     DrawColor        = (ColorParameter)s.effect.findValueParameter("DrawColor");
                    ColorParameter     SpecularColor    = (ColorParameter)s.effect.findValueParameter("SpecularColor");
                    FloatParameter     SpecularExponent = (FloatParameter)s.effect.findValueParameter("SpecularExponent");
                    Texture2DParameter Texture          = (Texture2DParameter)s.effect.findValueParameter("Texture");

                    Writer.Write(Texture.getFullPath());

                    SaveHelper.Write(DrawColor.get());
                    SaveHelper.Write(SpecularColor.get());
                    Writer.Write((Single)SpecularExponent.get());

                    return;
                }
            }
            throw new Exception("No ShipViewer to save");
        }
Exemplo n.º 2
0
    private void Start()
    {
        //Finds PostProcessing layer to apply effect.
        //Must have PostProcessing layer added in order for effect to work properly.
        layerIndex = LayerMask.NameToLayer("PostProcessing");
        camera.GetComponent <PostProcessLayer>().volumeLayer = LayerMask.GetMask("PostProcessing");

        //Creates vignette effect and sets default settings.
        vignette = ScriptableObject.CreateInstance <Vignette>();
        vignette.enabled.Override(false);
        vignette.intensity.Override(0f);

        //Creates color grading effect and sets default settings.
        colorGrading = ScriptableObject.CreateInstance <ColorGrading>();
        colorGrading.enabled.Override(false);

        //Gets settings to use from effect profile provided.
        vColor      = postProfile.GetSetting <Vignette>().color;
        vCenter     = postProfile.GetSetting <Vignette>().center;
        vSmoothness = postProfile.GetSetting <Vignette>().smoothness;
        vRoundness  = postProfile.GetSetting <Vignette>().roundness;
        vRounded    = postProfile.GetSetting <Vignette>().rounded;

        //Sets settings to approprate values.
        vignette.color.Override(vColor);
        vignette.center.Override(vCenter);
        vignette.smoothness.Override(vSmoothness);
        vignette.roundness.Override(vRoundness);
        vignette.rounded.Override(vRounded);

        //Creates volume for effect to be applied.
        volume          = PostProcessManager.instance.QuickVolume(layerIndex, 0, vignette, colorGrading);
        volume.isGlobal = true;
    }
Exemplo n.º 3
0
 public ColorValue(ColorParameter parameter)
 {
     value = new float[3] {
         parameter.value[0], parameter.value[1], parameter.value[2]
     };
     overrideState = parameter.overrideState;
 }
Exemplo n.º 4
0
        /// <summary>
        ///     Draws all Gizmos that are sub-classes of GizmoGeometry.
        /// </summary>
        /// <param name="pass">The pass from an effect to draw the geometry with.</param>
        private void DrawBaseGizmosGeometries(EffectPass pass)
        {
            var           count = 0;
            List <Matrix> matrices;

            foreach (var drawInstance in DrawInstances)
            {
                var geometry = drawInstance.Key;
                geometry.Bind();

                foreach (var colorEntry in drawInstance.Value)
                {
                    ColorParameter.SetValue(colorEntry.Key.ToVector3());

                    matrices = colorEntry.Value;
                    count    = matrices.Count;

                    for (var index = 0; index < count; index++)
                    {
                        WorldViewProjectionParameter.SetValue(matrices[index]);
                        pass.Apply();
                        geometry.Draw();
                    }
                }
            }
        }
Exemplo n.º 5
0
    public void ChangeColorOld()
    {
        var            bloom = processProfile.GetSetting <Bloom>();
        ColorParameter color = new ColorParameter();

        color.value = Color.green;
        bloom.color = color;
    }
Exemplo n.º 6
0
    private void ChangeAmbientColor(Color color)
    {
        // Change post procesing vignette color
        CustomColorFix();
        ColorParameter currentColor = new ColorParameter();

        currentColor.value = color;
        effect.color       = currentColor;
    }
Exemplo n.º 7
0
        public static void Convert(this BIRPRendering.ColorParameter birpSource, ColorParameter target, bool enabledState, Color disabledColor)
        {
            if (target == null)
            {
                return;
            }

            target.value         = enabledState ? birpSource.value : disabledColor;
            target.overrideState = birpSource.overrideState;
        }
Exemplo n.º 8
0
	public void RefreshEditorGradient (Texture2D tex, ColorParameter p)
    {
        Color col;
        for (int x = 0; x < tex.width; x++) {
            col = p.GetGradientColor(x / (float)tex.width);
            for (int y=0;y<tex.height;y++)
                tex.SetPixel(x,y,col);
        }
        tex.Apply();
    }
Exemplo n.º 9
0
        public static void Convert(this BIRPRendering.ColorParameter birpSource, ColorParameter target)
        {
            if (target == null)
            {
                return;
            }

            target.value         = birpSource.value;
            target.overrideState = birpSource.overrideState;
        }
Exemplo n.º 10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TexturedMaterial"/> class.
        /// </summary>
        /// <param name="root">Root object to which the material belongs.</param>
        public TexturedMaterial(Root root) : base(root)
        {
            mAmbientColorParam      = new ColorParameter(root, "ambientColor", Color.Black);
            mDiffuseTextureParam    = new TextureParameter(Root, "txDiffuse", null);
            mSpecularIntensityParam = new FloatParameter(root, "specularIntensity", 0.0f);
            mShininessParam         = new FloatParameter(root, "shininess", 1.0f);
            mReceiveShadowsParam    = new FloatParameter(root, "receiveShadows", 1.0f);

            Setup();
        }
Exemplo n.º 11
0
        /// <summary>
        /// Creates a new material with no textures. Textures must be set before rendering any
        /// object with the material.
        /// </summary>
        /// <param name="root">Root object to which the material belongs.</param>
        public NormalMappedMaterial(Root root) : base(root)
        {
            mAmbientColorParam    = new ColorParameter(Root, "ambientColor", Color.Black);
            mDiffuseTextureParam  = new TextureParameter(Root, "txDiffuse", null);
            mNormalTextureParam   = new TextureParameter(Root, "txNormal", null);
            mSpecularTextureParam = new TextureParameter(Root, "txSpecular", null);
            mBumpinessParam       = new FloatParameter(Root, "bumpiness", 1.0f);
            mReceiveShadowsParam  = new FloatParameter(root, "receiveShadows", 1.0f);

            Setup();
        }
Exemplo n.º 12
0
    static public void Show(ColorParameter param, Texture2D etex, Editor editor) {
        // Get existing open window or if none, make a new one:
        XGradientEditor window = GetWindow<XGradientEditor>(true, "Xffect Color", false);
		
		window.mColorKeys = param.Colors;
		window.mColorParam = param;
		window.mEditor = editor;
		window.mEditorTex = etex;
		
		window.maxSize = new Vector2(1000, 100);
		window.minSize = new Vector2(500, 100);
    }
Exemplo n.º 13
0
    static public void Show(ColorParameter param, Texture2D etex, Editor editor)
    {
        // Get existing open window or if none, make a new one:
        XGradientEditor window = GetWindow <XGradientEditor>(true, "Xffect Color", false);

        window.mColorKeys  = param.Colors;
        window.mColorParam = param;
        window.mEditor     = editor;
        window.mEditorTex  = etex;

        window.maxSize = new Vector2(1000, 100);
        window.minSize = new Vector2(500, 100);
    }
Exemplo n.º 14
0
    void Awake()
    {
        ColorAdjustments colorAdjustments = null;

        if (!ppGlobalVolume.profile.TryGet <ColorAdjustments>(out colorAdjustments))
        {
            Debug.LogWarning("No color adjustments found!");
        }
        else
        {
            cp = colorAdjustments.colorFilter;
        }
    }
Exemplo n.º 15
0
    public string[] badTileNames = { "jungleTilemap_9", "jungleTilemap_19", "jungleTilemap_8", "jungleTilemap_18" }; //all the tiles that will kill us

    void Start()
    {
        backAlph      = PlayerPrefs.GetFloat("alpha", 0.1f);
        minAlpha      = backAlph;
        player        = GameObject.Find("Player");
        activeTileSet = 0;
        col           = new ColorParameter();
        UpdateTileCollider();
        SetAlpha(frontAlph, backAlph);
        vol.profile.TryGetSettings(out distortion);
        vol.profile.TryGetSettings(out hue);
        SetHue(255 - hueChange, 0);
        ResetColliders();
    }
Exemplo n.º 16
0
    static protected void RefreshEditorGradient(Texture2D tex, ColorParameter p)
    {
        Color col;

        for (int x = 0; x < tex.width; x++)
        {
            col = p.GetGradientColor(x / (float)tex.width);
            for (int y = 0; y < tex.height; y++)
            {
                tex.SetPixel(x, y, col);
            }
        }
        tex.Apply();
    }
Exemplo n.º 17
0
    public static void RefreshGradientTex(ref Texture2D tex, ColorParameter cp, Editor editor)
    {
        if (editor == null)
            return;

        if (tex == null)
        {
            tex =new Texture2D(ColorTexWidth,ColorTexHeight, TextureFormat.RGBA32, false);
            tex.wrapMode = TextureWrapMode.Clamp;
        }

        RefreshEditorGradient(tex,cp);

        //editor.Repaint();
    }
Exemplo n.º 18
0
    private PostProcessingStates LerpProcessingState(PostProcessingStates a, PostProcessingStates b, float progress)
    {
        ColorParameter vColor = new ColorParameter(a.mVignetteColor);

        vColor.Interp(a.mVignetteColor, b.mVignetteColor, progress);

        PostProcessingStates toReturn = new PostProcessingStates
        {
            mColorContrast      = Mathf.Lerp(a.mColorContrast, b.mColorContrast, progress),
            mColorSaturation    = Mathf.Lerp(a.mColorSaturation, b.mColorSaturation, progress),
            mVignetteColor      = vColor.value,
            mVignetteIntensity  = Mathf.Lerp(a.mVignetteIntensity, b.mVignetteIntensity, progress),
            mVignetteSmoothness = Mathf.Lerp(a.mVignetteSmoothness, b.mVignetteSmoothness, progress)
        };

        return(toReturn);
    }
Exemplo n.º 19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TexturedMaterial"/> class.
        /// </summary>
        /// <param name="root">Root object to which the material belongs.</param>
        /// <param name="diffuse">Diffuse texture of the material.</param>
        /// <param name="specularIntensity">Specular intensity of the new material.</param>
        /// <param name="shininess">Shininess of the new material.</param>
        /// <param name="ambient">Ambient color of the new material.</param>
        /// <param name="ambientIntensity">
        /// Intensity of the ambient color. Each component of the ambient color will be multiplied
        /// by this factor.
        /// </param>
        /// <param name="receiveShadows">if set to <c>true</c> [receive shadows].</param>
        public TexturedMaterial(Root root, Texture2D diffuse, float specularIntensity,
                                float shininess, Color ambient, float ambientIntensity = 0.2f,
                                bool receiveShadows = true)
            : base(root)
        {
            mAmbientIntensity = ambientIntensity;
            Color multipliedAmbient = Color.Multiply(ambient, ambientIntensity);

            mAmbientColorParam      = new ColorParameter(Root, "ambientColor", multipliedAmbient);
            mDiffuseTextureParam    = new TextureParameter(Root, "txDiffuse", diffuse);
            mSpecularIntensityParam = new FloatParameter(Root, "specularIntensity", specularIntensity);
            mShininessParam         = new FloatParameter(root, "shininess", shininess);
            mReceiveShadowsParam    = new FloatParameter(root, "receiveShadows", BoolToFloat(receiveShadows));
            mReceiveShadows         = receiveShadows;

            Setup();
        }
Exemplo n.º 20
0
        /// <summary>
        /// Creates a new material with all the textures set.
        /// </summary>
        /// <param name="root">Root object to which the material belongs.</param>
        /// <param name="diffuse">Diffuse texture of the new material.</param>
        /// <param name="normal">Normal map of the new material.</param>
        /// <param name="specular">Specular map of the new material.</param>
        /// <param name="ambient">Ambient color of the new material.</param>
        /// <param name="ambientIntensity">Intensity of the ambient light.</param>
        /// <param name="bumpiness">Bumpiness of the material.</param>
        /// <param name="receiveShadows">
        /// Whether objects drawn with this material receive shadows.
        /// </param>
        public NormalMappedMaterial(Root root, Texture2D diffuse, Texture2D normal,
                                    Texture2D specular, Color ambient, float ambientIntensity = 0.2f,
                                    float bumpiness = 1.0f, bool receiveShadows = true)
            : base(root)
        {
            mAmbientIntensity = ambientIntensity;
            Color multipliedAmbient = Color.Multiply(ambient, ambientIntensity);

            mAmbientColorParam    = new ColorParameter(Root, "ambientColor", multipliedAmbient);
            mDiffuseTextureParam  = new TextureParameter(Root, "txDiffuse", diffuse);
            mNormalTextureParam   = new TextureParameter(Root, "txNormal", normal);
            mSpecularTextureParam = new TextureParameter(Root, "txSpecular", specular);
            mBumpinessParam       = new FloatParameter(Root, "bumpiness", bumpiness);
            mReceiveShadowsParam  = new FloatParameter(root, "receiveShadows", BoolToFloat(receiveShadows));
            mReceiveShadows       = receiveShadows;

            Setup();
        }
Exemplo n.º 21
0
    static public void PatchColorGradient(ColorParameter c1, Gradient c2)
    {
        GradientColorKey[] ck = new GradientColorKey[c1.Colors.Count];
        GradientAlphaKey[] ak = new GradientAlphaKey[c1.Colors.Count];

        for (int i = 0; i < c1.Colors.Count; i++)
        {
            ColorKey k = c1.Colors[i];

            ck[i].color = k.Color;
            ck[i].time  = k.t;

            ak[i].alpha = k.Color.a;
            ak[i].time  = k.t;
        }

        c2.SetKeys(ck, ak);
    }
Exemplo n.º 22
0
    static public void RefreshGradientTex(ref Texture2D tex, ColorParameter cp, Editor editor)
    {
        if (editor == null)
        {
            return;
        }

        if (tex == null)
        {
            tex          = new Texture2D(ColorTexWidth, ColorTexHeight, TextureFormat.RGBA32, false);
            tex.wrapMode = TextureWrapMode.Clamp;
        }

        RefreshEditorGradient(tex, cp);


        //editor.Repaint();
    }
Exemplo n.º 23
0
    public PlayerModel(Transform playerT, float movSpeed, Transform aimPointer, float aimSensitivity, PlayerView view, float maxHp, List <AbstractAbilities> playerAbilities, float dashDuration, float dashDistance, float dashCooldown, LayerMask dashRayMask, GameObject mesh, ParticleSystem dashTrailParticles, Player player)
    {
        EventsManager.SuscribeToEvent("StartCastingSpell", StartCastingSpell);
        EventsManager.SuscribeToEvent("StopCastingSpell", StopCastingSpell);

        _abilities = new List <AbstractAbilities>(playerAbilities);
        new AbilitiesManager(_abilities, this);

        _transform          = playerT;
        movementSpeed       = movSpeed;
        this.aimPointer     = aimPointer;
        this.aimSensitivity = aimSensitivity;

        _maxHP     = maxHp;
        _currentHp = _maxHP;

        rotationUpdater = new PlayerRotationUpdater(aimPointer, _transform);

        _view = view;

        EventsManager.SuscribeToEvent("Dash", Dash);
        isDashing         = false;
        this.dashDuration = dashDuration;
        this.dashDistance = dashDistance;
        this.dashCooldown = dashCooldown;
        dashCooldownTimer = 0;

        _rigi            = _transform.gameObject.GetComponent <Rigidbody>();
        this.dashRayMask = dashRayMask;

        this.mesh = mesh;
        playerCol = _transform.gameObject.GetComponent <Collider>();
        this.dashTrailParticles = dashTrailParticles;
        var emission = dashTrailParticles.emission;

        initialDashParticleRateOverDistance = emission.rateOverDistance;

        Camera.main.gameObject.GetComponent <PostProcessVolume>().profile.TryGetSettings(out vignette);
        vignetteInitialColor     = vignette.color;
        vignetteInitialIntensity = vignette.intensity;

        _player        = player;
        fallingMaxTime = _player.MaxFallingTime;
    }
Exemplo n.º 24
0
        /// <summary>
        ///     Draws all Gizmos that are poly-lines.
        /// </summary>
        /// <param name="pass">The pass from an effect to draw the geometry with.</param>
        private void DrawPolyLines(EffectPass pass)
        {
            var count = 0;
            List <Vector3[]> positions;

            WorldViewProjectionParameter.SetValue(Matrix.Identity);
            foreach (var polyLineInstance in PolyLinesToDraw)
            {
                ColorParameter.SetValue(polyLineInstance.Key.ToVector3());

                positions = polyLineInstance.Value;
                count     = positions.Count;
                for (var index = 0; index < count; index++)
                {
                    pass.Apply();
                    PolyLine.Draw(positions[index]);
                }
            }
        }
Exemplo n.º 25
0
        /// <summary>
        /// Creates a new material by loading the required textures.
        /// </summary>
        /// <param name="root">Root object to which the material belongs.</param>
        /// <param name="diffuseFile">File with the diffuse texture of the material.</param>
        /// <param name="normalFile">File with the normal map of the material.</param>
        /// <param name="specularFile">File with the specular map of the material.</param>
        /// <param name="ambient">Ambient color of the material.</param>
        /// <param name="ambientIntensity">Intensity of the ambient light.</param>
        /// /// <param name="bumpiness">Bumpiness of the material.</param>
        public NormalMappedMaterial(Root root, string diffuseFile, string normalFile,
                                    string specularFile, Color ambient, float ambientIntensity = 0.2f,
                                    float bumpiness = 1.0f)
            : base(root)
        {
            mAmbientIntensity = ambientIntensity;
            Color multipliedAmbient = Color.Multiply(ambient, ambientIntensity);

            mAmbientColorParam = new ColorParameter(Root, "ambientColor", multipliedAmbient);

            //Load the textures of the material.
            Texture2D diffuse  = Root.ContentManager.Load <Texture2D>(diffuseFile);
            Texture2D normal   = Root.ContentManager.Load <Texture2D>(normalFile);
            Texture2D specular = Root.ContentManager.Load <Texture2D>(specularFile);

            mDiffuseTextureParam  = new TextureParameter(Root, "txDiffuse", diffuse);
            mNormalTextureParam   = new TextureParameter(Root, "txNormal", normal);
            mSpecularTextureParam = new TextureParameter(Root, "txSpecular", specular);
            mBumpinessParam       = new FloatParameter(Root, "bumpiness", bumpiness);

            Setup();
        }
Exemplo n.º 26
0
 public void Fill(ColorParameter parameter)
 {
     parameter.value         = new Color(value[0], value[1], value[2]);
     parameter.overrideState = overrideState;
 }
Exemplo n.º 27
0
    static public void PatchColorGradient(ColorParameter c1, Gradient c2)
    {

        GradientColorKey[] ck = new GradientColorKey[c1.Colors.Count];
        GradientAlphaKey[] ak = new GradientAlphaKey[c1.Colors.Count];

        for (int i = 0; i < c1.Colors.Count; i++)
        {
            ColorKey k = c1.Colors[i];

            ck[i].color = k.Color;
            ck[i].time = k.t;

            ak[i].alpha = k.Color.a;
            ak[i].time = k.t;
        }

        c2.SetKeys(ck, ak);
    }