由于之前的 边缘检测不适应HDRP,在GitHub上找了个 https://github.com/IronWarrior/UnityOutlineShader

这个项目基于屏幕后处理,采用robot算子,进行图像边缘检测。在使用HDRP 5.10.0 时,不能正常运行,在markdown文件中查找到,由于5.3.0之后采用内置后处理V3框架,之前的就不能用了。

5.3之后将后处理特效移到了这里 Volume 里


怎么才能添加自己的屏幕后处理特效?
试着加一个官方的景深效果。

在代码中查找depthoffield,发现三个主要脚本,发现在前两个脚本功能是定义, 第三个脚本是怎么实现。 右侧DoDepthOfField函数是具体的实现。

发现调用API改变了 之前是这种
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
public sealed class PostProcessOutlineRenderer : PostProcessEffectRenderer<PostProcessOutline> { public override void Render(PostProcessRenderContext context) { var sheet = context.propertySheets.Get(Shader.Find("Hidden/Roystan/Outline Post Process")); sheet.properties.SetFloat("_Scale", settings.scale); sheet.properties.SetColor("_Color", settings.color); sheet.properties.SetFloat("_DepthThreshold", settings.depthThreshold); sheet.properties.SetFloat("_DepthNormalThreshold", settings.depthNormalThreshold); sheet.properties.SetFloat("_DepthNormalThresholdScale", settings.depthNormalThresholdScale); sheet.properties.SetFloat("_NormalThreshold", settings.normalThreshold); sheet.properties.SetColor("_Color", settings.color); Matrix4x4 clipToView = GL.GetGPUProjectionMatrix(context.camera.projectionMatrix, true).inverse; sheet.properties.SetMatrix("_ClipToView", clipToView); context.command.BlitFullscreenTriangle(context.source, context.destination, sheet, 0); } } |
现在API变为类似这种
1 |
void DoDepthOfField(CommandBuffer cmd, HDCamera camera, RTHandle source, RTHandle destination, bool taaEnabled) |
待续。。。
转载请注明:veyvin » 基于HDRP和LWRP屏幕后处理的边缘检测