Author Topic: Battlescape development  (Read 290519 times)

Offline Daiky

  • Battlescape Programmer
  • Administrator
  • Commander
  • *****
  • Posts: 904
    • View Profile
Re: Battlescape development
« Reply #60 on: December 17, 2010, 10:24:09 pm »
Since the Items section is undergoing a major overhaul in release 0.3, I wanted to wait to implement items/weapons in battlescape as well.
So I have put some less exciting stuff on my todo list for the coming weeks:
- battlescape lighting (night missions yay!)
- fog of war (the excitement of not knowing what to expect at every step...)
(not necessarily in that order)

Offline Daiky

  • Battlescape Programmer
  • Administrator
  • Commander
  • *****
  • Posts: 904
    • View Profile
Re: Battlescape development
« Reply #61 on: December 19, 2010, 11:15:35 pm »
Not a very exciting feature that I implemented today, probably nobody ever notices it, but nevertheless: I call it "sun shading". This is the shade under the skyranger, inside buildings, inside ufo's,...

Offline Daiky

  • Battlescape Programmer
  • Administrator
  • Commander
  • *****
  • Posts: 904
    • View Profile
Re: Battlescape development
« Reply #62 on: December 21, 2010, 01:22:53 am »
Very first try at soldier personal light. Still needs lots of work.

Offline michal

  • Commander
  • *****
  • Posts: 629
    • View Profile
Re: Battlescape development
« Reply #63 on: December 21, 2010, 08:33:32 am »
You're fast :) Good work :) Looks great  ;D

Offline Daiky

  • Battlescape Programmer
  • Administrator
  • Commander
  • *****
  • Posts: 904
    • View Profile
Re: Battlescape development
« Reply #64 on: December 21, 2010, 12:35:17 pm »
Well, it depends what you call fast :) The lighting code up until now is maybe just 40 lines, but it took me about 10 hours to write. I have implemented these features before already in my own project, some concepts are carried over from there.
BUT.... and here it comes... in my project the minimum requirement was hardware acceleration (OpenGL or DirectX driven).
It is unplayable without hardware acceleration, because of how I handled the tile drawing. I pumped all sprites into the GPU as textured polygons. The GPU can render tiles this way very fast, including applying shaders to the textures while drawing them.

But in OpenXcom there is no HW acceleration. (...yet. But not let us start the discussion here :p)
I did a first try implementing it like I was used to. But no go: less than 5fps... I had to rethink the whole concept.

The issue was in the fact I had to create a temporary copy of the original sprite, this means creating/allocating a new Surface object and then applying the shading to every one of it pixels, and then blit it. This whole process takes up to 2 milliseconds, which is forever in the world of graphics rendering. That's only 500 sprites per second. Before shading I could blit about 100.000 sprites per second. And as a reference: old/slow GPUs could already shade and blit 10 million sprites per second. FYI the current battlescape viewport contains 400 sprites on average.

So I had to take out the shading process out of the drawing loop. This is from gameplay standpoint no issue, because the shading only changes every now and then. At the start of the battlescape I copy every tile to a "cache". If the shading of a tile changes, I update the cache with the correct shading of the tile. The shading update is done asap for tiles within the viewport and a little later for tiles outside the viewport. In the drawing loop I just blit the cached/pre-shaded tiles.

Offline Daiky

  • Battlescape Programmer
  • Administrator
  • Commander
  • *****
  • Posts: 904
    • View Profile
Re: Battlescape development
« Reply #65 on: December 22, 2010, 06:30:37 pm »
Interesting to see the Japanese gaming website seems to follow the progress, they even promoted the donation.
https://translate.google.be/translate?js=n&prev=_t&hl=nl&ie=UTF-8&layout=2&eotf=1&sl=ja&tl=en&u=http%3A%2F%2Fwww.game-damashi.com%2Fdatabase%2F%3Fp%3D7382&act=url

Offline Daiky

  • Battlescape Programmer
  • Administrator
  • Commander
  • *****
  • Posts: 904
    • View Profile
Re: Battlescape development
« Reply #66 on: December 25, 2010, 05:18:21 pm »
I made a little christmas present for the fans:
Wiiiii another videoooo :)
https://www.youtube.com/watch?v=t2ME1IhWFLk

Offline Daiky

  • Battlescape Programmer
  • Administrator
  • Commander
  • *****
  • Posts: 904
    • View Profile
