我想知道是否可以从 Qt3D 中的 FBO 读取数据?我有 2 个渲染通道,一个保存在纹理中,另一个渲染在屏幕上。我想从纹理中读取像素,但到目前为止我还没有运气。
将不胜感激任何输入!
编辑:这是阴影贴图示例中的 RenderSettings 对象的一些代码。我要做的是在 pass 之后读取 shadowmapTexture 的某个位置。例如,在某个 x,y 位置上单击鼠标后,读取同一 x,y 位置上的 Texture2D 的数据。
property alias viewCamera: viewCameraSelector.camera
property alias lightCamera: lightCameraSelector.camera
readonly property Texture2D shadowTexture: depthTexture
activeFrameGraph: Viewport {
normalizedRect: Qt.rect(0.0, 0.0, 1.0, 1.0)
RenderSurfaceSelector {
RenderPassFilter {
matchAny: [ FilterKey { name: "pass"; value: "shadowmap" } ]
RenderTargetSelector {
target: RenderTarget {
attachments: [
RenderTargetOutput {
objectName: "depth"
attachmentPoint: RenderTargetOutput.Depth
texture: Texture2D {
id: depthTexture
width: 1024
height: 1024
format: Texture.DepthFormat
generateMipMaps: false
magnificationFilter: Texture.Linear
minificationFilter: Texture.Linear
wrapMode {
x: WrapMode.ClampToEdge
y: WrapMode.ClampToEdge
}
comparisonFunction: Texture.CompareLessEqual
comparisonMode: Texture.CompareRefToTexture
}
}
]
}
ClearBuffers {
buffers: ClearBuffers.DepthBuffer
CameraSelector {
id: lightCameraSelector
}
}
}
}
RenderPassFilter {
matchAny: [ FilterKey { name: "pass"; value: "forward" } ]
ClearBuffers {
clearColor: Qt.rgba(0.0, 0.4, 0.7, 1.0)
buffers: ClearBuffers.ColorDepthBuffer
CameraSelector {
id: viewCameraSelector
}
}
}
}
}