Well, I guess you'd need a cubemap. I converted all Vegastrike backgrounds to DDS cubemaps a long time ago.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?
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);
}
GLSL is very similar to C.
At the top of the file, the fourth line says
Code: Select all
uniform sampler2D envMap;
Code: Select all
uniform samplerCube envMap;
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);
}
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;
}
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.