Unity Surface Shaders 表面着色器备忘

12 篇文章 2 订阅

表面着色器不能写在pass中

输出结构

1.Standard

struct SurfaceOutput
{
    fixed3 Albedo;  // diffuse color
    fixed3 Normal;  // tangent space normal, if written
    fixed3 Emission;
    half Specular;  // specular power in 0..1 range
    fixed Gloss;    // specular intensity
    fixed Alpha;    // alpha for transparencies
};

2.physically based lighting models

Standard
struct SurfaceOutputStandard
{
    fixed3 Albedo;      // base (diffuse or specular) color
    fixed3 Normal;      // tangent space normal, if written
    half3 Emission;
    half Metallic;      // 0=non-metal, 1=metal
    half Smoothness;    // 0=rough, 1=smooth
    half Occlusion;     // occlusion (default 1)
    fixed Alpha;        // alpha for transparencies
};
StandardSpecular
struct SurfaceOutputStandardSpecular
{
    fixed3 Albedo;      // diffuse color
    fixed3 Specular;    // specular color
    fixed3 Normal;      // tangent space normal, if written
    half3 Emission;
    half Smoothness;    // 0=rough, 1=smooth
    half Occlusion;     // occlusion (default 1)
    fixed Alpha;        // alpha for transparencies
};

编译指令

#pragma surface surfaceFunction lightModel [optionalparams]

1.必要参数

  • surfacefunction 定义表面着色器函数名称。函数定义格式应为void surf (Input IN, inout SurfaceOutput o),Input为自定义输入结构,SurfaceOutput为输出结构,根据不同的lightModel做出变化。
  • lightModel 使用的光照模型
光照模型介绍
Standard对应SurfaceOutputStandard
StandardSpecular对应SurfaceOutputStandardSpecular
Lambert / BlinnPhong对应SurfaceOutput ,可用于低档硬件

2.可选参数

  • Transparency and alpha testing
alpha or alpha:auto
alpha:blend
alpha:fade
alpha:premul
alphatest:VariableName
keepalpha
decal:add
decal:blend
  • Custom modifier functions

  • Shadows and Tessellation

  • Code generation options

  • Miscellaneous options

3.输入结构

变量名称及类型注释
float3 viewDir
float4 with semantic
float4 screenPos
float3 worldPos
float3 worldRefl
float3 worldNormal
float3 worldRefl
float3 worldNormal
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值