Code reformatting project [DONE]

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: Code reformatting project [DONE]

Post by chuck_starchaser »

Changed default.vp to,

Code: Select all

uniform int light_enabled[gl_MaxLights];
uniform int max_light_enabled;
uniform vec4 detail0Plane;
uniform vec4 detail1Plane;

//temporarily using the Sun's solid angle, as seen from Earth, for the solid
//angle of all light sources, until this parameter can be passed as a uniform
//for each light.
#define SUNS_SOLID_ANGLE (0.000263759)

/* varyings:
 *   gl_TexCoord[...]
 *    0 - tex coord
 *    1 - ws normal
 *    2 - ws tangent
 *    3 - ws binormal
 *    4 - vertex-to-eye direction
 *    5 - vertex-to-light0@xyz, light_size@z
 *    6 - vertex-to-light1@xyz, light_size@z
 *    7 - untransformed vertex position
 **/

//float selfshadowStep(float VNdotL) { return step(0.0,VNdotL); } // fast but hard selfshadow function
float selfshadowStep(float VNdotL) { return smoothstep(0.0,0.25,VNdotL); } // costly but soft and nice selfshadow function

vec4 lightPosAndSize0(in vec4 vertex)
{
  vec4 lpos = gl_LightSource[0].position;
  vec4 rv;
  rv.xyz    = lpos.xyz - vertex.xyz*lpos.w;
  rv.w      = SUNS_SOLID_ANGLE;
  return rv;
}
vec4 lightPosAndSize1(in vec4 vertex)
{
  vec4 lpos = gl_LightSource[1].position;
  vec4 rv;
  rv.xyz    = lpos.xyz - vertex.xyz*lpos.w;
  rv.w      = SUNS_SOLID_ANGLE;
  return rv;
}
vec4 lightPosAndSize2(in vec4 vertex)
{
  vec4 lpos = gl_LightSource[2].position;
  vec4 rv;
  rv.xyz    = normalize( lpos.xyz - vertex.xyz*lpos.w );
  rv.w      = 1.0;
  return rv;
}
vec4 lightPosAndSize3(in vec4 vertex)
{
  vec4 lpos = gl_LightSource[3].position;
  vec4 rv;
  rv.xyz    = normalize( lpos.xyz - vertex.xyz*lpos.w );
  rv.w      = 1.0;
  return rv;
}
vec4 lightPosAndSize4(in vec4 vertex)
{
  vec4 lpos = gl_LightSource[4].position;
  vec4 rv;
  rv.xyz    = normalize( lpos.xyz - vertex.xyz*lpos.w );
  rv.w      = 1.0;
  return rv;
}
vec4 lightPosAndSize5(in vec4 vertex)
{
  vec4 lpos = gl_LightSource[5].position;
  vec4 rv;
  rv.xyz    = normalize( lpos.xyz - vertex.xyz*lpos.w );
  rv.w      = 1.0;
  return rv;
}
vec4 lightPosAndSize6(in vec4 vertex)
{
  vec4 lpos = gl_LightSource[6].position;
  vec4 rv;
  rv.xyz    = normalize( lpos.xyz - vertex.xyz*lpos.w );
  rv.w      = 1.0;
  return rv;
}
vec4 lightPosAndSize7(in vec4 vertex)
{
  vec4 lpos = gl_LightSource[7].position;
  vec4 rv;
  rv.xyz    = normalize( lpos.xyz - vertex.xyz*lpos.w );
  rv.w      = 1.0;
  return rv;
}

void lighting2(in vec4 vertex, in vec3 refl, in vec3 normal, inout vec4 pc, inout vec4 sc)
{
  vec4  lpatt  = lightPosAndSize2(vertex);
  float NdotL = dot( lpatt.xyz, normal );
  float RdotL = dot( lpatt.xyz, refl );
  pc += lpatt.w*(  gl_FrontMaterial.ambient * gl_LightSource[2].ambient
                 + max(0.0, NdotL) * gl_LightSource[2].diffuse * gl_FrontMaterial.diffuse );
  sc += lpatt.w*(  pow( max(0.0, RdotL) , max(1.0,gl_FrontMaterial.shininess) ) * selfshadowStep(NdotL)
                 * gl_LightSource[2].specular * gl_FrontMaterial.specular );
}
void lighting3(in vec4 vertex, in vec3 refl, in vec3 normal, inout vec4 pc, inout vec4 sc)
{
  vec4  lpatt  = lightPosAndSize3(vertex);
  float NdotL = dot( lpatt.xyz, normal );
  float RdotL = dot( lpatt.xyz, refl );
  pc += lpatt.w*(  gl_FrontMaterial.ambient * gl_LightSource[3].ambient
                 + max(0.0, NdotL) * gl_LightSource[3].diffuse * gl_FrontMaterial.diffuse );
  sc += lpatt.w*(  pow( max(0.0, RdotL) , max(1.0,gl_FrontMaterial.shininess) ) * selfshadowStep(NdotL)
                 * gl_LightSource[3].specular * gl_FrontMaterial.specular );
}
void lighting4(in vec4 vertex, in vec3 refl, in vec3 normal, inout vec4 pc, inout vec4 sc)
{
  vec4  lpatt  = lightPosAndSize4(vertex);
  float NdotL = dot( lpatt.xyz, normal );
  float RdotL = dot( lpatt.xyz, refl );
  pc += lpatt.w*(  gl_FrontMaterial.ambient * gl_LightSource[4].ambient
                 + max(0.0, NdotL) * gl_LightSource[4].diffuse * gl_FrontMaterial.diffuse );
  sc += lpatt.w*(  pow( max(0.0, RdotL) , max(1.0,gl_FrontMaterial.shininess) ) * selfshadowStep(NdotL)
                 * gl_LightSource[4].specular * gl_FrontMaterial.specular );
}
void lighting5(in vec4 vertex, in vec3 refl, in vec3 normal, inout vec4 pc, inout vec4 sc)
{
  vec4  lpatt  = lightPosAndSize5(vertex);
  float NdotL = dot( lpatt.xyz, normal );
  float RdotL = dot( lpatt.xyz, refl );
  pc += lpatt.w*(  gl_FrontMaterial.ambient * gl_LightSource[5].ambient
                 + max(0.0, NdotL) * gl_LightSource[5].diffuse * gl_FrontMaterial.diffuse );
  sc += lpatt.w*(  pow( max(0.0, RdotL) , max(1.0,gl_FrontMaterial.shininess) ) * selfshadowStep(NdotL)
                 * gl_LightSource[5].specular * gl_FrontMaterial.specular );
}

