【UE5绿皮纪实】逐材质Custom Stencil Value 在用UE的时候,或多或少都会对官方的Custom Stencil Value和Overlay Material有些不满:为什么这么好用的功能是逐Actor / Mesh的而不是逐材质的? 其实这玩意是能改到逐材质的,在Stencil的写入的部分本身就写入了材质信息: 可以看到在输入里是有读到Material这个参数的。
CustomDepthRendering.cpp 修改自定义深度渲染,因为自定义深度和自定义Stencil在UE中是绑定在一起的,默认就可以获取到CustomDepthStencilValue,所以只需要把我们创建的材质中的MaterialStencilValue传给它就行。有这里找到位置将注释地方更换掉,如果MaterialStencilValue大于0就直接输出给CustomDepthStencilValue Stencil的项目设...
Stencil Value从0-255可以自己设置,一般推荐从250到255. 打开view mode可以看到 与custom depth不同的是,custom stencil可以理解为 custom depth,黄色为物体,d为到摄像头的像素数,背景M可以理解为极大数 custom stencil,背景可以理解为0,s为物体设置的stencil值 ...
找到Render in Depth Pass选项,打勾。 找到Render CustomDepth Pass 选项,打勾。 备注:有一定机率需要关闭 Render in Main Pass 选项才能成功。 备注:多个对象可以手动调节前后关系,通过 CustomDepth Stencil Value 。 在High Resolution Screenshot 面板中 勾选 Use Custom Depth as Mask 选项,即可输出。 其它笔记...
Weapon->SetRenderCustomDepth(true); Weapon->SetCustomDepthStencilValue(CUSTOM_DEPTH_RED); } void AEnemyBase::UnHighlightActor() { GetMesh()->SetRenderCustomDepth(false); Weapon->SetRenderCustomDepth(false); } 1. 2. 3. 4. 5. 6. ...
the final image in real time. In this Unreal Tips & Tricks video, we'll discuss the Custom Depth Buffer render target used in a Post Process Material, which allows us to quickly mask out any subject. For additional help, please see the documentation:https://docs.unrealengine.com/Engine/...
custom stencil custom stencil理解为在custom depth的基础上,又自定义一个value,又是另外一个通道 可视化:直接把custom stencil的color连到color上, 可以看到custom stencil是一个0-255的int值 也可以在viewport里直接选择custom stencil的pass查看,更直观 写材质 完整材质截图,(有的模糊,但是能看得清)接下来一步步...
进入MaterialInterface.h 它是UMaterial 和 UMaterialInstance 的 父类,主要用于定义各种接口和通用的一些属性,这里可以暴露给引擎层再材质中修改Stencil的值,然后定义一个虚函数,子类来覆盖修改它的函数体。 UMaterial和UMaterial中也同要需要定义,因为这里都是只用获取MaterialStencilValue , 所以这里实现体都一样 然后...
Custom Depth 减去 Scene Depth 收缩到0 -1 得到 还记得得到最终描边的图像么 两者相差得到 就得到了遮挡部分描边 效果 未遮挡部分描边 原始描边图像如下 遮挡部分描边如下 两者相减得到,就是非遮罩地方的描边 最终效果 优化 CustomDepth减去极大值的图像
Stencil Value从0-255可以自己设置,一般推荐从250到255. 打开view mode可以看到 与custom depth不同的是,custom stencil可以理解为 custom depth,黄色为物体,d为到摄像头的像素数,背景M可以理解为极大数 custom stencil,背景可以理解为0,s为物体设置的stencil值 ...