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

Some help with drawing a Wu Xiaoling line

7 posts in this topic

Hey, I'm going trying to draw the Wu line as he describes it in his paper, but I don't understand some of the concepts that he talks about. First thing that I don't understand is the error he calculates for DDA. Let me quote him
[quote]
The values can be determined by an elegant incremental algorithm opoerating on a single integer D represented by a machine word of n bits. The integer increment involved is d = floor(k*2 + 0.5)"
[/quote]
This part I understand

[quote]
The operation D <- D + d is a module 2^n addition with the overflow recorded.
[/quote]
This I'm a little fuzzy about. What is a module 2^n addition?

[quote]
This is essentially a classical DDA method... For the following analysis we may consider D as a fixed point number with the decimal point before its most significant bit, or conceptually percieve the proposed integer arithmetic as fixed point arithmetic. Thus the error between the real DDA increment and our integer DDA increment is [i] e = k - d*2^(-n) [/i]
[i][/quote][/i]
This I don't understand at all. How does he come up with that error. k is the slope and d is the increment, n is the number of bits in D. But how does he come up with a negative exponent and why is he subtracting.

[quote]
All gray-scale raster devices have 2^m, for some m > 1 discrete intensity levels from 0 to 2^m - 1. The intensity interpolation between the two vertically adjacent pixels becomes a bi-partition of the integer I, the maximum intensity. The intensity of the upper pixel for the line is
I( x, ceil(k*x) ) = (2^m - 1) * (D*2^(-n) + ex) = D*2^(m-n) + ....
[/quote]
Here he lost me completely. I understand that 2^m - 1 is the alpha basically, usually set to 255. But how did he tie in D and the error e? He goes on:

[quote]
The approximated I(x, ceil(k*x) ) ~ D*2^(m - n) is simply presented by the m most significant bits of D... Now we see that the integer D controls both the pixel positions and intensities
[/quote]

Can anyone tell me what the heck is he talking about?
0

Share this post


Link to post
Share on other sites
Perhaps not an proper answer to your question, but wikipedia may help you:
[url="http://en.wikipedia.org/wiki/Xiaolin_Wu"]http://en.wikipedia.org/wiki/Xiaolin_Wu's_line_algorithm[/url] (shows an implementation of the algorihm)
0

Share this post


Link to post
Share on other sites
[quote name='Syranide' timestamp='1327404037' post='4905753']
Perhaps not an proper answer to your question, but wikipedia may help you:
[url="http://en.wikipedia.org/wiki/Xiaolin_Wu"]http://en.wikipedia.org/wiki/Xiaolin_Wu's_line_algorithm[/url] (shows an implementation of the algorihm)
[/quote]

Oh believe you me, I've devoured that article tens of times, that and all the other articles that I could find on the subject, now I'm reading Michael Abrashes explanation, so far his makes the most sense to me.
0

Share this post


Link to post
Share on other sites
[quote name='Syranide' timestamp='1327404037' post='4905753']
Perhaps not an proper answer to your question, but wikipedia may help you:
[url="http://en.wikipedia.org/wiki/Xiaolin_Wu"]http://en.wikipedia.org/wiki/Xiaolin_Wu's_line_algorithm[/url] (shows an implementation of the algorihm)
[/quote]
Your link is broken, for some reason the URL gets cut at the apostrophe =/
0

Share this post


Link to post
Share on other sites
[quote name='VanillaSnake21' timestamp='1327404594' post='4905755']
[quote name='Syranide' timestamp='1327404037' post='4905753']
Perhaps not an proper answer to your question, but wikipedia may help you:
[url="http://en.wikipedia.org/wiki/Xiaolin_Wu"]http://en.wikipedia.org/wiki/Xiaolin_Wu's_line_algorithm[/url] (shows an implementation of the algorihm)
[/quote]

Oh believe you me, I've devoured that article tens of times, that and all the other articles that I could find on the subject, now I'm reading Michael Abrashes explanation, so far his makes the most sense to me.
[/quote]

Ah, I guess you could look at Bresenham's code a bit too on wikipedia, may not be directly applicable, but they do go through some short explanatations and optimizations...

Anyway, as you understand I have little knowledge of this myself, but!


"The operation D <- D + d is a module 2^n addition with the overflow recorded."
I'm pretty sure he just means D = (D + d) % (2^n) ... and he stores the overflow ... somewhere. Or it's just strangely worded?

"[i]e = k - d*2^(-n)"[/i]
Again, just my first hand instinct, negative n seems reasonable as the error should go down as the number of bits go up. Especially as it seems that d is related to 2^n, by the above.

"I( x, ceil(k*x) ) = (2^m - 1) * (D*2^(-n) + ex) = D*2^(m-n) + ...."
I'm guessing this is just a continuation on the above to some degree, with d replaced by D (as D is in-fact d, but accumulated).


Again, I may be completely stumbling in the dark here, so if this makes no sense either, it's probably because it doesn't ;)
1

Share this post


Link to post
Share on other sites
[quote name='Syranide' timestamp='1327406213' post='4905759']
[/quote]

Lol, that does make sense, especially the error part, I didn't think of it that way. I've just finished reading Abrashe's article (conveniently his whole book is found right [html]<a href="http://www.gamedev.net/page/resources/_/technical/graphics-programming-and-theory/graphics-programming-black-book-r1698"> here </a>[/html] at Gamedev, for anyone interested). He explains everything thoroughly, and I do understand the gist of it now. But still I can't seem to get it right in my code! Here's what I came up with, trying not to copy his but do it from my understanding.

[code]

void WuFast(int x0, int y0, int x1, int y1)
{
int DeltaY = y1 - y0;
int DeltaX = x1 - x0;
int IntensityShift = 16 - 8;
WORD ErorrAdj = ((unsigned long)DeltaY << 16) / (unsigned long)DeltaX;
WORD ErrorAcc = 0;

Plot(x0, y0, Build_GrayScale(255));

while(--DeltaX)
{
WORD tErrorAcc = ErrorAcc;
ErrorAcc += ErorrAdj;

x0++;

if(ErrorAcc < tErrorAcc)
y0++;


int Weight = ErrorAcc >> IntensityShift;
int InverseWeight = Weight ^ 255;
Plot(x0,y0, Build_GrayScale(Weight));
Plot(x0, y0 + 1, Build_GrayScale(InverseWeight));


}

}

[/code]

What happens is that I get a very jagged line that looks nowhere near anti-aliased [img]http://public.gamedev.net//public/style_emoticons/default/angry.png[/img]
Here's an image to show you what I mean

[sharedmedia=gallery:images:1633]
0

Share this post


Link to post
Share on other sites
That line looks correct to me, except it seems like the antialiasing is backwards... flip the white and black and you'll see that it looks right. Tried it quickly in photoshop and indeed, that is the case.

Good work!
1

Share this post


Link to post
Share on other sites
[quote name='Syranide' timestamp='1327410626' post='4905772']
That line looks correct to me, except it seems like the antialiasing is backwards... flip the white and black and you'll see that it looks right. Tried it quickly in photoshop and indeed, that is the case.

Good work!
[/quote]

You're right! Setting the background to white made a huge difference - it looks amazing! You can't believe how many forms of this algorithm I have written thinking that I've been getting it wrong somehow because all the lines have been coming out jagged. I just tested all of them again with white background and surprisingly they all worked flawlessly, hahaha. Anyways thanks Syranide, you literally saved me from a week worth of frustration. So the night has paid off well, time to catch some zzz [img]http://public.gamedev.net//public/style_emoticons/default/rolleyes.gif[/img]
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