Jump to content

  • Log In with Google      Sign In   
  • Create Account


Lode

Member Since 29 Mar 2002
Offline Last Active Aug 23 2014 05:18 PM

Topics I've Started

Something between bilinear and bicubic interpolation?

03 August 2014 - 02:35 PM

Hello,

 

Bilinear interpolation generates visible crosses, see image from wikipedia to see what I mean, I mean the horizontal and vertical structures and sharp edges:

 

jLg2YP4.png

 

Bicubic interpolation looks much rounder:

 

RedJIfK.png

 

 

 

Imagine now that the colors are types of world (tundra, desert, grass, ...): the rounder shapes are *highly* preferable over the ugly "crosses" of bilinear interpolation.

 

However, bicubic interpolation has two disadvantages (the second being the most problematic for me):

 

1.) It requires 16 points, rather than only 4 points. It would be highly preferable for me to only have to use the 4 corners of a square zone, not corner points of neighboring zones as well

2.) Values can overshoot, that is, they can become lower or higher than the 4 corners of this zone. I really don't want this, "conditions" in a zone should be bounded by its corners for convenience reasons (predictable range of values in a zone).

 

So, the question is:

Does there exist a way of 2D interpolating that only uses 4 corner points and only returns values in that range, but, looks "rounder" than bilinear interpolation?

Thanks! smile.png


Random river and road generation without knowing full world?

23 July 2014 - 11:32 AM

Hello,

 

For a randomly generated world, I'm trying to find a way of randomly generating rivers in the landscape.

 

However, unlike for example in Dwarf Fortress, in my world the whole world is not known beforehand. DF generates the rivers with physical models on the entire landscape. That is not my intention.

 

In my case, the world is more like it works in Minecraft: a sector is only generated when you encounter it. Generating heights, humidity and so on is done this way with perlin noise, and that can work in independent sectors.

 

What I mean by "working in independent sectors" is that it is able to generate a sector with pseudorandom numbers, without any information about the other sectors, and yet if you zoom out and see the whole world, all the sectors smoothly connect together.

 

But for rivers, which of course go through many sectors, you sort of need to know where a begin and end is, so I can't find a way to generate it "independently". The fact that ideally the rivers would also flow from mountains to oceans makes it even more difficult. Same for roads: I want roads to connect cities, but a sector in-between ideally should not have to know which sectors contain the actual cities (as that is something that the city-sector alone can only know from its own pseudorandom values).

 

The simplest algorithm that does achieve that is to simply have a grid of cities (roads are the edges, a city at every intersection), but that is boring.

 

Are there algorithms for "independent" random river and road generation? And what is this concept called?

Thanks!


good random permutation?

13 July 2014 - 02:14 PM

Hello,

 

I'm looking for a way to map a 31-bit positive integer (leaving some room for Java!) to another 31-bit positive integer, for purpose of random world generation, with the following properties:

-if you go through the inputs in sequence, the resulting output sequence should be a good pseudo-random sequence

-it should not require state. So a linear congruence generator or similar will not work afaik. Instead, it should be able to give you the output for any of the inputs at any time, no requirement to go through it in order.

-it should be fast, so cryptographic hashes are probably not it

-it should be stable: always give the same output for the same input (so no true random generator smile.png)

-each result is unique, that is, every possible integer is output by one input integer (not the most important requirement, but would be nice, each output value should have equal probability). So some arbitrary bit twiddling and multiplications won't do it either

 

I tried to implement something similar to the following one:

 

http://preshing.com/20121224/how-to-generate-a-sequence-of-unique-random-integers/

 

but it's actually not that great, I want to use a seed value as well, and while this one works great for some seeds, it does not for many as well and to make it even more annoying, it gives too similar patterns for seeds that are near each other (so if you generate for coordinates x and y a random world temperature with seed 1000 and a random height with seed 1001, they will be too correlated. Or something like that, in any case the patterns are ugly with nearby seeds).

 

Does anyone have suggestions for such a function?

Thanks a lot! smile.png


Derivative of complex function: taken in which direction?

27 April 2014 - 03:36 AM

Hi,

Given the function: f(x) = im(x). So, it takes the imaginary part of x.

On the real line, this function always returns 0. However, in the imaginary direction, it returns real values and has a slope of 1.

With the definition of the derivative, you look in the real direction only and miss that there's a slope in the imaginary direction. Wolfram Alpha gives 0: http://www.wolframalpha.com/input/?i=derivative+of+f%28x%29+%3D+im%28x%29+at+x+%3D+5

So, is that indeed correct then? Do you have to ignore the slope in imaginary direction for a derivative? Shouldn't the answer be something like 1, or -i?

My concern is that this derivative is not useful for Newton's method to find zeroes of complex functions, e.g. the above example would always return 0 even though there's a slope. I'm also wondering how to define slope in a 4D space (2D input, 2D output).

Thanks.


HSL with smoother transitions?

12 April 2014 - 04:41 PM

Hello,

 

It's extremely hard to explain with words, so I hope the image says it all:

 

iUtRd8v.png

 

The standard HSL color model looks like the image on the left.

 

Depending on which angle from your screen you look at it (im my case it's always visbile but more when looking from the bottom), you can clearly see that there is a horizontal line in the middle of the image. It's in fact just a difference in how it transitions, but the human eye/brain somehow makes a "line" of it. In addition, there are 3 such vertical lines, between the red and green, between the green and blue, and in the purple zone.

 

The red markings in the centermost image contain where those ugly lines are.

 

And the rightmost image shows a plot of a mathematical function (guess which) made with that very HSL color model. And there it is, the ugly line is visible there as well.

 

I'd like to make better looking plots. It should still be a HSL-like color model: still black at the bottom, white at the top (HSV is not white at the top), and all hues in the center. But smoothed in some way that no such obvious lines are visible.

 

I now use the standard HSL to RGB conversion function I already tried, after HSL to RGB, to set Y to the lightness with RGB->YUV->RGB conversion, but that looks even uglier, yellow becomes olive.

 

Does anyone know:

 

If there's a trick to make HSL color better for such mathematical plotting purpose?

 

What the phenomenon with the "lines" is called?

 

Another more suitable color model?

Thanks!


PARTNERS