void main() 
{
  // Compute position, eye-to-object direction and normalized world-space normal
  vec4 position = gl_ModelViewMatrix * gl_Vertex;
  vec3 eyetopos = normalize(position.xyz);
  vec3 normal   = normalize(gl_NormalMatrix * gl_Normal);
  vec3 tangent  = normalize(gl_NormalMatrix * gl_MultiTexCoord2.xyz);
  vec3 binormal = cross(tangent, normal) * sign(gl_MultiTexCoord2.w);
  // Load varyings
  gl_TexCoord[0] = gl_MultiTexCoord0;
  gl_TexCoord[1].xyz = normal;
  gl_TexCoord[2].xyz = tangent;
  gl_TexCoord[3].xyz = binormal;
  gl_TexCoord[4].xyz = -eyetopos;
  gl_TexCoord[5] = lightPosAndSize0(position);
  gl_TexCoord[6] = lightPosAndSize1(position);
  gl_TexCoord[1].w =
  gl_TexCoord[2].w =
  gl_TexCoord[3].w =
  gl_TexCoord[4].w = 0.0;
  gl_TexCoord[7] = position;
  // set primary color to the emissive material properties
  vec4 pc = gl_FrontMaterial.emission;
  vec4 sc = vec4(0.0);
  vec3 refl     = reflect( eyetopos, normal );
  if (max_light_enabled >= 2)
  {
    if (light_enabled[2] != 0) lighting2(position, refl, normal, pc, sc);
    if (light_enabled[3] != 0) lighting3(position, refl, normal, pc, sc);
    if (light_enabled[4] != 0) lighting4(position, refl, normal, pc, sc);
    if (light_enabled[5] != 0) lighting5(position, refl, normal, pc, sc);
  }
  // Need this instead of ftransform() for invariance
  gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
  gl_FrontColor = gl_BackColor = pc;
  gl_FrontSecondaryColor = gl_BackSecondaryColor = sc;
}
but the problem persists. (Note I added normalize() to lights 2 through 7.)
No difference whatsoever. Wonder if the problem is in default.vp at all...
safemode
Developer
Developer
Posts: 2150
Joined: Mon Apr 23, 2007 1:17 am
Location: Pennsylvania
Contact:

Re: Code reformatting project [DONE]

Post by safemode »

guys, we already have the option to use system boost libs. I put that in years ago.

We dont ship with any boost versions, they are external svn pulls. You can add new versions in there if you like, but 1.28 was kept for mac builds on older versions of their OS.

It's always been recommended you build using system boost libs. Only build using the included pulls if that fails for some reason. You can use the svn option to not even download external trees and save space if you dont use the included pulls of svn.

I also recommend using cmake for building vegastrike, it will use system boost libs automatically, and you build in a completely external directory so you dont pollute your source tree with generated files.

the automake/autoconf configure option for using system boost libs is --with-boost=system or something like that. ./configure --help will tell you.

