[UnityShader基础]LOD

来源:互联网 发布:金星妻子 知乎 编辑:程序博客网 时间:2024/06/08 05:05

本文片段摘自:猫都能学会的Unity3D Shader入门指南,请点击链接查看原文,尊重楼主版权。

LOD

案例:

Shader "Custom/Diffuse Texture" {      Properties {        _MainTex ("Base (RGB)", 2D) = "white" {}    }    SubShader {        Tags { "RenderType"="Opaque" }        LOD 200        CGPROGRAM        #pragma surface surf Lambert        sampler2D _MainTex;        struct Input {            float2 uv_MainTex;        };        void surf (Input IN, inout SurfaceOutput o) {            half4 c = tex2D (_MainTex, IN.uv_MainTex);            o.Albedo = c.rgb;            o.Alpha = c.a;        }        ENDCG    }     FallBack "Diffuse"}

LOD很简单,它是Level of Detail的缩写,在这里例子里我们指定了其为200(其实这是Unity的内建Diffuse着色器的设定值)。这个数值决定了我们能用什么样的Shader。
在Unity的Quality Settings中我们可以设定允许的最大LOD,当设定的LOD小于SubShader所指定的LOD时,这个SubShader将不可用。Unity内建Shader定义了一组LOD的数值,我们在实现自己的Shader的时候可以将其作为参考来设定自己的LOD数值,这样在之后调整根据设备图形性能来调整画质时可以进行比较精确的控制。

  • VertexLit及其系列 = 100
  • Decal, Reflective VertexLit = 150
  • Diffuse = 200
  • Diffuse Detail, Reflective Bumped Unlit, Reflective Bumped VertexLit = 250
  • Bumped, Specular = 300
  • Bumped Specular = 400
  • Parallax = 500
  • Parallax Specular = 600
原创粉丝点击