zoukankan      html  css  js  c++  java
  • [Shder]物体溶解效果

    <1>效果图

           

    <2>源码:剔除像素 融合就看随机值的大小啦 越靠近0 融合红色 黄色

          

    Shader "Legacy Shaders/Transparent/Diffuse" {
    Properties{
    _Color("Main Color", Color) = (1,1,1,1)
    _AddCol("Add Color",Color)=(1,0,0,1)
    _AddColY("_AddColY",Color)=(1,1,0,1)
    _MainTex("Base (RGB) Trans (A)", 2D) = "white" {}
    _NoiseTex("mmp",2D) = "white" {}
    _Speed("速度",Range(0.1,2)) = 0.1
    }

    SubShader{
    Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
    LOD 200

    CGPROGRAM
    #pragma surface surf Lambert alpha:fade

    sampler2D _MainTex;
    sampler2D _NoiseTex;
    fixed4 _Color;
    float _Speed;
    fixed4 _AddCol;
    fixed4 _AddColY;

    struct Input {
    float2 uv_MainTex;
    };

    void surf(Input IN, inout SurfaceOutput o) {
    fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
    fixed r = tex2D(_NoiseTex, IN.uv_MainTex).r;
    r -= _Time.x*_Speed;

    o.Albedo = c.rgb;

    //融合颜色
    if (r<0.1)
    o.Albedo = c.rgb*_AddColY;

    if(r<0.04)
    o.Albedo = c.rgb*_AddCol;


    //剔除
    if (r<0)
    clip(r);

    o.Alpha = c.a;
    }
    ENDCG
    }

    Fallback "Legacy Shaders/Transparent/VertexLit"
    }

  • 相关阅读:
    uva-10160-枚举
    zk-systemd
    c++官方文档-枚举-联合体-结构体-typedef-using
    c++官方文档-动态内存
    c++官方文档-指针
    c++官方文档-命名空间
    c++官方文档-模版函数和重载
    c++官方文档-按值传递和按引用传递
    c++官方文档
    HDU 1068
  • 原文地址:https://www.cnblogs.com/cocotang/p/7412667.html
Copyright © 2011-2022 走看看