Problem: I need to retrieve a heightmap value, given a texel coordinate during runtime.
I'm trying to avoid having another copy of the texture on the CPU, as it's already sitting in the GPU and it's rather large.
So, what I've been trying to do is get a colour value from the pixel shader in D3DFMT_R32F format and then slap it into a 1x1 texture-surface in sysmemory.
Result so far: the returned height is always 1.0 and PIX claims the surface is empty.
Relevant code:
Vert/Pix shader (pastebin.com)
Initialization code (pastebin.com)
Render to surface code (pastebin.com)
Retrieval code (pastebin.com)
If anyone can provide a hint as to where I might have gone wrong, or maybe have a better idea of how I can solve my problem, or gotchas' I might not be conscious of, I would sure appreciate the help!
EDIT: This is Direct3D 9 in Windows 7, ATI HD4850
[Edited by - PSS on January 5, 2011 9:12:30 PM]
(SOLVED-ish)Retrieving data from GPU to CPU (GetRenderTargetData)
Is the heightmap texture a static texture you've loaded into D3DPOOL_MANAGED? If that's the case, it will already have a copy in CPU memory that's managed by the runtime. In which case you can just lock it and grab a texel without worrying about stalling or slow readback issues.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement