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

Help with smooth voronoi diagrams

4 posts in this topic

[source lang="vb"]
sub vor_gradient cdecl(px as f32_t, pz as f32_t, weights as integer, vret as vor_return ptr)

dim as integer x = int(px), z = int(pz)

dim as vvalue pmin(WEIGHTS-1)
dim as vpoint ptr p2

dim as f32_t dist, mindist(WEIGHTS-1)

for i as integer = 0 to WEIGHTS-1
mindist(i) = 10 '' set to out of bounds distance
next

for dx as Integer = x-2 to x+2
for dz as integer = z-2 to z+2

p2 = @vor_points( dx and (VORONOI_TABLESIZE-1), dz and (VORONOI_TABLESIZE-1) )
dist = VOR_EUCLIDIAN( px, pz, dx + 0.5, dz + 0.5 )

for i as integer = 0 to WEIGHTS-1
if dist <= mindist(i) then

for j as integer = WEIGHTS-1 to i+1 step -1
'' set N-closest
pmin(j) = pmin(j-1)
mindist(j) = mindist(j-1)
next

'' set closest
pmin(i).value = p2->value
mindist(i) = dist

exit for
endif
next

next
next

'' find max distance
#define length mindist(WEIGHTS-1)
#define weight(i) mindist(i)

'' inverse distance and recount weights
dist = 0.0
for i as integer = 0 to WEIGHTS-1
weight(i) = 1.0 - mindist(i) / length
dist += weight(i)
next

dim as uinteger cl = 0

'' finalize weights and create final color using N-vector
for i as integer = 0 to WEIGHTS-1
weight(i) /= dist
cl = adduint32(cl, pmin(i).value, weight(i))
next

'' return final composite
vret->v = cl

end sub
[/source]
I am trying to blend the nearby weights of voronoi cells
in this example all cell centers are at 0.5, 0.5 for simplicity's sake, and to show the error more clearly
I have tried for a day now to figure out what mistake I'm making, but i just dont understand what I'm doing wrong here

First: I find the N closest points (determined by WEIGHTS)
then I use the longest distance as the "normalizing value" all the way to the end
finally i divide by the total length of the inverted distances (so that the closest point has the strongest weight)
by listening to my brain, this should be working, but it doesn't seem like it's working alright.. :S
Please help!
Note: if you want me to recreate the function in C, that can be arranged since it's not an issue for me..

Here are some example images for 3,4 and 9 weights, first with center at (0.5, 0.5) then with centers at the respective cells for a total of 6 images:

[url="http://art.fwsnet.net/vor/w3c.png"]http://art.fwsnet.net/vor/w3c.png[/url]
[url="http://art.fwsnet.net/vor/w4c.png"]http://art.fwsnet.net/vor/w4c.png[/url]
[url="http://art.fwsnet.net/vor/w9c.png"]http://art.fwsnet.net/vor/w9c.png[/url]

[url="http://art.fwsnet.net/vor/w3.png"]http://art.fwsnet.net/vor/w3.png[/url]
[url="http://art.fwsnet.net/vor/w4.png"]http://art.fwsnet.net/vor/w4.png[/url]
[url="http://art.fwsnet.net/vor/w9.png"]http://art.fwsnet.net/vor/w9.png[/url] Edited by Kaptein
0

Share this post


Link to post
Share on other sites
When you rasterize a colored Voronoï diagram, you can determine the winning (nearest) node for each pixel, and paint the pixel with the color of the winning node. It's computationnally huge, but it's pixel-accurate and easy to implement.

But it wouldn't produce a 'smoothed' Voronoï diagram .... is it possible to explain what does this smooth represent ?

[img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
0

Share this post


Link to post
Share on other sites
I've already shown in the previous images sort-of what i want, but the keywords are: transitions with continuity [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
or crossfade, if you will
here is my best effort so far:
[url="http://fbcraft.fwsnet.net/gonzonoi.png"]http://fbcraft.fwsnet.net/gonzonoi.png[/url]
and my conclusion is: it can't be done
it can be done "pretty well", but anything short of 100% success is worthless to me
i need total control over ramps and curves, and my example image is one that already has discontinuities using best-match trial and error
googling around for anything like voronoi diagrams and weights only shows each diagram being assigned a weight that determines its control exertion
i guess i'll yet again just have to look for something completely different to solve my problem [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] Edited by Kaptein
0

Share this post


Link to post
Share on other sites
I think it can be done as you wish, as an extention of the algorithm I gave above, but instead of saying "[i] this [/i]node is the closest", you can take into account the distances of [i]all [/i]nodes, expressed as probabilities. Then you blend the nodes colors accordingly to these probabilities to get the final pixel color.
0

Share this post


Link to post
Share on other sites
this isn't a finite set, it's infinite
i can only grab WEIGHTS amount of nodes around me, or the algorithm will never finish
regardless, i think i figured out in the end, that determining the weights for the nearest points at any point in space is easy enough
but it was impossible to do this in a way that made the image continous
the more weights i grab, the more it will look like a soup of colors anyways
the final result where i gave up was where i had set a minimum distance that gave 100% weight to one color, and anything under that was distributed as evenly as i could
it wasn't all that bad, but it was insufficient for the purpose of what i need it for

i hope i haven't wasted anyones time with this..
seeing the complete lack of information on voronoi diagrams with weights AND id's, i'll just have to assume that it can't be done properly
you just arent able to determine the correct weights as you go (and keep in mind, the nodes aren't centered on a grid in the final result, only when testing) Edited by Kaptein
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