是否可以在3D模型之外添加片段?
在Godot的3D场景中,我试图为空间着色器创建一个像素完美的轮廓(在像素化效果后应用以确保相同的分辨率)。为此,我想将Pixels 直接修改为目标网格。
也就是说,我的预感是我根本无法在屏幕空间中网格区域之外修改像素,而且我必须使用单独的供体网格来实现此效果。这样做的问题是,我更不确定如何访问外部网格(我可以在屏幕上使用相同的像素完美效果,但必须是Perfect)。
我可能不得不解决的次要解决方案:为轮廓供入向内流血,牺牲了大纲最外层的像素,这是可以接受的折衷。
In a 3D scene in Godot, I am attempting to create a pixel-perfect outline for a Spatial shader (applied after a pixelation effect to ensure the same resolution). To achieve this, I would like to modify pixels directly adjacent to the target mesh.
That said, I have a hunch that I simply cannot modify pixels outside of a mesh's area in screespace, and that I would have to use a separate donor mesh to achieve this effect. The issue with this is that I'm even more unsure of how to access an external mesh (I am fine applying the same pixel perfect effect to all meshes on-screen, but it would have to be pixel-perfect).
A secondary solution that I may have to settle with: do an inwards bleed for the outline, sacrificing the outermost pixels for the outline, which would be acceptable compromise.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将要的元素渲染到
fiewport
使用cull_mask
正如我在另一个答案中所描述的那样/402022“>在这里。现在,您可以从该
fiewport
使用viewporttexture
(确保它是场景本地的,并且您正在使用node
)在场景树中放置在viewport
之后),并使用着色器对其进行处理。我建议您制作
fiewport
透明的背景,因此您可以使用Alpha频道检查是否呈现像素。轮廓像素将是那些未呈现的,而是与被渲染的像素相邻的。这是卷积边缘检测背后的想法。参见 kernel(image processing)。。
You can render just the elements you want to a
Viewport
usingcull_mask
as I just described in another answer here.Now, you can take the texture from that
Viewport
use aViewportTexture
(make sure it is local to the scene and you are using it aNode
placed after theViewport
in the scene tree) and process it using a shader.I suggest you make the background of the
Viewport
transparent, so you can use the alpha channel to check if a pixel is rendered or not. The outline pixels will be those which are not rendered but are adjacent to a pixel that was rendered.This is the idea behind convolution edge detection. See Kernel (image processing).