Re: Battlescape development
« Reply #67 on: December 30, 2010, 02:44:13 pm »
You can play with lighting too now, if you update your SVN build. Or wait until v0.2.
SVN 227:
- Basic per-tile-lighting implemented. Lighting/shade is depending on the landing site.
- Basic fog-of-war implemented.
- Caching of tiles and units implemented. This was needed for faster shading, despite some increase of RAM usage.
- Added terror site map rules.

I'm going to party some, and then go on holiday, so it might be quiet for a few weeksdays.
« Last Edit: December 30, 2010, 10:38:11 pm by Daiky »

Offline michal

  • Commander
  • *****
  • Posts: 629
    • View Profile
Re: Battlescape development
« Reply #68 on: January 04, 2011, 08:56:17 am »
If you want to try latest battlescape stuff and can't compile openxcom by yourself, you can download svn builds for windows. More details here:

https://openxcom.ninex.info/forum/index.php?topic=140.0

Offline liamdawe

  • Sergeant
  • **
  • Posts: 27
    • View Profile
Re: Battlescape development
« Reply #69 on: January 08, 2011, 01:58:01 pm »
Loving the active development here, hope you had a good new year, seems we are getting close to a really playable release now :D

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: Battlescape development
« Reply #70 on: January 10, 2011, 02:15:07 am »
Daiky i think that is small bug in battlescape, in mission during night source of light under solder is too big. its made 4 squares bright not only one under solder.

Offline Daiky

  • Battlescape Programmer
  • Administrator
  • Commander
  • *****
  • Posts: 904
    • View Profile
Re: Battlescape development
« Reply #71 on: January 10, 2011, 02:56:59 pm »
Daiky i think that is small bug in battlescape, in mission during night source of light under solder is too big. its made 4 squares bright not only one under solder.
Hi Yankes,
I have seen this problem too, it's some kind of rounding error. Problem is the tile coordinates have a very low resolution (if you see every tile as a pixel with it's own brightness) and this easely causes this kind of rounding errors.

Offline Daiky

  • Battlescape Programmer
  • Administrator
  • Commander
  • *****
  • Posts: 904
    • View Profile
Re: Battlescape development
« Reply #72 on: January 18, 2011, 12:28:03 pm »
Just an update on what is happening on battlescape development these days.
- First of all the battlescape savegame is on it's way. Yaml-cpp hasn't yet all the base64 encoded binary reading/writing functions in place, so currently I will work with my own base64 encoding functions.

Why binary? Well, the map file will be huge otherwise, so I try to make it as compact as possible.
It is made up by 3 bytes per object, 1 byte for the datafile the object is in, 2 bytes for the index in the datafile.
A tile has 4 object on it, so 12 bytes per tile.
- Empty tiles are saved as a 0xFF byte followed by a two byte number indicating how many empties.
- Fog of war is stored as a bitmap with 0 or 1 when a tile is discovered(1) or not(0). This bitmap is also base64 encoded.
- Lighting level per tile is not stored but calculated.
- Smoke and fire is not yet implemented. But these will probably be stored as a list.

- Secondly, I discovered a spot in my design that really needed refactoring. I don't know what I was thinking when I initially did it this way.
Currently we have the following classes:

Resource/TerrainObject
Resource/TerrainObjectSet
Ruleset/MapDataFile

But a terrainobjectset and mapdatafile are actually the same thing (both refer to the .MCD file).
So I decided to merge them both into MapDataFile, and remove TerrainObjectSet.
And TerrainObject will be moved from the Resource map to the Ruleset map and renamed to MapData.
The set of MapData is then MapDataSet, following the syntax of Surface/SurfaceSet
So after refactoring we have:

Ruleset/MapDataSet
Ruleset/MapData

- Thirdly, lighting implemented like in the original game (light not blocked by objects). With the option to switch back to the solution I made.
« Last Edit: January 18, 2011, 08:35:03 pm by Daiky »

Offline Daiky

  • Battlescape Programmer
  • Administrator
  • Commander
  • *****
  • Posts: 904
    • View Profile
Re: Battlescape development
« Reply #73 on: January 22, 2011, 07:48:04 pm »
Daiky i think that is small bug in battlescape, in mission during night source of light under solder is too big. its made 4 squares bright not only one under solder.
It's fixed now.

Offline Daiky

  • Battlescape Programmer
  • Administrator
  • Commander
  • *****
  • Posts: 904
    • View Profile
Re: Battlescape development
« Reply #74 on: January 30, 2011, 04:51:02 pm »
This is how the night mission now looks at the start. The battlescape terrain is not completly blocking light, but also it isn't completly "transparent".