• unity meta pass


    简单说就是在meta pass计算

    albedo,emission,specular

    3个值

    光照烘焙,gi计算间接光照时都会用到这些值

    Shader "MyShader/SampleLightmap"
    {
    	SubShader
    	{
    		Pass
    		{
    			CGPROGRAM
    			#pragma vertex vert
    			#pragma fragment frag
    			#pragma multi_compile _ LIGHTMAP_ON
    			#include"Lighting.cginc"
    
    			struct VertexData
    			{
    				float4 pos:POSITION;
    				float2 uv:TEXCOORD0;
    				float2 uv1:TEXCOORD1;
    			};
    
    			struct V2F
    			{
    				float4 pos:SV_POSITION;
    				float2 uv:TEXCOORD0;
    				#if defined(LIGHTMAP_ON)
    					float2 uv1:TEXCOORD1;
    				#endif
    			};
    
    
    			V2F vert(VertexData v)
    			{
    				V2F res;
    				res.pos = UnityObjectToClipPos(v.pos);
    				res.uv = v.uv;
    				#if defined(LIGHTMAP_ON)
    				res.uv1 = v.uv1 * unity_LightmapST.xy + unity_LightmapST.zw;
    				#endif
    				return res;
    			}
    
    			fixed4 frag(V2F i) :SV_TARGET
    			{
    				fixed4 col = fixed4(1,0,0,1);
    				#if defined(LIGHTMAP_ON)
    					col.rgb = DecodeLightmap(UNITY_SAMPLE_TEX2D(unity_Lightmap, i.uv1));
    				#endif
    				return col;
    			}
    			ENDCG
    		}
    
    
    		Pass
    		{
    			Tags{ "LightMode" = "Meta" }
    
    			CGPROGRAM
    			#pragma vertex vert
    			#pragma fragment frag
    			#include "UnityStandardInput.cginc"
    			#include "UnityMetaPass.cginc"
    
    	
    			struct V2F
    			{
    				float4 pos:SV_POSITION;
    				float4 uv:TEXCOORD0;
    			};
    
    
    			V2F vert(VertexInput v)
    			{
    				V2F o;
    				o.pos = UnityMetaVertexPosition(v.vertex, v.uv1.xy, v.uv2.xy, unity_LightmapST, unity_DynamicLightmapST);
    				o.uv = TexCoords(v);
    				return o;
    			}
    
    			fixed4 frag(V2F i) :SV_TARGET
    			{
    				UnityMetaInput o;
    				UNITY_INITIALIZE_OUTPUT(UnityMetaInput, o);
    				o.Albedo = fixed3(1, 1, 0); //这里只是将漫反射添加到烘焙贴图中去
                        o.Emission = xxxx;
                        o.SpecularColor = xxxx;
    return UnityMetaFragment(o); } ENDCG } } }

      

    meta pass

    https://blog.csdn.net/wodownload2/article/details/94554057

    https://blog.csdn.net/cgy56191948/article/details/100766303

  • 相关阅读:
    cenos安装memcache
    微信开发——测试号申请,接口配置,JS接口安全域名,自定义菜单
    mysql设计-优化
    mysql设计-基本操作
    CI框架部署后访问出现404
    ueditor的bug
    git操作
    github基本操作
    基于SSH协议clone GitHub远端仓库到本地-git
    Thinkphp5.0 路由
  • 原文地址:https://www.cnblogs.com/nafio/p/14315093.html
Copyright © 2020-2023  润新知