struct vertex_input
{
float4 position : POSITION;
float4 normal : NORMAL;
float2 uv : TEXCOORD0;
};
struct vertex_output
{
float4 position : POSITION;
float tex1 : TEXCOORD1;
};
vertex_output main(
vertex_input IN
, uniform float4x4 ModelViewProj
, uniform float du
, uniform float dv
, uniform sampler2D heightmap
)
{
vertex_output OUT;
float4 h = tex2D(heightmap, IN.uv);
...
...
}
ATI 1950 PRO no texture fetching?
I have an ATI 1950 PRO graphics card. I am trying to implement displacement mapping in the vertex shader and I therefore do a lookup in a height_map:
But I get an error at runtime that the vertex program could not be created. If I outcomment the call to tex2D it runs fine. I have heard that texture fetching are not working for some ATI cards, is that the reason that I get an error?
Vertex texture fetch is not supported on the X1950. It's a required feature of DX10, but not DX9. As such, it's implemented as a proprietary extension on the Geforce 6/7 series. But from what I hear, it's far too slow to be of any real use anyway.
Ok I have now inserted my old GF 7600 GS card and now it works (wierd since ATI X1950 PRO is a much better card). But I don't think my GF7600 GS is able to run DX10 so how come it works?
Because Nvidia implemented it on their GF 6/7 cards as an extension IIRC, even though it's not required for a DX9-level card.
Ok but what card do I need to get to run it in realtime? Are there any algorithms that can optimize the lookup in the texture the vertex program?
Doing texture fetches in a shader to use a heightmap is the wrong way to go. Typically, the heightmap is turned into a mesh at load time. Since the heightmap doesn't change, there's no point in resampling it every frame in a vertex shader. And even if the heightmap does change, it'll likely be infrequent enough that you can just generate the mesh again.
Mesh or not I still have to do a lookup in the vertex program for each frame to displace the vertex or am I misunderstanding you?
No. When you load your program, use the height map to displace the vertices in the mesh, and store the mesh somewhere. Then you can just render your pre-displaced mesh normally without having to do a texture lookup in the vertex shader.
Ok but that just moves the displacement problem to the CPU instead of the GPU right? I thought the whole point was to make the process faster doing the displacement on the GPU.
Quote:Original post by mlt
Ok but that just moves the displacement problem to the CPU instead of the GPU right?
Yes
Quote:I thought the whole point was to make the process faster doing the displacement on the GPU.
Yes. But this is NOT your case.
This is because that's when the CPU needs to do the displacement EACH AND EVERY frame. So translating the problem to the GPU speeds up the process.
However, you need to compute the displacement in only ONE frame (usually at start up).
The GPU doesn't suppport doing this once and saving the result forever. Therefore the only slowdown you will get for doing this in the CPU is when displaying the "Loading..." screen.
That's the whole idea of precomputing
Remember, usually "precomputing" is better than "real-time" (most cases and scenarios)
Cheers
Dark Sylinc
Edit: Sorry for the Caps Lock, but I think it highlights the point better, I didn't want to offend anybody
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement