Пример #1
0
    public VHSShaderValue Lerp(VHSShaderValue val1, VHSShaderValue val2, float lerp)
    {
        VHSShaderValue res = new VHSShaderValue();

        //Blur
        res.blurIntensity     = Mathf.Lerp(val1.blurIntensity, val2.blurIntensity, lerp);
        res.blurBlueIntensity = Mathf.Lerp(val1.blurBlueIntensity, val2.blurBlueIntensity, lerp);
        //Color
        res.tint         = Color.Lerp(val1.tint, val2.tint, lerp);
        res.decalageBleu = Vector4.Lerp(val1.decalageBleu, val2.decalageBleu, lerp);
        res.saturation   = Mathf.Lerp(val1.saturation, val2.saturation, lerp);
        res.noirEtBlanc  = Mathf.Lerp(val1.noirEtBlanc, val2.noirEtBlanc, lerp);
        //Bug
        res.tailleBug         = Mathf.Lerp(val1.tailleBug, val2.tailleBug, lerp);
        res.decalageDansLeBug = Mathf.Lerp(val1.decalageDansLeBug, val2.decalageDansLeBug, lerp);
        res.verticalGlitch    = val1.verticalGlitch || val2.verticalGlitch;
        res.vitesseBug        = Mathf.Lerp(val1.vitesseBug, val2.vitesseBug, lerp);
        //Noise
        res.tolerance  = Mathf.Lerp(val1.tolerance, val2.tolerance, lerp);
        res.noiseColor = Color.Lerp(val1.noiseColor, val2.noiseColor, lerp);
        //Tram
        res.tramFrac      = Mathf.Lerp(val1.tramFrac, val2.tramFrac, lerp);
        res.tramRythm     = Mathf.Lerp(val1.tramRythm, val2.tramRythm, lerp);
        res.tramIntensity = Mathf.Lerp(val1.tramIntensity, val2.tramIntensity, forTramIntensityTransition.Evaluate(lerp));
        res.tramColor     = Color.Lerp(val1.tramColor, val2.tramColor, lerp);

        return(res);
    }
Пример #2
0
    public void ApplyVHSValueOnMat(VHSShaderValue val, Material mat)
    {
        mat.SetFloat("_Blur", val.blurIntensity);
        mat.SetVector("_BlurForColor", val.blurColorIntensity);

        mat.SetColor("_Color", val.tint);
        mat.SetVector("_OffsetRed", val.decalageRoug + Vector2.one * val.evenOffsetRed);
        mat.SetVector("_OffsetGreen", val.decalageVert + Vector2.one * val.evenOffsetGreen);
        mat.SetVector("_OffsetBlue", val.decalageBleu + Vector2.one * val.evenOffsetBlue);
        mat.SetFloat("_Saturation", val.saturation);
        mat.SetFloat("_RedIntensity", val.redIntensity);
        mat.SetFloat("_GreenIntensity", val.greenIntensity);
        mat.SetFloat("_BlueIntensity", val.blueIntensity);
        mat.SetFloat("_NbIntensity", val.noirEtBlanc);

        mat.SetFloat("_Taille", val.tailleBug);
        mat.SetFloat("_Decalage", val.decalageDansLeBug);
        mat.SetFloat("_typeOfBug", val.verticalGlitch ? 1 : 0);
        mat.SetFloat("_Speed", val.vitesseBug);

        mat.SetFloat("_ToleranceBWNoise", val.tolerance);
        mat.SetColor("_NoiseColor", val.noiseColor);

        mat.SetFloat("_Tramage", val.tramFrac);
        mat.SetFloat("_Tram2", val.tramRythm);
        mat.SetFloat("_TramIntensity", val.tramIntensity);
        mat.SetColor("_TramColor", val.tramColor);

        mat.SetFloat("_FloatEffect", val.floatEffectIntensity);
        mat.SetFloat("_FloatNoiseDensity", val.floatNoiseDensity);
    }
Пример #3
0
    public VHSShaderValue GetCurrentVHSEffect()
    {
        VHSShaderValue res = Lerp(targetEffect[0], targetEffect[1], (lerpForTarget[0] + lerpForTarget[1]));

        for (int i = 2; i < targetEffect.Count; i++)
        {
            if (lerpForTarget[i] != 0)
            {
                res = Lerp(res, targetEffect[i], lerpForTarget[i]);
            }
        }
        return(res);
    }
Пример #4
0
    private void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        if (matToApply != null)
        {
            if (!onTransition)
            {
                //matToApply = onVHS if not onTransition
                if (texturesGlitch != null)
                {
                    matToApply.SetTexture("_TextureGlitch", texturesGlitch);
                }
                if (targetEffect.Count > 1)
                {
                    VHSShaderValue val = GetCurrentVHSEffect();
                    ApplyVHSValueOnMat(val, matToApply);
                }
            }
            else
            {
                matToApply.SetFloat("_LerpVal", lerpForTarget[0]);
            }
        }


        if (matToApply != null)
        {
            RenderTexture tmp = destination;
            Graphics.Blit(source, tmp, matToApply);
            Graphics.Blit(tmp, destination);
            //for transition
            if (doOnce)
            {
                doOnce = false;
                forTransition.SetTexture("_LastFrame", tmp);
                //destination and put it on the mat : forTransition
                matToApply   = forTransition;
                onTransition = true;
            }
            //For transition
        }
        else
        {
            Graphics.Blit(source, destination);
        }
    }
