zoukankan      html  css  js  c++  java
  • 总结

    1.我图中采用的模型是使用单模型多材质球,所以只展示了一个身体,单模型但材质直接赋值材质球就好,如果是单模型多材质的需要多创建几个材质球,因为每一部分的发现切图和Albedo图是不一样的。
    2.这里就不展示Demo了,东西比较简单,感兴趣的可以研究一下这个插件Amplify Shader Editor,我用的是1.6.1版本
    3.源码我也附上在下面

    源码:
    Shader “ASE/Ray”
    {
    Properties
    {
    _ASEOutlineWidth( “Outline Width”, Float ) = 0
    _Albedo(“Albedo”, 2D) = “white” {}
    _Normalmap(“Normal map”, 2D) = “white” {}
    _Color0(“Color 0”, Color) = (1,0,0,0)
    _Alpha(“Alpha”, Float) = 0
    _Bias(“Bias”, Range( 0 , 1)) = 0
    _Scale(“Scale”, Range( 0 , 1)) = 0
    _Power(“Power”, Range( 0 , 1)) = 0
    [HideInInspector] _texcoord( “”, 2D ) = “white” {}
    [HideInInspector] __dirty( “”, Int ) = 1
    }

    SubShader
    {
    Tags{ "RenderType" = "Transparent" "Queue" = "Transparent+0"}
    ZWrite Off
    ZTest Always
    Cull Front
    CGPROGRAM
    #pragma target 3.0
    #pragma surface outlineSurf Outline nofog alpha:fade keepalpha noshadow noambient novertexlights nolightmap nodynlightmap nodirlightmap nometa noforwardadd vertex:outlineVertexDataFunc



    struct Input
    {
    float3 worldPos;
    float3 worldNormal;
    INTERNAL_DATA
    };
    uniform float4 _Color0;
    uniform float _Bias;
    uniform float _Scale;
    uniform float _Power;
    uniform float _Alpha;
    uniform half _ASEOutlineWidth;

    void outlineVertexDataFunc( inout appdata_full v, out Input o )
    {
    UNITY_INITIALIZE_OUTPUT( Input, o );
    v.vertex.xyz += ( v.normal * _ASEOutlineWidth );
    }
    inline half4 LightingOutline( SurfaceOutput s, half3 lightDir, half atten ) { return half4 ( 0,0,0, s.Alpha); }
    void outlineSurf( Input i, inout SurfaceOutput o )
    {
    float3 ase_worldPos = i.worldPos;
    float3 ase_worldViewDir = normalize( UnityWorldSpaceViewDir( ase_worldPos ) );
    float3 ase_worldNormal = WorldNormalVector( i, float3( 0, 0, 1 ) );
    float fresnelNdotV7 = dot( ase_worldNormal, ase_worldViewDir );
    float fresnelNode7 = ( _Bias + _Scale * pow( 1.0 - fresnelNdotV7, _Power ) );
    float lerpResult18 = lerp( ( 1.0 - (_Color0).a ) , fresnelNode7 , (-2.0 + (_Alpha - 0.0) * (0.0 - -2.0) / (1.0 - 0.0)));
    o.Emission = _Color0.rgb;
    o.Alpha = lerpResult18;
    o.Normal = float3(0,0,-1);
    }
    ENDCG

    Tags{ "RenderType" = "Opaque" "Queue" = "Geometry+1" }
    Cull Back
    ZWrite On
    ZTest LEqual
    CGPROGRAM
    #pragma target 3.0
    #pragma surface surf Standard keepalpha addshadow fullforwardshadows vertex:vertexDataFunc
    struct Input
    {
    float2 uv_texcoord;
    };

    uniform sampler2D _Normalmap;
    uniform float4 _Normalmap_ST;
    uniform sampler2D _Albedo;
    uniform float4 _Albedo_ST;

    void vertexDataFunc( inout appdata_full v, out Input o )
    {
    UNITY_INITIALIZE_OUTPUT( Input, o );
    v.vertex.xyz += 0;
    }

    void surf( Input i , inout SurfaceOutputStandard o )
    {
    float2 uv_Normalmap = i.uv_texcoord * _Normalmap_ST.xy + _Normalmap_ST.zw;
    o.Normal = UnpackNormal( tex2D( _Normalmap, uv_Normalmap ) );
    float2 uv_Albedo = i.uv_texcoord * _Albedo_ST.xy + _Albedo_ST.zw;
    o.Albedo = tex2D( _Albedo, uv_Albedo ).rgb;
    o.Alpha = 1;
    }

    ENDCG
    }
    Fallback "Diffuse"
    CustomEditor "ASEMaterialInspector"
    --------------------- 

  • 相关阅读:
    IO流中文件和文件夹的删除程序举例
    2.14 小结
    mysql数据库分库分表(Sharding)
    django 连接mysql
    网页页面自动刷新代码
    python you-get 下载视频
    爬虫米扑代理
    python urlretrieve 下载图片
    UnicodeDecodeError: 'gbk' codec can't decode byte 0xae in position 120: illegal multibyte sequence
    create a bootable USB stick on Ubuntu
  • 原文地址:https://www.cnblogs.com/hyhy904/p/11329138.html
Copyright © 2011-2022 走看看