Esempio n. 1
0
    /// <summary>
    /// Creates the rain material.
    /// </summary>
    /// <param name="shaderType"></param>
    /// <param name="renderQueue"></param>
    /// <returns></returns>

    public static Material CreateRainMaterial(RainDropShaderType shaderType, int renderQueue)
    {
        var shader = Shader.Find(GetShaderName(shaderType));
        var mat    = new Material(shader);

        mat.renderQueue = renderQueue;
        return(mat);
    }
Esempio n. 2
0
    /// <summary>
    /// Apply the values to a material of rain object
    /// </summary>
    /// <param name="material"></param>
    /// <param name="shaderType"></param>
    /// <param name="normalMap"></param>
    /// <param name="overlayTexture"></param>
    /// <param name="distortionValue"></param>
    /// <param name="overlayColor"></param>
    /// <param name="reliefValue"></param>
    /// <param name="blur"></param>
    /// <param name="darkness"></param>

    public static void ApplyRainMaterialValue(
        Material material,
        RainDropShaderType shaderType,
        Texture normalMap,
        Texture overlayTexture = null,
        float distortionValue  = 0f,
        Color?overlayColor     = null,
        float reliefValue      = 0f,
        float blur             = 0f,
        float darkness         = 0f
        )
    {
        // Apply shader values
        switch (shaderType)
        {
        case RainDropShaderType.Expensive:
            material.SetColor("_Color", overlayColor ?? Color.white);
            material.SetFloat("_Strength", distortionValue);
            //material.SetFloat("_HeightOffset", 0.5f);
            material.SetFloat("_Relief", reliefValue);
            if (blur != 0f)
            {
                material.EnableKeyword("BLUR");
                material.SetFloat("_Blur", blur);
            }
            else
            {
                material.DisableKeyword("BLUR");
                material.SetFloat("_Blur", blur);
            }
            material.SetFloat("_Darkness", darkness);
            material.SetTexture("_Distortion", normalMap);
            material.SetTexture("_ReliefTex", overlayTexture);
            break;

        case RainDropShaderType.Cheap:
            material.SetFloat("_Strength", distortionValue);
            material.SetTexture("_Distortion", normalMap);
            break;

        case RainDropShaderType.NoDistortion:
            material.SetTexture("_MainTex", overlayTexture);
            material.SetTexture("_Distortion", normalMap);
            material.SetColor("_Color", overlayColor ?? Color.white);
            material.SetFloat("_Darkness", darkness);
            material.SetFloat("_Relief", reliefValue);
            break;

        default:
            break;
        }
    }
Esempio n. 3
0
    //public static string SHADER_DEFFERED = "RainDrop/Internal/RainDistortion (Deffered)";



    /// <summary>
    /// Get the shader name from RainDropShaderType
    /// </summary>
    /// <param name="shaderType"></param>
    /// <returns></returns>
    public static string GetShaderName(RainDropShaderType shaderType)
    {
        switch (shaderType)
        {
        case RainDropShaderType.Expensive:
            return(SHADER_FORWARD);

        case RainDropShaderType.Cheap:
            return(SHADER_CHEAP);

        case RainDropShaderType.NoDistortion:
            return(SHADER_NO_DISTORTION);

        default:
            return("");
        }
    }