UFO: Alien Invasion Issue Tracker
UFO: Alien Invasion
Go to the previous open issue
Go to the previous issue (open or closed)
star_faded.png
Please log in to bookmark issues
icon_project.png UFO: Alien Invasion / Closed Submit Patch #4633 more geoscape rendering stuff
Go to the next issue (open or closed)
Go to the next open issue
This issue has been closed with status "Closed" and resolution "Not determined".
Issue basics
  • Type of issue
    Submit Patch
  • Category
    General
  • Targetted for
    Not determined
  • Status
    Closed
  • Priority
    3. Normal
User pain
  • Type of bug
    Not triaged
  • Likelihood
    Not triaged
  • Effect
    Not triaged
Affected by this issue (0)
There are no items
People involved
Times and dates
  • Posted at
  • Last updated
Issue details
Attachments (0)
There is nothing attached to this issue
Duplicate issues (0)
This issue does not have any duplicates
Description
[http://sourceforge.net/p/ufoai/patches/506 Item 506] imported from sourceforge.net tracker on 2013-01-28 20:43:43

- Moved gloss and city light maps into the alpha channels of the bump map and the season textures, respectively, and re-wrote the shader rendering code to take advantage of this (fewer images loaded into memory, and fewer texture samplers in the shader).

- The sphere generation code now generates tangents as well as normals for each vertex. The tangents are being used in the geoscape shader code; bump-mapping should look better now.

- Reduced contrast of specularity map, and decreased the specular exponent; water is less shiny.

- Added a glowing border to the nation overlay.

- Changed rendering of the sun to be done as a textured sphere (rather than a billboard) in preparation for adding glow-effect post-processing.
===== Comments Ported from Sourceforge =====

====== arisian (2010-03-27 14:29:29) ======

patch
====== arisian (2010-03-27 14:31:43) ======

Ack, can't attach the textures 'cause they're too big. I'll post them over in the forum I guess...
====== tlh2000 (2010-03-28 08:09:58) ======

applied coding guidelines
====== tlh2000 (2010-03-28 08:14:47) ======

use R_BindArray(GL_TANGENT_ARRAY, GL_FLOAT, sphere->tangents);
====== tlh2000 (2010-03-28 08:18:08) ======

changed R_RotateCelestialBody a little bit - vec4_t is already a pointer
====== tlh2000 (2010-03-28 08:20:02) ======

R_LoadShader: geoscape_vs.glsl: 0(45) : error C1115: unable to find compatible overloaded function "cross(vec3, error)"
0(45) : error C1115: unable to find compatible overloaded function "normalize(error)"

R_LoadShader: geoscape_fs.glsl: 0(50) : error C1115: unable to find compatible overloaded function "normalize(error)"
0(51) : warning C7011: implicit cast from "vec4" to "vec3"
0(64) : warning C7011: implicit cast from "vec4" to "vec3"
0(64) : error C1115: unable to find compatible overloaded function "clamp(float)"
0(64) : error C0000: syntax error, unexpected floating point constant at token "<undefined>"
0(64) : error C0501: type name expected at token "<undefined>"


line numbers are +9
====== tlh2000 (2010-03-28 08:23:37) ======

sorry - had a typo in my shaders - forget the last comment
====== tlh2000 (2010-03-28 08:24:13) ======

fixed TANGENT variable name
====== arisian (2010-03-28 23:51:13) ======

I did some more work on the shaders, particularly getting the specular stuff to be both efficient and correct (at least, I think it&#039;s as correct as it&#039;s able to be given that we&#039;re using an orthographic view). I&#039;ve attached a new patch (against current svn trunk); this patch should replace the previous one. The same textures should work, though. I&#039;ve got some slightly improved versions of a couple of the textures here, but the code should work with the ones I posted yesterday.
====== arisian (2010-03-28 23:51:49) ======

updated patch; use this version rather than the previous one
====== tlh2000 (2010-03-29 05:38:53) ======

for the records - the textures are here: http://cs.jhu.edu/~ben/graphics/ufoai/
====== tlh2000 (2010-03-29 05:42:04) ======

screenshot of the patch - used lowres_textures.zip
====== tlh2000 (2010-03-29 05:42:18) ======

attached is a screenshot of how it looks for me
====== arisian (2010-03-29 12:54:19) ======

Hmm, that&#039;s odd; I&#039;ve just attached a screenshot of how it looks for me. I still think it&#039;s most likely to be an issue with the textures rather than the shaders, but I suppose there&#039;s no way of knowing. Go over to the website and grab new copies of the following files (the last three links on the page):

map_earth_bump.png
map_earth_season_00.png
map_earth_nations_overlay_glow.png

Then be sure you&#039;re using season00 for *all* the seasons (on linux, do "for i in `seq -w 1 11`; do ln -s map_earth_season_00.png map_earth_season_$i.png; done"). Or I guess you could edit r_draw.c to be sure that only season_00 was getting loaded.

Let me know if that fixes the "white" problem or not.
====== tlh2000 (2010-03-29 16:10:28) ======

it works with the high res textures
====== arisian (2010-03-30 02:36:11) ======

It looks like the issue is the JPEG format; it doesn&#039;t support "transparency," which translates to meaning you can only store 3 channels. The new-and-improved version saves space (on disk and in memory) by using the 4th channel (the "alpha" channel) to store the night-time and gloss maps, since they&#039;re grayscale anyway, and therefore only need one channel. OpenGL stores everything as RGBA as far as I can tell anyway, so it&#039;s really a lot more efficient at runtime to use that extra channel for something rather than load an entire other texture. But it doesn&#039;t look like the JPEG format is compatible with this scheme; we&#039;ll either need to go back to having several extra (large) textures in memory, or use a different image format. My preference would be for the latter. I&#039;m a big fan of .PNG as a format because it&#039;s lossless, but that same fact means it won&#039;t compress as far. I&#039;m not sure how small we need the images, though; at 4096x2048, the map_earth_season_XX.png files are about 6Mb each; check out the "medium" resolution texture zipfile on the website, which contains all the season images at 4096x2048 as .pngs.
====== tlh2000 (2010-03-30 05:49:16) ======

using png with compression for the standard files that we will add to the svn is fine, too
====== arisian (2010-03-30 15:14:02) ======

I can make versions of the files matching pretty much whatever specs you give me; what kind of resolution are we looking for, and what file size? The actual file size is mostly important for the purposes of downloading UFOAI; the resolution is really all that&#039;s important in terms of runtime resource requirements, since everything gets loaded into memory as opengl texture images regardless of what the file format or compression level is.

For my personal use, I really think that the 8192x4096 images make a big difference when you zoom all the way in; they&#039;re still crisp, and don&#039;t look blurry at max-zoom the way the lower resolutions do. However, they take a lot of memory to store; I suspect that you&#039;ll need 2Gb of RAM to be able to actually use them. The old geoscape image, map_earth_day.jpg is a 4096x2084 image, which works fine, but given that we&#039;re now loading several extra textures (two "season" textures and one "bump" texture, as opposed to the old version which only had map_earth_day), I don&#039;t know if that&#039;s going to be too high a resolution or not. We can go lower, but visual quality will suffer.

After we&#039;ve picked a resolution, I can play with different compression settings to trade off quality against file size, but I&#039;m unsure what sort of file size I should be trying to achieve.
====== tlh2000 (2010-03-30 15:34:02) ======

Width: 4096 pixels
Height: 2048 pixels

for the standard resolution - but we still can offer a different pk3 with higher resolution geoscape textures - the problem is that the load times are much higher if we use 8192x4096 for each texture.
====== tlh2000 (2010-03-30 15:35:09) ======

as of the file size - 3-4 mb would be really cool (if that&#039;s doable with png)
====== arisian (2010-03-30 16:02:39) ======

Okay, I&#039;ll see what I can do. I can get them down to ~6.4Mb losslessly, but I should be able to reduce the quality a bit and get them down to 3-4Mb.
====== tlh2000 (2010-03-30 19:02:43) ======

/offtopic on

#!/bin/bash

SUM=0; for i in $(find . -name "*.tga" -print); do FS=$(ls -l $i | tr -s " " | cut -d " " -f 5); SUM=$(($SUM + $FS)); done; echo "Total size of TGA: $SUM"
SUM=0; for i in $(find . -name "*.png" -print); do FS=$(ls -l $i | tr -s " " | cut -d " " -f 5); SUM=$(($SUM + $FS)); done; echo "Total size of already existing PNGs: $SUM"

for i in $(find . -name "*.tga" -print); do j=${i%.tga}.png; svn move $i $j; cp $j $i; convert $i $j; rm $i; done

SUM=0; for i in $(find . -name "*.png" -print); do FS=$(ls -l $i | tr -s " " | cut -d " " -f 5); SUM=$(($SUM + $FS)); done; echo "Total size of PNGs: $SUM"


i&#039;ve played around with converting all TGAs to PNGs to reduce the size of the svn and the installer - we can reduce the size by more than 100MB if we convert to PNG, but i&#039;m not sure whether the imagemagick call will do that in the best quality or if some gimp batch script should do the job.

/offtopic off
====== nobody (2010-03-30 19:17:48) ======

/offtopic on

imagemagick &#039;convert&#039; actually seems to do a pretty good job of optimizing PNGs without any special options. If you really want to squeeze them as small as possible, you can use programs like &#039;optipng&#039; and &#039;advpng&#039;, eg:


#!/bin/bash

# create backup copy
cp $1 $1.orig

# shrink the PNG using three tools:

#convert to colormap based-image if there are few enough colors
pngrewrite $1 $1

#find optimal set of filters to use
#do maximal search for best results possible (takes a long time):
#optipng -zc1-9 -zm1-9 -zs0-2 -f0-5 $1
#do slightly less exhaustive search, usually does just as well:
optipng -o7 $1

#find optimal compression
advpng -z4 $1

# display file sizes of the original and compressed image
ls -sla $1*



Using this technique on the 4096x2048 images only reduced their size from the 6.3Mb that &#039;convert&#039; produced to 6.2Mb, but for other types of images it may do better. In terms of "quality" you really don&#039;t need to worry; PNGs are a lossless format by design. I have yet to find any tool that will reduce their quality in an automated way. TGAs are also lossless, I believe, but have a much less flexible compression scheme than PNGs.

/offtopic off
====== nobody (2010-03-30 19:48:52) ======

Another format option is TIFF; that format allows lossy compression but can handle transparency. Converting from PNG to TIFF reduces one of the season images from 6.2Mb to 3.6Mb.

At the moment, however, the UFOAI codebased doesn&#039;t seem to have support for TIFF files. If you wanted to include it, the libTIFF library (http://www.remotesensing.org/libtiff/) should work. It&#039;s not GPL, but it is free (as in both speech and beer); you can use, distribute, modify, whatever as long as you include the original copyright (http://www.remotesensing.org/libtiff/misc.html).
====== arisian (2010-04-08 21:43:21) ======

latest version of the geoscape; much improved
====== arisian (2010-04-08 21:43:22) ======

Added a new patch; this version is both more feature rich and should be more flexible with respect to different system configurations. In addition to the patch, a number of other files are required; they can be obtained from:

http://cs.jhu.edu/~ben/graphics/ufoai/
====== arisian (2010-04-10 00:36:11) ======

New patch; this version now handles different resolutions properly, including changing resolutions on-the-fly. Specularity has also been temporarily disabled in geoscape_fs.glsl until I fix it properly (I&#039;m hoping Fresnel&#039;s equations might help, but that&#039;s a separate project).

Be sure to re-download the "common.tar.bz2" file, as one of the textures has changed (don&#039;t worry, it&#039;s small).
====== arisian (2010-04-10 00:36:51) ======

even newer version; minor fixes and improvements
====== tlh2000 (2010-04-10 06:54:28) ======

applied to trunk now - thanks a lot for the work

i&#039;ve performed minor modifications to the patch posted here.
====== tlh2000 (2010-04-10 06:54:40) ======

oh - it was commited in r29282
Todos (0 / 0)
Issue created
footer_logo.png The Bug Genie 4.3.1 | Support | Feedback spinning_16.gif