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

Light Trails

9 posts in this topic

I'm trying to create light trails using DirectX. My main purpose is to emit light trails from character's eyes. Now i'm doing this with point sprites and alpha blending. But i dont get good results. So my question is how can i create light trails? Thanks.
0

Share this post


Link to post
Share on other sites
What do your current trails look like, and what makes it "not good"? What are you trying to achieve instead?
1

Share this post


Link to post
Share on other sites
Thanks for reply. I attached screenshots. As you can see it just looks like point array :D. I want something like beam.
0

Share this post


Link to post
Share on other sites
[quote name='ekba89' timestamp='1307817463' post='4822149']
Thanks for reply. I attached screenshots. As you can see it just looks like point array :D. I want something like beam.
[/quote]


If you want to create a beam, you'll want to create a continous strip of triangles instead of using particle effects. Each frame, add on a new quad that joins onto the quad from the previous frame. When you reach the maximum number of segments that you want, start removing the old ones. To make it fade off, you can set an alpha value on the vertices that fades to 0 as they approach the end of the beam.
1

Share this post


Link to post
Share on other sites
Thanks for reply. But with quads i have to make them always look to screen. Is there a easy way to do this or should i calculate each frame what wil be the rotation angles.
0

Share this post


Link to post
Share on other sites
This "stream of billboard quads" is quite common in a lot of games (things like smoke trails behind projectiles, etc). Sometimes you see it referred to as "particle ribbons".
Before vertex shaders, you'd manually have to rotate the quad's verts to face the camera each frame, but these days you can do it in a shader.

In either case, the logic behind it is quite simple: the [url="http://en.wikipedia.org/wiki/Cross_product"]cross-product[/url] of the camera's forward direction, and the direction from one particle's position to the next gives you a direction that's perpendicular to both of those. i.e. the resulting direction will stick out sideways at 90º from the ribbon, and be 90º from the camera, so it's always facing the camera.

In top-down ASCII art form:[code]
x->----x->----x->



^
|
C[/code]The 'x's are your particles. The arrows pointing to the right represent the direction from one 'x' to the next one.
The 'C' is the camera, and the arrow pointing up is the direction it's looking in.
If you get the cross product of those two directions, the result points towards you, out of the monitor ([i]or [/i]into [i]the monitor if you swap the order of the inputs to the cross product equation[/i]).
Each 'x' then becomes two vertices, one shifted out of the monitor ([i]in this case[/i]), and the other shifted into the monitor. In this case, that gives us 6 vertices, which we can stitch together into a ribbon of quads which face the camera.
0

Share this post


Link to post
Share on other sites
Thanks. Nice explanation :D. But what if we have something like
[code]
^
|
x
^
|
x


^
|
C
[/code]

i have to use camera right vector don't i?
0

Share this post


Link to post
Share on other sites
By the way now i was trying to get nice beam looking light by using point size (d3dfvf_psize). It looks nice but i have another problem.As you can see in the second screenshot they are drawing top of each other. How can i make them draw according to how close they are to the camera. I'm planning to save a float for minimum distance from particle to camera and update it every frame. When adding new particle i will check if it is less than min distance ill push it front of the list and update the min distance if not push it back to the list. Is there a more efficient way?
0

Share this post


Link to post
Share on other sites
[quote name='ekba89' timestamp='1307880018' post='4822366']But what if we have something like ...[/quote]If the camera is looking in the exact same direction as the ribbon, the illusion breaks down, yeah... ([i]simply using the camera's right-vector won't fix it either[/i])
Often this simply isn't a problem because the player won't notice ;), but [i]if it is[/i] easy for the player to get the camera into such a situation, you can often work-around this issue by drawing regular point-sprites as well as the ribbon ([i]as an extension, you can fade the ribbon out as you approach this angle, and fade the point-sprites in[/i]).

Regarding your sorting -- you could simply turn off the depth test so that they all draw over the top of each other no matter the order. Depending on your blending mode this might cause artifacts of it's own though.
Alternatively, sorting a list of a few dozen to a few hundred items every frame is actually pretty cheap.
0

Share this post


Link to post
Share on other sites
Thanks with z test disabled it looks nice but i cant lower their size because when i do that it doesnt look like continous. I think if i can draw all particles with big size then resize all of them like they are one big particle my problem will be solved. Also ill definitely check particle ribbons to see if i can get better results .Thanks for pointing that out.
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