Results 1 to 9 of 9

Thread: Water/terrain rendering

  1. #1
    Legendary Member NecroDOME's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands, Eindhoven
    Posts
    1,059

    Water/terrain rendering

    Hi guys,

    I'm still busy with my 3D engine, so far so good. But now I have stumbled upon some questions regarding water/terrain rendering (basicly the same).

    I want to have a grid that is transformed by a heightmap in real time.

    What I want to know is what is the best approach.
    - I can calculate everyting on the CPU, what would be kinda slow.
    - I can do texture lookup in a vertex shader 3.0. However there are some restrictions and limitations on this one, and it is not supported on ATI cards I think.

    Anyone any idea how to render a grid with real-time animated waves?

    Thanks in advance!
    NecroSOFT - End of line -

  2. #2

    Water/terrain rendering

    At least in OpenGL you can use vertex array. May not be fastest but it's 1 way. You can create a single trianglestrip to cover the entire visible rectangular ocean grid. You only need to define texture coordinates once, maybe even X and Z coordinates for vertices too and only change Vertex Y when animating, or is it just texture coordinates that change. Depending ofc how do you animate it. I would imagine normals are not needed with water, and they slow rendering down a bit.

  3. #3
    Legendary Member NecroDOME's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands, Eindhoven
    Posts
    1,059

    Water/terrain rendering

    You can do similar stuff with DirectX, but I want a way to do it on the video card. In my rendering I want to do it screen-space, so every coordinate changes as I move the camera.
    NecroSOFT - End of line -

  4. #4

    Water/terrain rendering

    Are you sure about Texture-lookup not being supported by ATI cards? :shock: (We are talking about Tex2d() right?). Tex2d() is AFAIK a very basic and populair HLSL function. I can't imagine it not being supported by ATI. :?

    You should start looking of info about Tex2D() on ATI-cards. If you have an URL with some more info about whether it works or not, i would like to see it.

    And i also would like to know about those restrictions and limitations. I think reading some more docs would be a good idea in this case.

    P.S: According to MSDN, Tex2d() is supported by all shadermodels:
    http://msdn.microsoft.com/en-us/libr...77(VS.85).aspx
    I assume this is also the case on ATI cards.
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  5. #5
    Legendary Member NecroDOME's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands, Eindhoven
    Posts
    1,059

    Water/terrain rendering

    tex2D is only supported in pixel shaders, not in vertex shaders. I can use tex2Dlod, that is supported in vertex shader 3.0. In vertex shaders this only works with 32 bit floating point textures (R32F and A32R32G32B32F (on nVidia cards that is at least)).
    Also texture lookups in vertex shaders do not use any filtering or mip mapping. It's just point plane filtering.

    Anyway here's an nice article about it: http://www.ziggyware.com/readarticle.php?article_id=127

    edit:
    AFAIK
    - nVidia supports texture loopups in vertex shader
    - ATI supports rendering to a vertex buffer via pixels shader
    NecroSOFT - End of line -

  6. #6

    Water/terrain rendering

    Okay... lol ops: I totally forgot about the difference between vertex- and pixelshaders. In this case, you need your texture-lookup in the vertexshader, which is a problem.

    Maybe you can do something with parameterized terrain, but that would require an awefull lot of math, and it's only good for total random terrain generation.

    And that article looks very interesting.
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  7. #7
    Legendary Member NecroDOME's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands, Eindhoven
    Posts
    1,059

    Water/terrain rendering

    im still looking for a solution. Maybe I can use 2 vertex buffers? 1 for terrain and one for height offset? In this case I have a static buffer and a second dynamic buffer. However I have to dive into this to see if I can get it to work and if it's even possible...
    NecroSOFT - End of line -

  8. #8

    Water/terrain rendering

    All DirectX 10 GPUs can do vertex texture fetch (just tried running NVidias Direct3D9 VTF demo on ATI Radeon 4850). They can also use all available texture formats, not just FP32 (but this may work only in D3D10?).

    I had similar problem once (it was OpenGL program and vertex texture lookup doesn't work there even for new ATI cards). I used 2 buffers as you wrote earlier. I had a static triangulated 2D grid which was reused for every terrain block. Scalar height values were in separate buffers (one for each terrain block).
    Vampyre Imaging Library
    Earth Under Fire (PGD Big Boss 3rd place)
    Domains Of Chaos (PGD Multiplexity 5th place)

  9. #9
    Legendary Member NecroDOME's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands, Eindhoven
    Posts
    1,059

    Water/terrain rendering

    I know, but I'm not gonna use DX 10 atm. Just looking for some proof of concept that works on both nVidia and ATI cards, preferably on shader model 2, but shader model 3 is also no problem.
    NecroSOFT - End of line -

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •