Handmade Hero»Forums»Code
Livet Ersomen Strøm
163 posts
Periodic functions
Edited by Livet Ersomen Strøm on
d7samurai

I'm not so sure. First of all, for that to be the case you would have to make sure that the random functions in that algorithm are seeded with the same number(s) each time you invoke it. Secondly, there is no 'time' parameter there to shift the stars' positions in proportion to (and no algorithm to do to the shifting, nor to determine a (consistent) variability in movement speed - to simulate starfield depth, since all the stars you have will be at the same distance from the center).

I didn't quite understand whether you just wanted an algorithm to render a static starfield skydome texture for a 3D first person viewpoint or something more dynamic like this:

2D / parallax:
http://youtu.be/mUrJukqyhIE?t=28s

3D:
http://youtu.be/MiaqtUKALJU


I didn't have much time to think about it. And I still don't, but I can have "random" numbers like you say, and time I get from my "PhysicsTick".

"
z = rand(-1,1); // random number between -1 and 1
theta = rand(0,2*pi); // random number between 0 and 2*pi
r = sqrt(1 - z*z);
x = r * sin(theta);
y = r * cos(theta);
// The point (x,y,z) is what you want.
"

It wants a "random" number. Luckily those do not exist. So I will use a pseudorandom number. Or in other words. A pseudo-"unknown" number. That I will generate deterministically for the purpose :) LOL those "random" numbers are really really random.

The way I see it, R can give me many different fields, all moving at different speeds. But I will have to implement it first, and see. All in good time. Never had as much fun as this month, writing my first game.
Andrew Bromage
183 posts / 1 project
Research engineer, resident maths nerd (Erdős number 3).
Periodic functions
Kladdehelvete
Yeah. But who decide if it looks right?

The artist, usually. Certainly someone who has worked their way through the complete works of Edward Tufte.

The point he was making is that if you're making an augmented reality surgeon-assistance system, don't concern yourself with the refractive index of blood. It will "look right" without taking that into account.