• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
multifractal

Heightmap Per Quad

6 posts in this topic

Hello,
I am struggling with the idea of generating a heightmap and normal map per quad on a single mesh. Currently I am using openCL to generate these maps and was planning on sending these textures to the vertex/frag shaders in order to modify the vertices and apply the lighting. But I see no way of doing this other than making each quad an individual mesh which I don't think is very efficient (managing ~400 meshes or so). So I was wondering if there were any other ways of doing this.
Any suggestion is hugely appreciated.
0

Share this post


Link to post
Share on other sites

you assemble individual quad meshes into a single big mesh of quads in regular ram with the cpu. then you copy them to dynamic buffers in vidram and draw:

 

for each quad:

translate to desired location in a larger mesh (say 10x10 to 100x100 quads) heightmap, and add to a vertex buffer / index buffer in RAM.

 

once done, lock a dynamic VB and IB allocated in vidram and memcpy the RAM copies to the vidram buffers. 

 

then draw using those.

 

 

i use a similar method:

for each ground texture N in a 300x300 terrain chunk:

      for each 10x10 quad X,Z in the chunk that uses texture N: 

            translate master copy of quad mesh to correct position in the terrain chunk

            heighmap quad

            add quad X,Z to ground mesh N

copy ground mesh N to a static VB and IB

draw per usual

0

Share this post


Link to post
Share on other sites

Instead of making each quad a mesh, you could make each quad have unique vertices and then use a texture array. Are you trying to implement PTEX? I'd like to see hardware/driver support for it in future versions of D3D/OpenGL.

 

https://developer.nvidia.com/sites/default/files/akamai/gamedev/docs/Borderless%20Ptex.pdf

No nothing that cool; just procedural terrain, 

 

 

you assemble individual quad meshes into a single big mesh of quads in regular ram with the cpu. then you copy them to dynamic buffers in vidram and draw:

 

for each quad:

translate to desired location in a larger mesh (say 10x10 to 100x100 quads) heightmap, and add to a vertex buffer / index buffer in RAM.

 

once done, lock a dynamic VB and IB allocated in vidram and memcpy the RAM copies to the vidram buffers. 

 

then draw using those.

 

 

i use a similar method:

for each ground texture N in a 300x300 terrain chunk:

      for each 10x10 quad X,Z in the chunk that uses texture N: 

            translate master copy of quad mesh to correct position in the terrain chunk

            heighmap quad

            add quad X,Z to ground mesh N

copy ground mesh N to a static VB and IB

draw per usual

So I should generate each quad as an individual mesh and then insert the vertex buffer into the parent mesh? 

0

Share this post


Link to post
Share on other sites

So I should generate each quad as an individual mesh and then insert the vertex buffer into the parent mesh? 

 

i have a "master quad" in ram, a RAM vb and ib for the big mesh of qauds, and a VB/IB in vidram.

 

the master quad is just a quad from 0,0,0 to 10,10,0.

 

first i transform the master quad values to the proper location, then heightmap them add them to the big quad in ram.

 

so let's say i'm adding the quad at x=50, z=20. i add 50 to the x of all 4 verts, and 20 to the z of all 4 verts. i pass the results to my heightmap function which returns my y values at those locations. then i pass all those results as the verts of the quad to add to the big mesh.

 

so i don't generate a quad each time i add one. i just repeatedly transform the one master quad generated at program start.

 

note that the master quad, and VB / IB in ram are just arrays of floats, not D3D data structures. only the VB/IB in vidram is a D3D data structure.

Edited by Norman Barrows
1

Share this post


Link to post
Share on other sites

 


So I should generate each quad as an individual mesh and then insert the vertex buffer into the parent mesh? 

 

i have a "master quad" in ram, a RAM vb and ib for the big mesh of qauds, and a VB/IB in vidram.

 

the master quad is just a quad from 0,0,0 to 10,10,0.

 

first i transform the master quad values to the proper location, then heightmap them add them to the big quad in ram.

 

so let's say i'm adding the quad at x=50, z=20. i add 50 to the x of all 4 verts, and 20 to the z of all 4 verts. i pass the results to my heightmap function which returns my y values at those locations. then i pass all those results as the verts of the quad to add to the big mesh.

 

so i don't generate a quad each time i add one. i just repeatedly transform the one master quad generated at program start.

 

note that the master quad, and VB / IB in ram are just arrays of floats, not D3D data structures. only the VB/IB in vidram is a D3D data structure.

 

Oh ok that makes a lot of sense. So originally I was sampling the heightmap in a vertex shader and then doing normal mapping in a pixel shader. Would this be possible the method you described?

Also should the "master quad" be start out as the maximum size a quad could be or should there be a quad for every differently sized quad?

Edited by multifractal
0

Share this post


Link to post
Share on other sites


Oh ok that makes a lot of sense. So originally I was sampling the heightmap in a vertex shader and then doing normal mapping in a pixel shader. Would this be possible the method you described?

 

the heightmap can be applied to the mesh in RAM before you send it off to directx for drawing, or you can use the vertex shader to apply the heightmap. the most efficient way will depend on your particular application.

 

 


Also should the "master quad" be start out as the maximum size a quad could be or should there be a quad for every differently sized quad?

 

if you have multiple sizes of quads, you can just scale a single unit sized master quad, or have a master copy of each size. a master copy for each size avoids the performance hit of one scaling operation per quad. it may also make the code simpler (or perhaps not). either way you have to track which scale or quad size to use.

 

i tend to use a CSG type of approach to drawing, so i'd probably just have a single unit quad that i scaled as needed for all quads in the game. the performance hit for one scaling operation per quad isn't that bad. especially compared to the drawing time for one quad.

 

as usual it depends on how you do things. you could use the CPU for transforming and the GPU for drawing, or you can do it all on the GPU with shader code. splitting the work between the CPU and GPU may be faster, or the GPU alone may be faster.

 

for best results, i suspect you'll want to recalculate the normals after heightmapping, but before applying lighting. at the moment i just leave mine at (0,1,0).

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0