Пример #5
0
    public VHSShaderValue Lerp(VHSShaderValue val1, VHSShaderValue val2, float lerp)
    {
        VHSShaderValue res = new VHSShaderValue();

        lerp = Mathf.Clamp01(lerp);

        //Blur
        res.blurIntensity      = Mathf.Lerp(val1.blurIntensity, val2.blurIntensity, lerp);
        res.blurColorIntensity = Vector3.Lerp(val1.blurColorIntensity, val2.blurColorIntensity, lerp);
        //Color
        res.tint            = Color.Lerp(val1.tint, val2.tint, lerp);
        res.evenOffsetRed   = Mathf.Lerp(val1.evenOffsetRed, val2.evenOffsetRed, lerp);
        res.evenOffsetGreen = Mathf.Lerp(val1.evenOffsetGreen, val2.evenOffsetGreen, lerp);
        res.evenOffsetBlue  = Mathf.Lerp(val1.evenOffsetBlue, val2.evenOffsetBlue, lerp);
        res.decalageRoug    = Vector2.Lerp(val1.decalageRoug, val2.decalageRoug, lerp);
        res.decalageVert    = Vector2.Lerp(val1.decalageVert, val2.decalageVert, lerp);
        res.decalageBleu    = Vector2.Lerp(val1.decalageBleu, val2.decalageBleu, lerp);
        res.saturation      = Mathf.Lerp(val1.saturation, val2.saturation, lerp);
        res.redIntensity    = Mathf.Lerp(val1.redIntensity, val2.redIntensity, lerp);
        res.greenIntensity  = Mathf.Lerp(val1.greenIntensity, val2.greenIntensity, lerp);
        res.blueIntensity   = Mathf.Lerp(val1.blueIntensity, val2.blueIntensity, lerp);
        res.noirEtBlanc     = Mathf.Lerp(val1.noirEtBlanc, val2.noirEtBlanc, lerp);
        //Bug
        res.tailleBug         = Mathf.Lerp(val1.tailleBug, val2.tailleBug, lerp);
        res.decalageDansLeBug = Mathf.Lerp(val1.decalageDansLeBug, val2.decalageDansLeBug, lerp);
        res.verticalGlitch    = val1.verticalGlitch || val2.verticalGlitch;
        res.vitesseBug        = Mathf.Lerp(val1.vitesseBug, val2.vitesseBug, lerp);
        //Noise
        res.tolerance  = Mathf.Lerp(val1.tolerance, val2.tolerance, lerp);
        res.noiseColor = Color.Lerp(val1.noiseColor, val2.noiseColor, lerp);
        //Tram
        res.tramFrac      = Mathf.Lerp(val1.tramFrac, val2.tramFrac, lerp);
        res.tramRythm     = Mathf.Lerp(val1.tramRythm, val2.tramRythm, lerp);
        res.tramIntensity = Mathf.Lerp(val1.tramIntensity, val2.tramIntensity, forTramIntensityTransition.Evaluate(lerp));
        res.tramColor     = Color.Lerp(val1.tramColor, val2.tramColor, lerp);

        res.floatEffectIntensity = Mathf.Lerp(val1.floatEffectIntensity, val2.floatEffectIntensity, lerp);
        res.floatNoiseDensity    = Mathf.Lerp(val1.floatNoiseDensity, val2.floatNoiseDensity, forNoiseFloatDensityTransition.Evaluate(lerp));
        return(res);
    }
Пример #6
0
    public void ApplyVHSValueOnMat(VHSShaderValue val, Material mat)
    {
        mat.SetFloat("_Blur", val.blurIntensity);
        mat.SetFloat("_BlurForBlue", val.blurBlueIntensity);

        mat.SetColor("_Color", val.tint);
        mat.SetVector("_OffsetBlue", val.decalageBleu);
        mat.SetFloat("_Saturation", val.saturation);
        mat.SetFloat("_NbIntensity", val.noirEtBlanc);

        mat.SetFloat("_Taille", val.tailleBug);
        mat.SetFloat("_Decalage", val.decalageDansLeBug);
        mat.SetFloat("_typeOfBug", val.verticalGlitch ? 1 : 0);
        mat.SetFloat("_Speed", val.vitesseBug);

        mat.SetFloat("_ToleranceBWNoise", val.tolerance);
        mat.SetColor("_NoiseColor", val.noiseColor);

        mat.SetFloat("_Tramage", val.tramFrac);
        mat.SetFloat("_Tram2", val.tramRythm);
        mat.SetFloat("_TramIntensity", val.tramIntensity);
        mat.SetColor("_TramColor", val.tramColor);
    }
Пример #7
0
    private void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        if (matToApply != null)
        {
            if (targetEffect.Count > 1)
            {
                VHSShaderValue val = GetCurrentVHSEffect();
                ApplyVHSValueOnMat(val, matToApply);
            }
        }


        if (matToApply != null)
        {
            RenderTexture tmp = destination;
            Graphics.Blit(source, tmp, matToApply);
            //Graphics.Blit(tmp, destination);
            //Graphics.Blit(tmp, destination); //doesn't seem usefull (only one blit, so less calcul)
        }
        else
        {
            Graphics.Blit(source, destination);
        }
    }