Reviving Vega Strike

Development directions, tasks, and features being actively implemented or pursued by the development team.
Post Reply
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Re: Reviving Vega Strike

Post by chuck_starchaser »

JsnMtth wrote:Ok, I've read through it again and I only don't understand 5% :). It sounds like all we need to do is read the DDS file, then shove it into the graphics cards memory. It looks like that function does just that. Am I on course?

Also, How would I be able to see if it's working or not?
Well, I guess you'd need a cubemap. I converted all Vegastrike backgrounds to DDS cubemaps a long time ago.
http://wcjunction.com/temp_images/backg ... ube_dds.7z
They have the same names as the current backgrounds, except for the extension.
I didn't sleep last night and my brain is on and off like morse code, so if I write non-sense you know why.
Assuming DDS cubemap suppor IS in, working, I think you'll need to specify a system's background by the
name of the ddscm and be sure the file is there. The file name would be specified in the .system file; and you'd put
the file, I presume, wherever the current cube-map texture is.
If you do that, and everything is working, probably the shader will put garbage on the sky; because the shader
needs to know it's dealing with a cubemap, and not a spheremap.
But seeing garbage in the sky would be a great way to verify that something indeed changed.
If nothing happens, you might have to delete the corresponding auto-generated spheremap from the
/home/you/.vegastrike/textures folder.
The way the engine currently works is that there are plain cubemaps in the backgroiunds folder, but the
engine reads those cubemaps, converts them to spherical projection, and writes spheremaps to the
textures cache. If it sees the spheremap in the textures cache, it might not even notice there's a new
file in the backgrounds folder. Not sure.
Once you see garbage in the sky, then you can change the shader to work with a cubemap.
The shaders are in the /programs folder.
If you use the high shader, open highend.fp, and the third function is

Code: Select all

vec2 EnvMapGen(vec3 f) {
   float fzp1=f.z+1.0;
   float m=2.0*sqrt(f.x*f.x+f.y*f.y+(fzp1)*(fzp1));
   return vec2(f.x/m+.5,f.y/m+.5);
}
Which you could comment out with /* */, or put in an #ifndef CUBETEST ... #endif
GLSL is very similar to C.

At the top of the file, the fourth line says

Code: Select all

uniform sampler2D envMap;
It would have to say,

Code: Select all

uniform samplerCube envMap;
Near the bottom of the file there's the function,

Code: Select all

vec3 envMapping(in vec3 reflection, in float gloss, in vec3 spec_col)
{
   float envLod = shininess2Lod(gloss);//shininessMap(shininess,spec_col));
   return texture2DLod(envMap, EnvMapGen(reflection), envLod).rgb * spec_col * vec3(2.0);
}
which now should read, I believe,

Code: Select all

vec3 envMapping(in vec3 reflection, in float gloss, in vec3 spec_col)
{
   float envLod = shininess2Lod(gloss);
   return textureCubeLod(envMap, reflection, envLod) * spec_col;
}
I think that's about it.
Now, I don't know whether we need a special .technique file. If we do, we're in trouble; but I don't
think we do.

If your computer blows up and the videocard throws thick smoke, check the errors log file in /bin;
it will say when it's compiling the shader, and if something goes wrong, at a minimum it gives you
a line number.
But be sure the sky changed for the worse before trying the shader changes.
By the way, there's a hotkey for reloading the shader; you don't have to reboot vegastrike each
time; but I don't remember what the hotkey is.
I'm going to bed now, for sure. Thanks a lot for the help.

EDIT:
If EVERYTHING works, you might notice an improvement on the specular reflection on ships.
I'll have to then work on the shader to optimize it, and on models, to provide a shininess
channel in the specual texture's alpha channel.
But don't commit those cubemaps to the data repo; I have to re-generate them with better
parameters.
JsnMtth
Bounty Hunter
Bounty Hunter
Posts: 174
Joined: Wed May 27, 2009 6:38 am
Location: Fresno, California - United States of America
Contact:

Re: Reviving Vega Strike

Post by JsnMtth »

No broken Sky :(

Code: Select all

<system name="Cephid_17" background="backgrounds/green" nearstars="500" stars="1000" starspread="150" scalesystem="1000">
I put the .dds files in data/textures/backgrounds
I deleted all the files in the .vegastrike/textures/backgrounds
It regenerated:

Code: Select all

[jason@jsnmtth backgrounds]$ ls -1
black_light.image
green_light.image
I'll poke around and find the file decision routines.
JsnMtth
Bounty Hunter
Bounty Hunter
Posts: 174
Joined: Wed May 27, 2009 6:38 am
Location: Fresno, California - United States of America
Contact:

Re: Reviving Vega Strike

Post by JsnMtth »

Take a look at the file: src/star_system.cpp
Lines: 528-563
Function: void GameStarSystem::createBackground( StarSystem::StarXML * xml)

Note of particular interest line 552.
The function called there "EnvironmentMapGeneratorMain" is in env_map_gent.cpp line 437
This is the part that isn't done. It calls GenerateSphereMap on line 477. It doesn't contain
any code regarding the DDS cubemaps. I'm stuck. I need to know more about creating
environment maps in general before moving forward. Unless you know what needs to be done
here to go from spheremaps to cubemaps?
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Re: Reviving Vega Strike

Post by chuck_starchaser »

Yeah; that was my best guess, but I guess it wasn't good enough.

Ehm... I'm thinking... Maybe the engine needs to see a particular extension.
First of all, did you delete the six green_<xxx>.image files? Because if they are
still there the engine might not look for anything else.
Second, the DDS cubemap might need to be renamed to green.image or more
probably green.texture.
The new naming convention in the engine is .image for images without mip-maps,
and .texture for images with mip-maps; and the dds cubemaps do have mips.
I'm just guessing, needless to say.
JsnMtth
Bounty Hunter
Bounty Hunter
Posts: 174
Joined: Wed May 27, 2009 6:38 am
Location: Fresno, California - United States of America
Contact:

Re: Reviving Vega Strike

Post by JsnMtth »

I did rename green.dds to green.image. I did not delete the other images. I will try that. However, I'm quite convinced that the DDS loading that is there, isn't integrated into creating the environment map. Basicaly the SphereMap Functions need to be replaced with the CubeMap functions. It didn't look like they used a common API, but rather go about things quite differently. In order to do the integration I need to understand the separate systems AND how they need to interact with the engine. I don't have good knowledge of how the engine works, I have to study it more. Nor do I have knowledge about HOW to implement an environment map. I do have books about it (that I haven't read), and I have examples in the engine.

I'll work on HOW the engine implements env_maps, THEN how to implement DDS cubemaps. That should be enough to finish the integration. (It might take some time, I'm not on vacation yet and am working three projects other than this one)
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Re: Reviving Vega Strike

Post by chuck_starchaser »

JsnMtth wrote:I did rename green.dds to green.image. I did not delete the other images. I will try that. However, I'm quite convinced that the DDS loading that is there, isn't integrated into creating the environment map.
There should be NO creation of any environment map, with dds cubemaps in place, though.
In the current way of doing things, the 6 images in the main textures folder are used for painting the sky; but they are not used for environment mapping (i.e. specular reflections of the sky on objects). For environment mapping, the engine uses the spheremaps it generates into.vegastrike/textures. But DDS cubemaps are dual purpose: For background painting AND environment mapping, so the engine shouldn't need to generate spheremaps from them. If it did, I'm curious what they look like; but my guess is it generated them from the six old pictures.
Basicaly the SphereMap Functions need to be replaced with the CubeMap functions. It didn't look like they used a common API, but rather go about things quite differently. In order to do the integration I need to understand the separate systems AND how they need to interact with the engine. I don't have good knowledge of how the engine works, I have to study it more. Nor do I have knowledge about HOW to implement an environment map. I do have books about it (that I haven't read), and I have examples in the engine.
You're probably right.
The way the engine works is, if it doesn't find a spheremap for a given background, it generates it and stores it in the .vegastrike... folder.
During rendering, whenever you enter a system (by loading a savegame, or jumping through a jump point), the needed spheremap for that system is loaded and sent to the videocard, replacing the old.
JsnMtth
Bounty Hunter
Bounty Hunter
Posts: 174
Joined: Wed May 27, 2009 6:38 am
Location: Fresno, California - United States of America
Contact:

Re: Reviving Vega Strike

Post by JsnMtth »

chuck_starchaser wrote: In the current way of doing things, the 6 images in the main textures folder are used for painting the sky;
The 6 images are in the main textures folder? Not in textures/backgrounds?
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Re: Reviving Vega Strike

Post by chuck_starchaser »

Sorry, I meant the main textures/backgrounds folder, as opposed to the /home/<self>/.vegastrike/textures/backgrounds.
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Re: Reviving Vega Strike

Post by chuck_starchaser »

Got an email from Klauss, finally. He says he's pretty sure he committed all the changes needed for dds cubemaps; but
that there's a compile switch needed: --enable-cubemap.
By email, Klauss wrote:MY version of it (perhaps someone commited something else) required a slight change to the techniques for non-environment cubemaps - environment maps would automatically become cubemaps (so you'd have to update the shaders) if VS was built with --enable-cubemap (or something like that).
I didn't understand the techniques bit, myself; and sent him an email asking for clarification.
safemode
Developer
Developer
Posts: 2150
Joined: Mon Apr 23, 2007 1:17 am
Location: Pennsylvania
Contact:

Re: Reviving Vega Strike

Post by safemode »

I'm hoping to have at least some time during this coming week to get back in my physics code and get the ray collider work done. I have off from my first job from christmas till jan 4th but not the second. I really hate not having that aspect finished so that all the old collider code is banished.
Ed Sweetman endorses this message.
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Re: Reviving Vega Strike

Post by chuck_starchaser »

Hey, Safemode; welcome back! :D

Email update:
I wrote:You lost me with the technique bit, tho... Do I need to do something with them or not?
Klauss wrote:Not, only if you have something else as a cubemap, like a unit texture (who knows - a BRDF?) or a shared lookup table. Some of my shaders use them, so I added the option (wasn't really hard) - but normally you wouldn't have to do anything but change the shaders, because environment textures are automatically loaded as cube maps.
I wrote: So, what should I name the DDS cubemaps? Where there's green_up.image, green_down.image, etceteras, would I delete
those and throw in a green.image?, green.texture?, green.dds?
Klauss wrote:I don't really remember the specifics, but it was the same naming as normal background images, except there wasn't an up/down/left/right/whatever suffix to them. I'll have to confirm the specifics though.
charlieg
Elite Mercenary
Elite Mercenary
Posts: 1329
Joined: Thu Mar 27, 2003 11:51 pm
Location: Manchester, UK
Contact:

Re: Reviving Vega Strike

Post by charlieg »

Another reason to work on getting out a new 0.5.1 release...

Actually, chuck, what are the ramifications of this? What textures need changing? Just the backgrounds?
Free Gamer - free software games compendium and commentary!
FreeGameDev forum - open source game development community
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Re: Reviving Vega Strike

Post by chuck_starchaser »

Exactly. Just the backgrounds. And I already did them all, long time ago; though I want to do them again, because recently I calculated the exact settings I need for CubeMapGen. Pages and pages of math. So, as a matter of fact, I'm checking out masters repo, right now, in case it contains higher quality versions of what's in-game ((converting from HQ originals should produce better quality cubemaps)).

But yeah, just the backgrounds; and minor changes in the shaders I can do in 5 minutes.
JsnMtth
Bounty Hunter
Bounty Hunter
Posts: 174
Joined: Wed May 27, 2009 6:38 am
Location: Fresno, California - United States of America
Contact:

Re: Reviving Vega Strike

Post by JsnMtth »

@Chuck
I'll try re-compiling with cube map support :)

@safemode
safemode wrote:I really hate not having that aspect finished so that all the old collider code is banished.
I hate it when that happens. Seems like it happens to me at work 3-4 times a year.
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Re: Reviving Vega Strike

Post by chuck_starchaser »

Use this cubemap for testing; it's the brightest (not blue at all); and I just created it
with the new settings:
blue.dds
JsnMtth
Bounty Hunter
Bounty Hunter
Posts: 174
Joined: Wed May 27, 2009 6:38 am
Location: Fresno, California - United States of America
Contact:

Re: Reviving Vega Strike

Post by JsnMtth »

Nobody put an --enable-cubemap in the configure script(needs to be added to configure.ac), but I did find NV_CUBE_MAP Preprocessor Conditionals in Klaus's last commit, I added a -D switch to my CXXFLAGS variable in my Makefile and am compiling. Wish me luck.
JsnMtth
Bounty Hunter
Bounty Hunter
Posts: 174
Joined: Wed May 27, 2009 6:38 am
Location: Fresno, California - United States of America
Contact:

Re: Reviving Vega Strike

Post by JsnMtth »

Attached is my terminal output and an in-game screenshot of what I saw after compiling. I'm not really sure what I'm looking for though.
You do not have the required permissions to view the files attached to this post.
JsnMtth
Bounty Hunter
Bounty Hunter
Posts: 174
Joined: Wed May 27, 2009 6:38 am
Location: Fresno, California - United States of America
Contact:

Re: Reviving Vega Strike

Post by JsnMtth »

It doesn't look like my flags made it into the compile... well at least I have a baseline (and know that DDS cubemaps are supported by my video card)
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Re: Reviving Vega Strike

Post by chuck_starchaser »

Great! Glad to see you're making progress.
I can't tell from that image if it's the dds cubemap working. Whatever it is, it's working, tho.
If you removed the original .image files and the generated spheremap, then it has to be
the dds cubemap; and if so it's working just fine.
I just finished converting all VS cubemaps to dds cubemaps, from the originals in the
masters repository. Here they are:
http://wcjunction.com/temp_images/cinem ... dds.tar.gz
Two days of non-stop work; but worth it; they look good.
Besides the format conversion I tried to standardize them in terms of brightness
and contrast. Some were just too dark; some lacked contrast; some had too much
contrast. And some of them had apparently been scaled up and had pixelation
artifacts, and in those cases I used a bit extra filtering.
Somebody with commit access to the data repo should commit them
to /textures/backgrounds. Not sure what they should be named, in terms of
extension, though.

EDIT:
Wrote a small tutorial about converting backgrounds to DDS cubemaps here:
http://wcjunction.com/phpBB2/viewtopic. ... 2329#22329
If someone could copy it to the wiki please go ahead; I can't edit the VS wiki
pages anymore; long story.
JsnMtth
Bounty Hunter
Bounty Hunter
Posts: 174
Joined: Wed May 27, 2009 6:38 am
Location: Fresno, California - United States of America
Contact:

Re: Reviving Vega Strike

Post by JsnMtth »

They weren't the cubemaps in the screenshot. I didn't put my changes in the right place in the Makefile :(. I downloaded your file, and I also know what I need to do to get a DDS enabled compile. I'll delete ALL the backgrounds from my working copy, then it will HAVE to load them :)
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Re: Reviving Vega Strike

Post by chuck_starchaser »

You also need to edit the high shader like I told you; otherwise it will be expecting a spheremap. Not sure what will happen if you don't. Probably the code will switch to the next shader down, and then again, and then revert to the fixed opengl pipe; and that will probably fail also.
JsnMtth
Bounty Hunter
Bounty Hunter
Posts: 174
Joined: Wed May 27, 2009 6:38 am
Location: Fresno, California - United States of America
Contact:

Re: Reviving Vega Strike

Post by JsnMtth »

from vegastrike/src/star_system.cpp line 528

Code: Select all

void    GameStarSystem::createBackground( StarSystem::StarXML * xml)
{
#ifdef NV_CUBE_MAP
	printf("using NV_CUBE_MAP\n");
	LightMap[0]=new Texture ((xml->backgroundname+"_light.cube").c_str(),1,BILINEAR,CUBEMAP,CUBEMAP_POSITIVE_X);
	if (lightMap[0]->LoadSuccess() && LightMap[0]->isCube()) {
	    LightMap[1] = LightMap[2] = LightMap[3] =
	    LightMap[4] = LightMap[5] = 0;
    } else {
        delete LightMap[0];
        LightMap[0]=new Texture ((xml->backgroundname+"_right_light.image").c_str(),1,BILINEAR,CUBEMAP,CUBEMAP_POSITIVE_X);
        LightMap[1]=new Texture ((xml->backgroundname+"_left_light.image").c_str(),1,BILINEAR,CUBEMAP,CUBEMAP_NEGATIVE_X);
        LightMap[2]=new Texture ((xml->backgroundname+"_up_light.image").c_str(),1,BILINEAR,CUBEMAP,CUBEMAP_POSITIVE_Y);
        LightMap[3]=new Texture ((xml->backgroundname+"_down_light.image").c_str(),1,BILINEAR,CUBEMAP,CUBEMAP_NEGATIVE_Y);
        LightMap[4]=new Texture ((xml->backgroundname+"_front_light.image").c_str(),1,BILINEAR,CUBEMAP,CUBEMAP_POSITIVE_Z);
        LightMap[5]=new Texture ((xml->backgroundname+"_back_light.image").c_str(),1,BILINEAR,CUBEMAP,CUBEMAP_NEGATIVE_Z);
    }
#else
	//string bglight= VSFileSystem::sharedtextures+"/"+xml->backgroundname+"_light.image";
	string bglight= xml->backgroundname+"_light.image";
	string bgfile = xml->backgroundname+"_light.image";
	VSFile f;
	VSError err = f.OpenReadOnly(bgfile,TextureFile);
	if (err>Ok) {
		EnvironmentMapGeneratorMain (xml->backgroundname.c_str(),bglight.c_str(), 0,xml->reflectivity,1);
	}
	else {
		f.Close();
	}
	LightMap[0] = new Texture(bgfile.c_str(), 1,MIPMAP,TEXTURE2D,TEXTURE_2D,GFXTRUE);
#endif

	bg = new Background(xml->backgroundname.c_str(),xml->numstars,g_game.zfar*.9,filename);
	stars = new Stars (xml->numnearstars, xml->starsp);
	stars->SetBlend (game_options.starblend, game_options.starblend);
}
Compile Errors:

Code: Select all

-*- mode: compilation; default-directory: "~/vegastrike/vegastrike.git/vegastrike/" -*-
Compilation started at Thu Dec 24 10:42:32

make -k 
make  all-am
make[1]: Entering directory `/home/jason/vegastrike/vegastrike.git/vegastrike'
depbase=`echo src/star_system.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
	g++ -DHAVE_CONFIG_H -I.   -DBOOST_PYTHON_NO_PY_SIGNATURES -DBOOST_PYTHON_STATIC_LIB -I./boost/1_35    -DHAVE_SDL=1 -DSDL_WINDOWING=1      -DHAVE_AL=1   -DHAVE_OGG   -I/usr/include/python2.6 -DHAVE_PYTHON=1    -I./src   -pipe -O0 -g -DNV_CUBE_MAP  -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -pthread -MT src/star_system.o -MD -MP -MF $depbase.Tpo -c -o src/star_system.o src/star_system.cpp &&\
	mv -f $depbase.Tpo $depbase.Po
In file included from /usr/include/python2.6/pyconfig.h:6,
                 from /usr/include/python2.6/Python.h:8,
                 from ./src/python/python_class.h:11,
                 from src/cmd/unit.cpp:48,
                 from src/cmd/unit.h:272,
                 from src/cmd/planet.h:10,
                 from src/star_system.cpp:3:
/usr/include/python2.6/pyconfig-64.h:1031:1: warning: "_XOPEN_SOURCE" redefined
In file included from /usr/include/assert.h:37,
                 from src/star_system.cpp:1:
/usr/include/features.h:160:1: warning: this is the location of the previous definition
src/star_system.cpp: In member function ‘virtual void GameStarSystem::createBackground(StarSystem::StarXML*)’:
src/star_system.cpp:533: error: ‘lightMap’ was not declared in this scope
make[1]: *** [src/star_system.o] Error 1
make[1]: Target `all-am' not remade because of errors.
make[1]: Leaving directory `/home/jason/vegastrike/vegastrike.git/vegastrike'
make: *** [all] Error 2

Compilation exited abnormally with code 2 at Thu Dec 24 10:42:39
Looks like the code enabled by NV_CUBE_MAP loads the old files (if it compiled with what is missing). Any ideas?
You do not have the required permissions to view the files attached to this post.
JsnMtth
Bounty Hunter
Bounty Hunter
Posts: 174
Joined: Wed May 27, 2009 6:38 am
Location: Fresno, California - United States of America
Contact:

Re: Reviving Vega Strike

Post by JsnMtth »

Found the compile error
lightMap was a typo, it should have been LightMap
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Re: Reviving Vega Strike

Post by chuck_starchaser »

I haven't the foggiest idea, myself; don't know what an NV_CUBE_MAP is, or why that's
defined...
JsnMtth wrote:Found the compile error
lightMap was a typo, it should have been LightMap
Hurray!
Post Reply