这是一篇年前:2021.1.28 些的日志
主要是备忘用
帮美术同学修改完 shader 后 发现烘焙后 alpha test 的 shader 都没有了投影镂空的效果
导致树叶之间的投影 乌黑一大片,然后搜索了一下
还好的是,发现 taecg 老师也在某乎上写过这个问题的处理分享
看了这篇文章就知道:unity黑箱 + 文档不说明有多 e xin:关于AlphaTest阴影烘焙后消失的问题
处理要点:
- 主纹理名称必须是"_MainTex",只有这个名称才会被内部识别到,就像后处理Shader中也需要用到这个名称是一样的道理。
- Shader中的Queue排序在2450-3999之间,也就是"Queue" = “AlphaTest"或者"Queue” = “Transparent”.
- RenderType设置为"RenderType" = “Transparent"或者"RenderType” = “TransparentCutout”.
记住要处理:Forwardbase 和 ShadowCaster 两个 shader 的 tag, queue 等
如果我们要重写 ShaderGUI 那么注意处理这两点即可,如下:
References- 关于AlphaTest阴影烘焙后消失的问题
// jave.lin 2022/08/27 为 SanGuo_PBR_MRA_SSS shader 材质的编辑器重写
using UnityEngine;
using UnityEditor;
using System;
using System.Collections.Generic;
public enum JAVELIN_RenderType
{
Opaque,
AlphaTest,
TransparentWithoutPMA,
TransparentWithPMA,
Additive,
Subtractive,
}
public enum JAVELIN_ShowFaceType
{
Front,
Back,
DoubleSide,
}
public class SanGuo_PBR_MRA_SSS_MAT_GUI : ShaderGUI
{
static MaterialProperty FindAndRemoveProperty(string propertyName, List propertyList)
{
return FindAndRemoveProperty(propertyName, propertyList, true);
}
static MaterialProperty FindAndRemoveProperty(string propertyName, List propertyList, bool propertyIsMandatory)
{
for (var i = 0; i 0)
{
for (int i = 0; i
关注
打赏
最近更新
- 深拷贝和浅拷贝的区别(重点)
- 【Vue】走进Vue框架世界
- 【云服务器】项目部署—搭建网站—vue电商后台管理系统
- 【React介绍】 一文带你深入React
- 【React】React组件实例的三大属性之state,props,refs(你学废了吗)
- 【脚手架VueCLI】从零开始,创建一个VUE项目
- 【React】深入理解React组件生命周期----图文详解(含代码)
- 【React】DOM的Diffing算法是什么?以及DOM中key的作用----经典面试题
- 【React】1_使用React脚手架创建项目步骤--------详解(含项目结构说明)
- 【React】2_如何使用react脚手架写一个简单的页面?