shader开发_4.Surface shader初探
Posted 大.罗
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了shader开发_4.Surface shader初探相关的知识,希望对你有一定的参考价值。
可编程渲染管线
unity shader==>>Surface shader
Surface shader是 unity 对于顶点和片段着色器的一种封装
下面这是一个unity 默认生成的Surface shader
Shader "Custom/myshader01" { Properties { _Color ("Color", Color) = (1,1,1,1) _MainTex ("Albedo (RGB)", 2D) = "white" {} _Glossiness ("Smoothness", Range(0,1)) = 0.5 _Metallic ("Metallic", Range(0,1)) = 0.0 } SubShader { Tags { "RenderType"="Opaque" } LOD 200 CGPROGRAM // Physically based Standard lighting model, and enable shadows on all light types #pragma surface surf Standard fullforwardshadows // Use shader model 3.0 target, to get nicer looking lighting #pragma target 3.0 sampler2D _MainTex; struct Input { float2 uv_MainTex; }; half _Glossiness; half _Metallic; fixed4 _Color; void surf (Input IN, inout SurfaceOutputStandard o) { // Albedo comes from a texture tinted by color fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color; o.Albedo = c.rgb; // Metallic and smoothness come from slider variables o.Metallic = _Metallic; o.Smoothness = _Glossiness; o.Alpha = c.a; } ENDCG } FallBack "Diffuse" }
首先看一下基本结构
Shader "Custom/myshader01" { Properties { } SubShader { } FallBack "Diffuse" }
以上是关于shader开发_4.Surface shader初探的主要内容,如果未能解决你的问题,请参考以下文章