小编Max*_*ris的帖子

如何在CGAL中计算一条线上的点

给定CGAL中的3D线,如何计算该线上距离端点已知距离的点?

c++ cgal computational-geometry

5
推荐指数
1
解决办法
795
查看次数

如何使用 Metal 将深度缓冲区保存到纹理?

我想将深度缓冲区保存到金属纹理中,但我尝试过的似乎都不起作用。

_renderPassDesc.colorAttachments[1].clearColor = MTLClearColorMake(0.f, 0.f, 0.f, 1.f);
[self createTextureFor:_renderPassDesc.colorAttachments[1]
                  size:screenSize
            withDevice:_device
                format:MTLPixelFormatRGBA16Float];

_renderPassDesc.depthAttachment.loadAction = MTLLoadActionClear;
_renderPassDesc.depthAttachment.storeAction = MTLStoreActionStore;
_renderPassDesc.depthAttachment.texture = self.depthTexture;
_renderPassDesc.depthAttachment.clearDepth = 1.0;   
Run Code Online (Sandbox Code Playgroud)

当我传递depthTexture到我的着色器(它与来自其他纹理的数据配合良好)时,我得到的只是红色像素。

当我更改clearDepth为接近零的值时,我会得到更深的红色阴影。也许我在着色器中没有正确采样纹理?

fragment float4 cubeFrag(ColorInOut in [[stage_in]],
                     texture2d<float> albedo [[ texture(0) ]],
                     texture2d<float> normals [[ texture(1) ]],
                     texture2d<float> albedo2 [[ texture(2) ]],
                     texture2d<float> normals2 [[ texture(3) ]],
                     texture2d<float> lightData [[ texture(4) ]],
                     texture2d<float> depth [[ texture(5) ]])
{
    constexpr sampler texSampler(min_filter::linear, mag_filter::linear);
    return depth.sample(texSampler, in.texCoord).rgba;
}
Run Code Online (Sandbox Code Playgroud)

metal

4
推荐指数
1
解决办法
1639
查看次数

标签 统计

c++ ×1

cgal ×1

computational-geometry ×1

metal ×1