Jump to content

  • Log In with Google      Sign In   
  • Create Account


GS Geometry from texture?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 CptBonex   Members   -  Reputation: 162

Like
0Likes
Like

Posted 05 June 2012 - 02:20 AM

I resently read about geometry shaders but I only found examples where you pass vertex data to the GS and then create new geometry. I was thinking is it possible to not give the geometry shader any vertrices and have it create new ones by reading a texture? So that the only thing I have to do is give the shader a texture and out comes some nice looking terrain.

If there is? Is there any tutorials or something where I can read about it?

Sponsor:

#2 iedoc   Members   -  Reputation: 637

Like
0Likes
Like

Posted 05 June 2012 - 03:41 AM

you have to at least pass a single vertex to the geometry shader, but from that single vertex you'd be able to make your terrain and send it back to your app through the stream output. You might also consider looking into the tesselation shaders

about how to do it, all you have to do is read the texture the same way you would read it in a vertex or pixel shader. you would create a grid, where each texel in the texture represents the height of each vertex in the grid.

Edited by iedoc, 05 June 2012 - 03:46 AM.

Braynzar Soft - DirectX Lessons & Game Programming Resources!

#3 japro   Members   -  Reputation: 887

Like
0Likes
Like

Posted 05 June 2012 - 03:50 AM

Note that the geometry shader is not really meant for massive geometry amplification. Using it to say expand points to quads or so is ok. Using it to create vast amounts of vertices from a texture most likely isn't.
Not sure about dx but at least from OpenGL i know that you can render without using a vertex buffer by essentially using the vertex id as the only input and calculating the rest from there.

#4 iedoc   Members   -  Reputation: 637

Like
0Likes
Like

Posted 05 June 2012 - 04:04 AM

japro's right about a lot of geometry, which is why i mentioned the tesselation shaders. but if your just talking about making terrain, i wouldn't generate it in the shaders anyway if it's not going to be moving around like water. I guess if you wanted to just make the terrain while initializing the scene you could do that, but you could just make your own terrain in your app by making a grid and changing each vertice's height depending on the texture.
Braynzar Soft - DirectX Lessons & Game Programming Resources!

#5 CptBonex   Members   -  Reputation: 162

Like
0Likes
Like

Posted 05 June 2012 - 05:18 AM

Well actually my terrain is dynamic and it is and made to change each frame. Right now every chunk is stored in byte files and loaded on the go as i need them. But I thought that creating it from a texture could help me to get the right light without doing calculations on the cpu or doing multiple passes as the light is depending on the terrain cells neibours.

#6 Nik02   Crossbones+   -  Reputation: 2629

Like
0Likes
Like

Posted 05 June 2012 - 06:25 AM

Geometry shader is severely limited in the amount of data it can write out per invocation.

You could:

-use a flat grid, and displace it in VS by reading from a heightmap texture
-use a single quad, and tessellate it; in the domain shader, displace the generated geometry like you'd do in vs
-use instancing to render several tessellated quads; use the instance id to look up the quad index to determine the part of the heightmap texture you want to use for that quad

Niko Suni





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS