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

Making a mesh appear face by face

8 posts in this topic

Hi all, I'd like to build this animation effect. It should animate over time the appearance of a mesh by having its faces appear either randomly (ie from zero faces to all of them) or through some sort of pattern (ie given a starting face, have all the others appear through an expanding radius). One simple way to do it would be to animate the VertexBuffer, but it doesn't seem the brightest idea. 

 

Another idea I had would be to use a Vertex Struct having Alpha information and then in the vertex shader fetch from a 1D texture (or float array, which would be faster?) the corresponding alpha value for the given vertex. Perhaps it would be necessary to have a vertexId value in the vertex struct itself? So in the shader I could do (HLSL)

output.color.a = alphaValues[input.vertexId];

In theory if I set all three face vertices' alpha to zero, that face should disappear, correct? Assume that I am not using indices.

Are there any other possibly better ways to do it?

0

Share this post


Link to post
Share on other sites

That's actually true, I didn't think about that! Thanks!

 

However, in that way the only possible appearance pattern would be the order in which the vertices were defined. I guess if I wanted to have some control, I could presort the vertices accordingly before rendering. I must have a habit of overthinking things :(

0

Share this post


Link to post
Share on other sites

If you want more control you can add a vertex parameter that is simply a single float value set randomly between 0 and 1.
The vertex buffer is created alongside your main vertex buffer and set to stream 1 (while the vertex buffer you normally use is set to stream 0).

The values from 0 to 1 indicate how long it takes each vertex to go from 0 alpha to full alpha.
When you want to begin the effect (generating different alpha buffers allows the effect to be different for each instance of the mesh) you put a per-instance timer from 0 to 1 that takes however long you want the effect to be (if you want it to last 5 seconds then it takes 5 seconds to go from 0 to 1) and inside the vertex shader each vertex’s alpha is set to saturate( fFadeTime * inRandomTime ) where inRandomTime is the special random number in the stream-1 vertex buffer.

 

Draw the whole vertex buffer every frame while increasing fFadeTime in the shader slowly.

 

Every vertex will fade in at random speeds in random spots until the whole mesh is displayed.

 

 

L. Spiro

0

Share this post


Link to post
Share on other sites

Another alternative (and assuming a newer API like DX10+) you could also use SV_PrimitiveID. Generate a alpha in you pixel shader procedurally or use the ID as a lookup index into a buffer/texture.

1

Share this post


Link to post
Share on other sites

Thanks all, I'll try to implement my own version as soon as possible!

 

 

When you want to begin the effect (generating different alpha buffers allows the effect to be different for each instance of the mesh) you put a per-instance timer from 0 to 1 that takes however long you want the effect to be (if you want it to last 5 seconds then it takes 5 seconds to go from 0 to 1) and inside the vertex shader each vertex’s alpha is set to saturate( fFadeTime * inRandomTime ) where inRandomTime is the special random number in the stream-1 vertex buffer.

 

Just one clarification: if those two are both values between [0 and 1] with inRandomTime not changing over time, won't alpha = saturate(fFadeTime * inRandomTime) be equal to inRandomTime when fFadeTime reaches 1? Ie if inRandomTime is 0.5 when the timer has reached 1, the alpha value would be saturate(1 * 0.5) = 0.5

0

Share this post


Link to post
Share on other sites


However, in that way the only possible appearance pattern would be the order in which the vertices were defined. I guess if I wanted to have some control, I could presort the vertices accordingly before rendering. I must have a habit of overthinking things sad.png

 

If you're using a simple single index buffer approach, you could still get a decent amount of variation.

 

Instead of starting at the start of the buffer, and increasing the count every time you render, start at some randomised point in the middle of the index buffer, and as you increase the desired number of triangles, randomise whether you're going to add the extra triangle by increasing the count alone, or by increasing the count and moving back the start point.

 

If the effect doesn't feel sufficiently randomised, then have 3 or 4 different index buffers to choose from at random, and the result will probably be noisy enough to appear completely random to the player.

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