aliens

Author Topic: Globe improvements  (Read 68338 times)

Volutar

  • Guest
Re: Globe improvements
« Reply #45 on: December 15, 2011, 01:52:39 pm »
kkmic, dithering is needed to avoid sharp borders between different light levels. But as Yankes said - it was done by random noise, and I don't think it's a good idea. Noising night side isn't good either. It is definately subject to improve.
Quote
Can't you apply an per pixel alpha blending effect depending on it's position in the twilight?
It's technically impossible in 256 paletted color mode.

Offline Daiky

  • Battlescape Programmer
  • Administrator
  • Commander
  • *****
  • Posts: 904
    • View Profile
Re: Globe improvements
« Reply #46 on: December 15, 2011, 04:54:21 pm »
Isn't dithering rather slow to do real time (fps drop)?
I'd rather have the banding as in the original, it has a nice retro look to it ;)

Volutar

  • Guest
Re: Globe improvements
« Reply #47 on: December 15, 2011, 06:34:59 pm »
Nah, it's not.

Either you're using Ordered dithering
 
or simple error-diffusion

or random noise

(which Yankes used, as I suppose - he haven't released his sources) - you have to process almost whole image pixel-by-pixel. Original XCOM draws globe pixel-by-pixel - and that's not a problem at all :)
The only difference between these algorithms is either the image is stable or not. Ordered dithering is prefferable just because it won't "flicker" as others.
« Last Edit: December 15, 2011, 06:36:32 pm by Volutar »

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: Globe improvements
« Reply #48 on: December 15, 2011, 07:14:52 pm »
https://github.com/Yankes/OpenXcom/blob/master/src/Geoscape/Globe.cpp#L987
i released it ;P it would be strange if I did do that and ask SupSuper and Daiky to judge my code :) I try keep my fork up to date with my current version.
BTW i probably throw away half of this code soon :) I find out that more "brutal force" approach is better and faster.
current solution is more scalable, ugliest version is faster than "brutal force" but if you want get good looking globe it will take lot of more FPS to get it.

old solution was testing intersection between spheres, new one is comparing 3d normals of pixel in earth surface with sun direction.
additional new solution work much better with noise.


Volutar

  • Guest
Re: Globe improvements
« Reply #49 on: December 15, 2011, 07:48:50 pm »
Testing sun vector for each surface pixel???
Did you compare fps for those 2 methods?

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: Globe improvements
« Reply #50 on: December 15, 2011, 08:29:13 pm »
yes, and with current form openXcom.
using lowest rez and rotating globe i get:
orginal openXcom: ~1150 FPS
prev version (pretty, 32 different shades): ~600 FPS
prev version (ugly, only night and day without twilight): ~1200 FPS
new version: ~1150 FPS


Code: [Select]
Cord temp = earth;
https://diff
temp.x -= sun.x;
temp.y -= sun.y;
temp.z -= sun.z;
https://norm
temp.x *= temp.x;
temp.y *= temp.y;
temp.z *= temp.z;
temp.x += temp.z + temp.y;
temp.x = sqrt(temp.x);
temp.x -= sqrt(2)*rad;
if(temp.x > 0.)
if(temp.x>8.)
return 64;
else
return temp.x*8.;
else
return 0;
this is all thing I need compute to get it, `earth` is 3d normal of pixel in earth globe that is seen in display, `sun` is direction where sun is (relative to screen). return value is value of shade in that pixel. this code is bit raw now and need some tweaking.

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: Globe improvements
« Reply #51 on: December 15, 2011, 09:44:52 pm »
ok now I can say `I finished it` :D
soon I will update my git fork.

Volutar

  • Guest
Re: Globe improvements
« Reply #52 on: December 15, 2011, 10:02:18 pm »
I think you should keep classic Earth inclanation at 0 degrees.
And.. i cannot compile it with VS :)  nevermind.

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: Globe improvements
« Reply #53 on: December 15, 2011, 11:05:13 pm »
what error you get?

Offline kkmic

  • Commander
  • *****
  • Posts: 582
  • Undefined
    • View Profile
Re: Globe improvements
« Reply #54 on: December 16, 2011, 09:55:57 am »
It's technically impossible in 256 paletted color mode.

I don't know much about graphics, but can't it be faked? I mean, this is not a state of the art engine with countless shaders and post-processing effects, shadows and what else.

Since Yankes is already doing the calculation per-pixel, how much overhead would this type of faked shadow will add?

Volutar

  • Guest
Re: Globe improvements
« Reply #55 on: December 16, 2011, 10:23:04 am »
kkmic, no it can't be, until going 24bit mode.

So only those colors can be used in Geoscape mode:
« Last Edit: December 16, 2011, 10:24:52 am by Volutar »

Offline kkmic

  • Commander
  • *****
  • Posts: 582
  • Undefined
    • View Profile
Re: Globe improvements
« Reply #56 on: December 16, 2011, 01:26:23 pm »
What I see there is the full range of colors available, grouped into gradients (more or less)

As I understand it, each pixel has a "daylight color" and a "night color" (the start and end of a specific gradient) and a twilight pixels' color is calculated depending on the position in the twilight, and then, the appropriate color from the palette (in between those pixels) is used.

Did I get i right?

So, by using this algorithm, the original Xcom created those"bands" of shading, because only that set of colors were available.

Then... this sucks :)

Anyway, any plans on increasing the depth? After 1.0 I mean. I'm pretty sure that there will be quite a lot of people out there who would like to give Xcom a facelift. Higher resolution/redone graphics and maybe audio. That would require a 24/32 bit depth.

Volutar

  • Guest
Re: Globe improvements
« Reply #57 on: December 16, 2011, 01:41:20 pm »
Quote
Did I get i right?
Yeah. Textures of globe are simply paletted textures, and when they are shaded - each pixel just shifted forward to darker version (with clamping on "darkest").
Terrain textures use 16 intensity palette parts, while ocean have 32 intensity levels, so ocean looks smoother than land (in original XCOM).


Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: Globe improvements
« Reply #58 on: December 17, 2011, 12:06:41 am »
I get final version to git. additional I get correct shade for Battlescape. In couple of days I will try merge it with main version.

Volutar

  • Guest
Re: Globe improvements
« Reply #59 on: December 17, 2011, 11:15:42 am »
Your version doesn't compile in VS2003.. :( look into PM.