Gamestudio Links
Zorro Links
Newest Posts
Z9 getting Error 058
by jcl. 07/22/26 06:42
ZorroGPT
by TipmyPip. 07/21/26 17:54
New Zorro version 3.11
by jcl. 07/21/26 13:42
Lapsa's very own thread
by Lapsa. 07/18/26 13:40
Purchase A8 full licence version
by ukgamer. 07/17/26 05:52
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
1 registered members (1 invisible), 1,544 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
riggi89, shuhari, KD1990, Ephraim, Student_64151
19223 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Apply heightmap to vertices on GPU #412248
11/24/12 16:29
11/24/12 16:29
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline OP
Expert
Kartoffel  Offline OP
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Hi there,

I'm looking for a way to apply a heightmap to a terrain.
I want to do this GPU-side because doing it on the CPU is too slow.

Has anyone got an idea for this?

regards, Alex


POTATO-MAN saves the day! - Random
Re: Apply heightmap to vertices on GPU [Re: Kartoffel] #412255
11/24/12 17:47
11/24/12 17:47
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
I don't think that this is possible because tex2D or similar commands are (with a few exceptions) not supported in vertex shaders.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Apply heightmap to vertices on GPU [Re: Superku] #412259
11/24/12 19:06
11/24/12 19:06
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline OP
Expert
Kartoffel  Offline OP
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Thanks for the answer!

storing the information in an array could work...
but I'm not sure if shader model 3.0 supports enough indices for doing this.


POTATO-MAN saves the day! - Random
Re: Apply heightmap to vertices on GPU [Re: Kartoffel] #412261
11/24/12 19:16
11/24/12 19:16
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline OP
Expert
Kartoffel  Offline OP
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
yea, it doesn't support enough... smirk


POTATO-MAN saves the day! - Random
Re: Apply heightmap to vertices on GPU [Re: Kartoffel] #412272
11/24/12 20:22
11/24/12 20:22
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Well, actually the intrinsic function tex2D and tex2Dlod can be used in a vertex shader to sample a 2D texture, but you require at least Shader Model 3 for it, plus, the graphics card has to support that. For example the function is only supported on NVidia cards from GeForce 6/7 Series and higher, and NV4x-based Quadro FX; for ATI cards I don't have any information about that. Besides, working with matrices on the CPU is not a big deal. I don't know what you are doing and how big the heightmap is, but maybe you should consider to write a multithreaded routine that transfers the contents of a matrix into the mesh on the CPU prior rendering.

Re: Apply heightmap to vertices on GPU [Re: HeelX] #412437
11/27/12 13:50
11/27/12 13:50
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline OP
Expert
Kartoffel  Offline OP
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
another question, is it possible to modify vertex positions via shaders
I mean constantly modifying, not per frame modification.

Last edited by Kartoffel; 11/27/12 13:51.

POTATO-MAN saves the day! - Random
Re: Apply heightmap to vertices on GPU [Re: Kartoffel] #412465
11/27/12 16:57
11/27/12 16:57
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Originally Posted By: Kartoffel
is it possible to modify vertex positions via shaders I mean constantly modifying, not per frame modification.


What do you mean exactly? What do you want to do?

Re: Apply heightmap to vertices on GPU [Re: HeelX] #412466
11/27/12 17:04
11/27/12 17:04
Joined: May 2005
Posts: 2,713
Lübeck
Slin Offline
Expert
Slin  Offline
Expert

Joined: May 2005
Posts: 2,713
Lübeck
You can set them to a value read from a heightmap or from wherever, but this won´t effect the meshs representation within the engine, just the output. And you can´t set the vertex positions in one frame and add to those positions in another frame, what you can do is just setting them to whatever value you want within the vertex shader, which is processing each vertex every frame the mesh is rendered.
If you want for example an "endless terrain" which is always moving with the player and reads the vertices height values from a heightmap, you can do this very fast in a shader, while doing this in your script would be really slow.

Re: Apply heightmap to vertices on GPU [Re: Slin] #412472
11/27/12 18:52
11/27/12 18:52
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline OP
Expert
Kartoffel  Offline OP
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Originally Posted By: HeelX
What do you mean exactly? What do you want to do?

A realtime terrain editor. smile My thought was it to have a heightmap I can "draw" on.
Within the shader I want to set vertex.y based on the correspondending pixel of the heightmap.


Originally Posted By: Slin
You can set them to a value read from a heightmap or from wherever, but this won´t effect the meshs representation within the engine, just the output

That's what I wanted to do, but VS doesn't support texture-reading functions like tex2D / 3D / whatever.
I also thought about storing the information in an array but SM 3.0 doesn't support enough indices for this method...

Last edited by Kartoffel; 11/27/12 18:56.

POTATO-MAN saves the day! - Random
Re: Apply heightmap to vertices on GPU [Re: Kartoffel] #412473
11/27/12 19:00
11/27/12 19:00
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Why don't you manipulate the vertices close to the mouse/ brush on the CPU? This should be really fast in your case. If you want you can still calculate a heightmap from your vertices for whatever reason.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Page 1 of 2 1 2

Moderated by  Blink, Hummel, Superku 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1