Jump to content
  • Advertisement
Sign in to follow this  
Christoffer Enne

GS Geometry from texture?

This topic is 2354 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!