• 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
Yura

Best way to draw cylinder

8 posts in this topic

Hi

I need some effective way to draw cylinder, many cilinders. Basicly, I'm rendering primitives on my scene,  but making cylinder from primitives is very unprofitably (especially circles) - much additional points needed. So, I'm searching alternative way to draw awesome fast-drawing cylinders.  

I thought about textures, but I don't know how to make textured cylinder, which will stay cylinder when I'll rotate camera. 

0

Share this post


Link to post
Share on other sites

You will be able to draw a hell of a lot of cylinders before you reach the point where it's too many polygons for any vaguely modern hardware. You could generate multiple LODs if necessary so cylinders far away from your camera use fewer triangles.

 

Otherwise, I imagine you could render quads and do some clever maths in a pixel shader to draw a cylinder, but that's much harder and probably more expensive than doing it with triangles.

 

You could also look at imposters, 2D sprites which you can update as your camera position changes, but only when it changes beyond a certain threshold. Again, lots of work, probably little gain, just render the triangles.

1

Share this post


Link to post
Share on other sites

I would make a single unit-cylinder (radius = 1.0, height range from -0.5 to +0.5), and pass in the desired radius and height. Then multiply the vertex in the unit cylinder by float3( desiredRadius, desiredHeight, desiredRadius ) before the transform. Allowing you to just have one geometry block shared across all cylinders for a small memory footprint.

 

As someone else said, you should be able to draw an awful lot of cylinders before it becomes a problem.

 

n!

Edited by nfactorial
1

Share this post


Link to post
Share on other sites

I see two different possibilities:

 

1. Define a cylinder as a your base mesh, using radius = 1.0 and height = 1.0.  Then you could use this as the instance basis, and then just pass the per-instance data that is needed to scale the cylinder and place it where you want it in the proper orientation (i.e. a transformation matrix only, since you can do a scale in Y for scaling the height, scale in X and Z for radius, then the standard rotation and translation can all be concatenated into one matrix).  This should be very efficient, with the vertex shader simply being a single transformation, and it should be faster than one draw call for each cylinder (plus a significant reduction in vertex buffer size needed).

 

2. You can try to use imposters if the precision isn't too strictly needed.  This is essentially rendering a few cylinders into textures, and then you use billboards to put them into the correct location within your scene.  This would be hard to get working in an acceptable quality, but could be very fast if it meets your requirements...

 

I would prefer #1, but your mileage may vary!

1

Share this post


Link to post
Share on other sites

In D3d9, you can try using D3DXCreateCylinder. There are tons of working examples you can find on the web to use this method.

 

Can't find this method in SharpDX.. Seems it's not exist in this library

0

Share this post


Link to post
Share on other sites

I'm displaying quite big 3D surface on my scene, it has enough primitives even without those cylinders (near 500 000, can be even more), so I'm quite limited in resources, even with modern hardware smile.png . 

 

Jason Zink

If I understood you right, you suggest (#1) not to store needed vertices, but to recalculate those cylinders with new parameters on each draw call to reduce buffer size? 

Edited by Yura
0

Share this post


Link to post
Share on other sites

I would make a single unit-cylinder (radius = 1.0, height range from -0.5 to +0.5), and pass in the desired radius and height. Then multiply the vertex in the unit cylinder by float3( desiredRadius, desiredHeight, desiredRadius ) before the transform. Allowing you to just have one geometry block shared across all cylinders for a small memory footprint.

 

As someone else said, you should be able to draw an awful lot of cylinders before it becomes a problem.

 

n!

 

One geometry block  shared across all cylinders - sounds nice. You wrote about initialization above, give me more information about where I need to store those points? Maybe, some code samples?

0

Share this post


Link to post
Share on other sites

Jason Zink

If I understood you right, you suggest (#1) not to store needed vertices, but to recalculate those cylinders with new parameters on each draw call to reduce buffer size?

Basically just to use instanced rendering.  You will have a base mesh to represent your 'unit' cylinder, and then you load another vertex buffer with per-instance data (the transformation I mentioned above).  That second vertex buffer will allow you to draw all of your cylinders in one draw call, and your total memory consumption is significantly reduced.
1

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