edit: I use python2.5 and boost 1.40. (debian unstable's defaults)
Ed Sweetman endorses this message.
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Re: Code reformatting project [DONE]

Post by chuck_starchaser »

Thanks!
For some reason, with python version is not working, even though I copied it from the --help output.
Here's my config line:
./configure --enable-release --disable-debug --enable-cubemap --with-python-version=2.5 --with-boost=system
It tells me,
configure: WARNING: unrecognized options: --with-python-version
In Configure.ac I only see with_python_inc and with_python_libs; or would this be in some other file?
And then it doesn't build:

Code: Select all

In file included from src/networking/lowlevel/netui.h:25,
                 from src/networking/lowlevel/netui.cpp:5:
src/networking/lowlevel/vsnet_socket.h:22:32: error: boost/shared_ptr.hpp: No such file or directory
In file included from src/networking/lowlevel/vsnet_socket.h:27,
                 from src/networking/lowlevel/netui.h:25,
                 from src/networking/lowlevel/netui.cpp:5:
src/networking/lowlevel/vsnet_socketset.h:32:30: error: boost/weak_ptr.hpp: No such file or directory
In file included from src/networking/lowlevel/vsnet_socketset.h:39,
                 from src/networking/lowlevel/vsnet_socket.h:27,
                 from src/networking/lowlevel/netui.h:25,
                 from src/networking/lowlevel/netui.cpp:5:
src/networking/lowlevel/vsnet_debug.h:4:29: error: boost/version.hpp: No such file or directory
In file included from src/networking/lowlevel/vsnet_socket.h:28,
                 from src/networking/lowlevel/netui.h:25,
                 from src/networking/lowlevel/netui.cpp:5:
src/networking/lowlevel/packetmem.h:10:34: error: boost/shared_array.hpp: No such file or directory
In file included from src/networking/lowlevel/vsnet_socket.h:27,
                 from src/networking/lowlevel/netui.h:25,
                 from src/networking/lowlevel/netui.cpp:5:
src/networking/lowlevel/vsnet_socketset.h:77: error: ‘boost’ has not been declared
src/networking/lowlevel/vsnet_socketset.h:77: error: ISO C++ forbids declaration of ‘weak_ptr’ with no type
src/networking/lowlevel/vsnet_socketset.h:77: error: expected ‘;’ before ‘<’ token
src/networking/lowlevel/vsnet_socketset.h:78: error: ‘boost’ has not been declared
src/networking/lowlevel/vsnet_socketset.h:78: error: ISO C++ forbids declaration of ‘weak_ptr’ with no type
src/networking/lowlevel/vsnet_socketset.h:78: error: expected ‘;’ before ‘<’ token
src/networking/lowlevel/vsnet_socketset.h:83: error: ‘boost’ has not been declared
src/networking/lowlevel/vsnet_socketset.h:83: error: expected ‘,’ or ‘...’ before ‘<’ token
src/networking/lowlevel/vsnet_socketset.h:84: error: ‘boost’ has not been declared
src/networking/lowlevel/vsnet_socketset.h:84: error: expected ‘,’ or ‘...’ before ‘<’ token
src/networking/lowlevel/vsnet_socketset.h:84: error: ‘bool SocketSet::addDownloadManager(int)’ cannot be overloaded
src/networking/lowlevel/vsnet_socketset.h:83: error: with ‘bool SocketSet::addDownloadManager(int)’
In file included from src/networking/lowlevel/vsnet_socket.h:28,
                 from src/networking/lowlevel/netui.h:25,
                 from src/networking/lowlevel/netui.cpp:5:
src/networking/lowlevel/packetmem.h:25: error: ‘boost’ has not been declared
src/networking/lowlevel/packetmem.h:25: error: ISO C++ forbids declaration of ‘shared_array’ with no type
src/networking/lowlevel/packetmem.h:25: error: typedef name may not be a nested-name-specifier
src/networking/lowlevel/packetmem.h:25: error: expected ‘;’ before ‘<’ token
src/networking/lowlevel/packetmem.h:27: error: ‘ptr’ does not name a type
In file included from src/networking/lowlevel/netui.h:25,
                 from src/networking/lowlevel/netui.cpp:5:
src/networking/lowlevel/vsnet_socket.h:36: error: ‘boost’ has not been declared
src/networking/lowlevel/vsnet_socket.h:36: error: ISO C++ forbids declaration of ‘shared_ptr’ with no type
src/networking/lowlevel/vsnet_socket.h:36: error: typedef name may not be a nested-name-specifier
src/networking/lowlevel/vsnet_socket.h:36: error: expected ‘;’ before ‘<’ token
src/networking/lowlevel/vsnet_socket.h:38: error: ‘ptr’ does not name a type
make[1]: *** [src/networking/lowlevel/netui.o] Error 1
make[1]: Leaving directory `/home/d/vs/repo/trunk/vegastrike'
make: *** [all] Error 2
I need some environmental variable for it to find boost?
pheonixstorm
Elite
Elite
Posts: 1567
Joined: Tue Jan 26, 2010 2:03 am

Re: Code reformatting project [DONE]

Post by pheonixstorm »

You want a polluted source tree try the vega-vc8 one.. it has 3 python directories that are pretty much the same... And dont forget windows doesnt have a boost sytem dir so it has to use the external pulls
Because of YOU Arbiter, MY kids? can't get enough gas. OR NIPPLE! How does that mkae you feeeel? ~ Halo
safemode
Developer
Developer
Posts: 2150
Joined: Mon Apr 23, 2007 1:17 am
Location: Pennsylvania
Contact:

Re: Code reformatting project [DONE]

Post by safemode »

Well, i got no idea what autoconf is doing anymore. The python checking occurs in the m4 scripts found in the m4script dir.

as far as the source files go, that option should be recognized. perhaps something went wrong when you generated ./configure?

i just use cmake.

If ./configure exits correctly, your boost setup should point to system dirs instead of a local boost dir. And you wont build boost-python, as it already exists.
Ed Sweetman endorses this message.
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Re: Code reformatting project [DONE]

Post by chuck_starchaser »

safemode wrote:Well, i got no idea what autoconf is doing anymore. The python checking occurs in the m4 scripts found in the m4script dir.

as far as the source files go, that option should be recognized. perhaps something went wrong when you generated ./configure?

i just use cmake.

If ./configure exits correctly, your boost setup should point to system dirs instead of a local boost dir. And you wont build boost-python, as it already exists.
Added ticket #12.
http://vegastrike.wcjunction.com/trac/t ... ate=Update
safemode
Developer
Developer
Posts: 2150
Joined: Mon Apr 23, 2007 1:17 am
Location: Pennsylvania
Contact:

Re: Code reformatting project [DONE]

Post by safemode »

I'll get cmake up to date with all the latest stuff (cubemaps and additions/subtractions to sources). I'm currently merging in the trunk changes to my branch. Then i have to merge back my commit i last made to my branch but never merged to trunk ....then i should be ready to do some debugging .
Ed Sweetman endorses this message.
safemode
Developer
Developer
Posts: 2150
Joined: Mon Apr 23, 2007 1:17 am
Location: Pennsylvania
Contact:

Re: Code reformatting project [DONE]

Post by safemode »

Couple questions. Cubemaps should be mandatory now, correct? so if we dont detect it in gl_init, we should die? If so i'll add that in.
Ed Sweetman endorses this message.
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Re: Code reformatting project [DONE]

Post by chuck_starchaser »

Cool!

I'm trying to find the cause for the yellow ships and flashy planets.

Klauss, just for your reference, here's my current default.vp (I think it's PERFECT):

Code: Select all

uniform int light_enabled[gl_MaxLights];
uniform int max_light_enabled;
uniform vec4 detail0Plane;
uniform vec4 detail1Plane;

//temporarily using the Sun's solid angle, as seen from Earth, for the solid
//angle of all light sources, until this parameter can be passed as a uniform
//for each light.
#define SUNS_SOLID_ANGLE (0.000263759)

/* varyings:
 *   gl_TexCoord[...]
 *    0 - tex coord
 *    1 - ws normal
 *    2 - ws tangent
 *    3 - ws binormal
 *    4 - vertex-to-eye direction
 *    5 - vertex-to-light0@xyz, light_size@z
 *    6 - vertex-to-light1@xyz, light_size@z
 *    7 - untransformed vertex position
 **/

//float selfshadowStep(float VNdotL) { return step(0.0,VNdotL); } // fast but hard selfshadow function
float selfshadowStep(float VNdotL) { return smoothstep(0.0,0.25,VNdotL); } // costly but soft and nice selfshadow function

vec4 lightPosAndSize0(in vec4 vertex)
{
  vec4 lpos = gl_LightSource[0].position;
  vec4 rv;
  rv.xyz    = lpos.xyz - vertex.xyz*lpos.w;
  rv.w      = SUNS_SOLID_ANGLE;
  return rv;
}
vec4 lightPosAndSize1(in vec4 vertex)
{
  vec4 lpos = gl_LightSource[1].position;
  vec4 rv;
  rv.xyz    = lpos.xyz - vertex.xyz*lpos.w;
  rv.w      = SUNS_SOLID_ANGLE;
  return rv;
}
vec4 lightPosAndAttenuation2(in vec4 vertex)
{
  vec4 lpos = gl_LightSource[2].position;
  vec4 rv;
  rv.xyz    = lpos.xyz - vertex.xyz*lpos.w;
  float t   = length(rv.xyz);
  rv.xyz   *= (1.0/t);
  rv.w      = 1.0 / dot( vec3(1,t,t*t),
                         vec3(gl_LightSource[2].constantAttenuation,
                              gl_LightSource[2].linearAttenuation,
                              gl_LightSource[2].quadraticAttenuation) );
  return rv;
}
vec4 lightPosAndAttenuation3(in vec4 vertex)
{
  vec4 lpos = gl_LightSource[3].position;
  vec4 rv;
  rv.xyz    = lpos.xyz - vertex.xyz*lpos.w;
  float t   = length(rv.xyz);
  rv.xyz   *= (1.0/t);
  rv.w      = 1.0 / dot( vec3(1,t,t*t),
                         vec3(gl_LightSource[3].constantAttenuation,
                              gl_LightSource[3].linearAttenuation,
                              gl_LightSource[3].quadraticAttenuation) );
  return rv;
}
vec4 lightPosAndAttenuation4(in vec4 vertex)
{
  vec4 lpos = gl_LightSource[4].position;
  vec4 rv;
  rv.xyz    = lpos.xyz - vertex.xyz*lpos.w;
  float t   = length(rv.xyz);
  rv.xyz   *= (1.0/t);
  rv.w      = 1.0 / dot( vec3(1,t,t*t),
                         vec3(gl_LightSource[4].constantAttenuation,
                              gl_LightSource[4].linearAttenuation,
                              gl_LightSource[4].quadraticAttenuation) );
  return rv;
}
vec4 lightPosAndAttenuation5(in vec4 vertex)
{
  vec4 lpos = gl_LightSource[5].position;
  vec4 rv;
  rv.xyz    = lpos.xyz - vertex.xyz*lpos.w;
  float t   = length(rv.xyz);
  rv.xyz   *= (1.0/t);
  rv.w      = 1.0 / dot( vec3(1,t,t*t),
                         vec3(gl_LightSource[5].constantAttenuation,
                              gl_LightSource[5].linearAttenuation,
                              gl_LightSource[5].quadraticAttenuation) );
  return rv;
}
vec4 lightPosAndAttenuation6(in vec4 vertex)
{
  vec4 lpos = gl_LightSource[6].position;
  vec4 rv;
  rv.xyz    = lpos.xyz - vertex.xyz*lpos.w;
  float t   = length(rv.xyz);
  rv.xyz   *= (1.0/t);
  rv.w      = 1.0 / dot( vec3(1,t,t*t),
                         vec3(gl_LightSource[6].constantAttenuation,
                              gl_LightSource[6].linearAttenuation,
                              gl_LightSource[6].quadraticAttenuation) );
  return rv;
}
vec4 lightPosAndAttenuation7(in vec4 vertex)
{
  vec4 lpos = gl_LightSource[7].position;
  vec4 rv;
  rv.xyz    = lpos.xyz - vertex.xyz*lpos.w;
  float t   = length(rv.xyz);
  rv.xyz   *= (1.0/t);
  rv.w      = 1.0 / dot( vec3(1,t,t*t),
                         vec3(gl_LightSource[7].constantAttenuation,
                              gl_LightSource[7].linearAttenuation,
                              gl_LightSource[7].quadraticAttenuation) );
  return rv;
}

void lighting2(in vec4 vertex, in vec3 refl, in vec3 normal, inout vec4 pc, inout vec4 sc)
{
  vec4  lpatt  = lightPosAndAttenuation2(vertex);
  float NdotL = dot( lpatt.xyz, normal );
  float RdotL = dot( lpatt.xyz, refl );
  pc += lpatt.w*(  gl_FrontMaterial.ambient * gl_LightSource[2].ambient
                 + max(0.0, NdotL) * gl_LightSource[2].diffuse * gl_FrontMaterial.diffuse );
  sc += lpatt.w*(  pow( max(0.0, RdotL) , max(1.0,gl_FrontMaterial.shininess) ) * selfshadowStep(NdotL)
                 * gl_LightSource[2].specular * gl_FrontMaterial.specular );
}
void lighting3(in vec4 vertex, in vec3 refl, in vec3 normal, inout vec4 pc, inout vec4 sc)
{
  vec4  lpatt  = lightPosAndAttenuation3(vertex);
  float NdotL = dot( lpatt.xyz, normal );
  float RdotL = dot( lpatt.xyz, refl );
  pc += lpatt.w*(  gl_FrontMaterial.ambient * gl_LightSource[3].ambient
                 + max(0.0, NdotL) * gl_LightSource[3].diffuse * gl_FrontMaterial.diffuse );
  sc += lpatt.w*(  pow( max(0.0, RdotL) , max(1.0,gl_FrontMaterial.shininess) ) * selfshadowStep(NdotL)
                 * gl_LightSource[3].specular * gl_FrontMaterial.specular );
}
void lighting4(in vec4 vertex, in vec3 refl, in vec3 normal, inout vec4 pc, inout vec4 sc)
{
  vec4  lpatt  = lightPosAndAttenuation4(vertex);
  float NdotL = dot( lpatt.xyz, normal );
  float RdotL = dot( lpatt.xyz, refl );
  pc += lpatt.w*(  gl_FrontMaterial.ambient * gl_LightSource[4].ambient
                 + max(0.0, NdotL) * gl_LightSource[4].diffuse * gl_FrontMaterial.diffuse );
  sc += lpatt.w*(  pow( max(0.0, RdotL) , max(1.0,gl_FrontMaterial.shininess) ) * selfshadowStep(NdotL)
                 * gl_LightSource[4].specular * gl_FrontMaterial.specular );
}
void lighting5(in vec4 vertex, in vec3 refl, in vec3 normal, inout vec4 pc, inout vec4 sc)
{
  vec4  lpatt  = lightPosAndAttenuation5(vertex);
  float NdotL = dot( lpatt.xyz, normal );
  float RdotL = dot( lpatt.xyz, refl );
  pc += lpatt.w*(  gl_FrontMaterial.ambient * gl_LightSource[5].ambient
                 + max(0.0, NdotL) * gl_LightSource[5].diffuse * gl_FrontMaterial.diffuse );
  sc += lpatt.w*(  pow( max(0.0, RdotL) , max(1.0,gl_FrontMaterial.shininess) ) * selfshadowStep(NdotL)
                 * gl_LightSource[5].specular * gl_FrontMaterial.specular );
}

void main() 
{
  // Compute position, eye-to-object direction and normalized world-space normal
  vec4 position = gl_ModelViewMatrix * gl_Vertex;
  vec3 eyetopos = normalize(position.xyz);
  vec3 normal   = normalize(gl_NormalMatrix * gl_Normal);
  vec3 tangent  = normalize(gl_NormalMatrix * gl_MultiTexCoord2.xyz);
  vec3 binormal = cross(tangent, normal) * sign(gl_MultiTexCoord2.w);
  // Load varyings
  gl_TexCoord[0] = gl_MultiTexCoord0;
  gl_TexCoord[1].xyz = normal;
  gl_TexCoord[2].xyz = tangent;
  gl_TexCoord[3].xyz = binormal;
  gl_TexCoord[4].xyz = -eyetopos;
  gl_TexCoord[5] = lightPosAndSize0(position);
  gl_TexCoord[6] = lightPosAndSize1(position);
  gl_TexCoord[1].w =
  gl_TexCoord[2].w =
  gl_TexCoord[3].w =
  gl_TexCoord[4].w = 0.0;
  gl_TexCoord[7] = position;
  // set primary color to the emissive material properties
  vec4 pc = gl_FrontMaterial.emission;
  vec4 sc = vec4(0.0);
  vec3 refl     = reflect( eyetopos, normal );
  if (max_light_enabled >= 2)
  {
    if (light_enabled[2] != 0) lighting2(position, refl, normal, pc, sc);
    if (light_enabled[3] != 0) lighting3(position, refl, normal, pc, sc);
    if (light_enabled[4] != 0) lighting4(position, refl, normal, pc, sc);
    if (light_enabled[5] != 0) lighting5(position, refl, normal, pc, sc);
  }
  // Need this instead of ftransform() for invariance
  gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
  gl_FrontColor = gl_BackColor = pc;
  gl_FrontSecondaryColor = gl_BackSecondaryColor = sc;
}
But the yellow oxes and throbbing planets persist.

I have a new theory:
I think the problem has something to do with something you mentioned passingly in an email
a while ago, namely that there were different default shaders. I think you mentioned that
in the case of a single texture mesh that doesn't specify a shader, ends up with something
xxx_simple.technique, right? There's only two: highend_simple- and fixed_simple.technique,
which call for fixed8.vp and fixed5.vp, for their vertex shaders.
Now, these vertex shaders do some weird things I don't understand, but it would seem to me
they are computing reflection vectors, or some kind of environment mapping vectors, on
behalf of the pixel shaders?

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);
}

void main() 
{
  // Compute position, eye-to-object direction and normalized world-space normal
  vec4 position = gl_ModelViewMatrix * gl_Vertex;
  vec3 eyetopos = normalize(position.xyz);
  vec3 normal   = normalize(gl_NormalMatrix * gl_Normal);

  // Load varyings
  gl_TexCoord[0] = gl_MultiTexCoord0;
  gl_TexCoord[1].xy = EnvMapGen(reflect(eyetopos, normal));
  gl_TexCoord[1].zw = EnvMapGen(normal);
  gl_TexCoord[2].xyz = normal;

.....................................
... which formula looks to me like a spheremapping formula.

Oxes and planets may just happen to have only one texture...
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Re: Code reformatting project [DONE]

Post by chuck_starchaser »

Safemode, here's the diff for Makefile.am from before the reformat branch until present:
http://vegastrike.wcjunction.com/trac/c ... akefile.am
It was a lot less changes than I thought, and I'm sure it's going to help update the CMake files.
Set it to show 77 lines around changes, and then it becomes real easy to see where the changes
are.
One change I did in configure.ac was to change the optimization default from -O2 to -O3, for
release; it makes a HUGE difference to game speed.
pheonixstorm
Elite
Elite
Posts: 1567
Joined: Tue Jan 26, 2010 2:03 am

Re: Code reformatting project [DONE]

Post by pheonixstorm »

has it affected game stability at all? almost sounds too good to be true.
Because of YOU Arbiter, MY kids? can't get enough gas. OR NIPPLE! How does that mkae you feeeel? ~ Halo
safemode
Developer
Developer
Posts: 2150
Joined: Mon Apr 23, 2007 1:17 am
Location: Pennsylvania
Contact:

Re: Code reformatting project [DONE]

Post by safemode »

-O3 vs -O2 is going to be machine dependent as far as if it makes things faster, or if it causes bugs or just straight crashes.

-O2 is fairly safe as far as not introducing bugs due to compiler optimizations, but -O3 is not. Using -O3 by default means we have to ask people to recompile with -O2 and see if the bugs appear again as the compiler may have optimized a block of code in a way that's not intended due to the code being questionable to begin with.

On one hand, it would identify what probably is buggy code, on the other, it introduces another lengthy step towards debugging in the case of users and such. (who are usually not thrilled about recompiling the entire source just to see if the bug appears again).

I'm not really opposed to making it the default, but i would not expect it to be without collateral issues on other machines. pros and cons.
Ed Sweetman endorses this message.
pheonixstorm
Elite
Elite
Posts: 1567
Joined: Tue Jan 26, 2010 2:03 am

Re: Code reformatting project [DONE]

Post by pheonixstorm »

yeah, I had fun while using gentoo stage 1 builds doing the "lets see what this does" with the compiler flags. -O3 -funroll-loops etc. most times it worked out fine.. but soemtimes I had the fastest apps around when they would run... Tinker and learn.
Because of YOU Arbiter, MY kids? can't get enough gas. OR NIPPLE! How does that mkae you feeeel? ~ Halo
safemode
Developer
Developer
Posts: 2150
Joined: Mon Apr 23, 2007 1:17 am
Location: Pennsylvania
Contact:

Re: Code reformatting project [DONE]

Post by safemode »

Ok, I'm really really not happy about VEGASERVER_COMPILING.

for one, it breaks _generic in that _generic needs to be target agnostic. This define makes that not the case. Has to be changed.

two, it's in source files that _only_ get built in vegastrike's target, so it's unecessary. Should be changed.

In any case, it angers me :) gonna fix this asap

edit: wow, this is worse than i thought. this define makes _every_ include of unit.h require building twice (one for vegaserver and one for vegastrike). this completely breaks any sort of shared object / intermediate library we have setup that includes unit.h. This will result in more compiling time, larger build trees and it weakens the structure we have setup for having a server version of any files that need to be stripped down or modified from the regular version for vegaserver.

Either we have a _server file or we dont. this define is not a good fix...
Ed Sweetman endorses this message.
klauss
Elite
Elite
Posts: 7243
Joined: Mon Apr 18, 2005 2:40 pm
Location: LS87, Buenos Aires, República Argentina

Re: Code reformatting project [DONE]

Post by klauss »

@chuck: re. shader, yep, I was going to say, it's most likely not default.vp, although it may be the same bug in all the lower shaders. Highend_simple is a very good candidate.

re. O3, I don't think it's unsafe for VS. The only really unsafe optimization I know is that O3 puts gcc in "optimistic" mode regarding pointer aliasing, and I don't remember many places where pointer aliasing occurs in VS, not at least in a breaking way.

The optimization O3 does that probably makes the biggest difference for speed is function inlining. O2 has relatively conservative inlining, where O3 does aggressive inlining. Inlining's benefit is architecture-dependant, but it's always safe, so I'd try with O2 but aggressive inlining instead. That could be the default in non-debug builds.
Oíd mortales, el grito sagrado...
Call me "Menes, lord of Cats"
Wing Commander Universe
safemode
Developer
Developer
Posts: 2150
Joined: Mon Apr 23, 2007 1:17 am
Location: Pennsylvania
Contact:

Re: Code reformatting project [DONE]

Post by safemode »

where is VEGASERVER_COMPILING defined? is it some autoconf auto-generated define ? I dont see it defined anywhere
Ed Sweetman endorses this message.
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Re: Code reformatting project [DONE]

Post by chuck_starchaser »

safemode wrote:where is VEGASERVER_COMPILING defined? is it some autoconf auto-generated define ? I dont see it defined anywhere
It's gone; I just forgot to take out the #ifdef blocks.
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Re: Code reformatting project [DONE]

Post by chuck_starchaser »

klauss wrote:@chuck: re. shader, yep, I was going to say, it's most likely not default.vp, although it may be the same bug in all the lower shaders. Highend_simple is a very good candidate.
Yeah, they both are; but it's the vp' s that are calculating the enviro fetch, instead of the fp's; I guess we need to remove that spheremap thing and pass a vec3 to the fp; but it's passing two fetches of a coord packed in a vec4; not enough room for two vec3's. Was this due to extremely limited interpolants?
re. O3, I don't think it's unsafe for VS. The only really unsafe optimization I know is that O3 puts gcc in "optimistic" mode regarding pointer aliasing, and I don't remember many places where pointer aliasing occurs in VS, not at least in a breaking way.

The optimization O3 does that probably makes the biggest difference for speed is function inlining. O2 has relatively conservative inlining, where O3 does aggressive inlining. Inlining's benefit is architecture-dependant, but it's always safe, so I'd try with O2 but aggressive inlining instead. That could be the default in non-debug builds.
I really, REALLY, didn't mean to leave this at -O3 permanently, though. In fact, my idea is the exact opposite: Compile with -Os by default; and use pragmas to optimize performance critical functions, one at a time. THAT will give us the best performance, by far; much higher than compiling the whole thing with -O3, --as using -O3 inflates the code, reducing cache coherence, almost defeating its advantage.
95% of the code with -Os; 5% with -O3 via pragmas; the way to go.
But for that I will need to know which functions are critical, for which I'll use AMD's Code Analyzer.
So, I just meant this -O3 thing temporarily; to save me having to type "=3" each time I run configure :D
safemode
Developer
Developer
Posts: 2150
Joined: Mon Apr 23, 2007 1:17 am
Location: Pennsylvania
Contact:

Re: Code reformatting project [DONE]

Post by safemode »

ok, i'm about 3 seconds from flipping shit on sourceforge.net's servers. It's been over 2 hours for this merge and it's dribbling through and in the meantime trunk is being updated with conflicting changes i already made in my branch :) I hate you SF
Ed Sweetman endorses this message.
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Re: Code reformatting project [DONE]

Post by chuck_starchaser »

VEGASERVER_COMPILING clingons wiped. r12654

By the way, we could remove the no aliasing optimization, specifically.
ok, i'm about 3 seconds from flipping shit on sourceforge.net's servers. It's been over 2 hours for this merge and it's dribbling through and in the meantime trunk is being updated with conflicting changes i already made in my branch :) I hate you SF
Sorry, I thought you'd be sleeping by now :D

EDIT:
You might want to keep my changes where in doubt; it compiles and runs.
safemode
Developer
Developer
Posts: 2150
Joined: Mon Apr 23, 2007 1:17 am
Location: Pennsylvania
Contact:

Re: Code reformatting project [DONE]

Post by safemode »

The only main issue you're gonna notice with my merge is that the include to unit.cpp is back and the independent compilation of unit.cpp is gone. All i got was linker errors doing it the way you had it. It can always be brought back to not being included easily, (one liners in the build file and in unit.h) but unless you were building on a source tree that wasn't what trunk was prior to my merge, i dont see how it was getting built at all without erroring out like a mad-man when you built unit.cpp.

all i would get was duplicate definitions ...perhaps that was due to the vegaserver_compiling defines, I'll have to do more testing on that later
Ed Sweetman endorses this message.
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Re: Code reformatting project [DONE]

Post by chuck_starchaser »

safemode wrote:The only main issue you're gonna notice with my merge is that the include to unit.cpp is back and the independent compilation of unit.cpp is gone. All i got was linker errors doing it the way you had it. It can always be brought back to not being included easily, (one liners in the build file and in unit.h) but unless you were building on a source tree that wasn't what trunk was prior to my merge, i dont see how it was getting built at all without erroring out like a mad-man when you built unit.cpp.

all i would get was duplicate definitions ...perhaps that was due to the vegaserver_compiling defines, I'll have to do more testing on that later
This is not cool; I worked very hard at tracking down and elliminating linker errors.
Well over a week of work; you should ask before wiping someone else's achievements.
The problem has to be in your update to CMake files.
Did you look at the diff I posted for you? There's a number of files that had to be
removed from the common lists to ONLY vegastrike or ONLY vegaserver.
This is VERY not cool.
safemode
Developer
Developer
Posts: 2150
Joined: Mon Apr 23, 2007 1:17 am
Location: Pennsylvania
Contact:

Re: Code reformatting project [DONE]

Post by safemode »

it had nothing to do with the cmake list. that was already done. It had something to do with the actual compiling of unit.cpp. it would always result in duplicate definitions.

The work wasn't eliminated. it's a one/two line change in two files to put it back the way you had it. just add unit.cpp back to the build file and comment out unit.cpp in the unit.h file. But when i did this (back before the vegaserver_compiles stuff was totally removed) it resulted in nothing but errors.


edit: to clarify about the cmake list, i put all the files in the appropriate sublists . Rather than just bunch them all into the final vegastrike or vegaserver list i put them in the correct vegastrike / vegaserver sublist. I only did this after first attempting it exactly the way the Makefile.am has it listed. either way made no difference.

I'm building again now after all the various intermediate changes have been merged in and will see what's going on with unit.cpp so that it can be put back the way you had it.
Ed Sweetman endorses this message.
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Re: Code reformatting project [DONE]

Post by chuck_starchaser »

Thanks; and sorry I had a sudden emotional storm.
Yes, I was just checking your diff on CMakeLists.txt and I could not find a mistake.
I'm curious what kind of redefinitions you're getting.
Seems to me impossible; unit_server.cpp has almost nothing in it; everything is commented out.
Could it be that somehow unit.cpp is slipping into the server build?
Or that unit_server.cpp is slipping into the vegastrike build?
Could you share more details about the conflicts you're getting?
safemode
Developer
Developer
Posts: 2150
Joined: Mon Apr 23, 2007 1:17 am
Location: Pennsylvania
Contact:

Re: Code reformatting project [DONE]

Post by safemode »

And we're back.

I dont make it a point to reverse changes if i dont have to ...and especially not without discussing it. I've been up all night mostly due to sf.net's extreme difficulty in merging my branch after merging trunk into it (something about updating almost 800 files makes their server unhappy). Because of that, i chose to push the commit rather than delay it and basically start all over. But i made sure not to throw everything away going on in trunk. Only the absolute minimum altered to get things to work again.

My mistake was not trying to do what i just did after i removed the vegaserver_compiling flags in the first place. Instead, i did both at the same time.

Anyways, all should be good now.

ps:

The conflicts i was getting seemed to be at first due to unit.h including unit.cpp and unit.cpp including unit.h (back when the vegaserver define was in there) ....this of course was during vegastrike compiling. Then i made some changes to the defines and it become undefined instances... Apparently at some point in my debugging, i commented out the forward declarations in unit.cpp at the bottom , probably when i was trying to stomp out the multiple declarations. I probably tried that first, then fixed the multiple include of unit.cpp but never uncommented the forward declares.

anyway, it was basically due to a mixmatch of fixes where none were in sync. Resulting in me just reversing the situation of unit.cpp back to what it was before you made your changes....which resulted in everything working fine.

Now that everything else was fixed though, i could return it to the way you had it and everything is working fine as well.
Ed Sweetman endorses this message.
Post Reply