Posted: Fri Jan 09, 2009 8:32 pm
Anyway it looks VERY cool
For information and discussion about Oolite.
https://bb.oolite.space/
Code: Select all
"griff_station_roof_billboard" =
{
ai_type = "nullAI.plist";
model = "griff_station_roof_billboard.dat";
roles = "griff_station_subent";
shaders =
{
"griff_no_shader_drinking_spaceman.png" =
{
vertex_shader = "griff_station_animated.vertex";
fragment_shader = "griff_station_animated_billboard.fragment";
textures = ("griff_drinking_spaceman.png");
uniforms =
{
FrameCount = { type = "float"; value = 5.0; };
TimePerFrame = { type = "float"; value = 1.0; };
uTime = "timeElapsedSinceSpawn";
};
};
};
};
As I mentioned before, sort of, in my obtuse way, any frame count will work, but for non-power-of-two frame counts the height of each frame will be a non-integer which will result in misalignment effects if you have sharp vertical edges. (A one-pixel gaussian blur, where by “one pixel” I mean one pixel at the final texture resolution, will make this barely noticeable. Of course, the cost is that you get a blurry texture.)Griff wrote:how on earth did i manage to do a 5 frame animation and fit it into a power of 2 scale image? i think when i was working it out i just assumed that as each frame was 256 x 256 pixels i could just stack as many as i wanted on top of each other and the final image size would be a power of 2, what a twit. happily it seemed to work out in this case although each image works out at 204.8 poixels tall! :?
Code: Select all
Config Folder:
The following changes have been made to the original shipdata.plist
Line 205: smooth = "false"; key added, change to smooth = "true"; if you prefer
Line 240 now reads: fragment_shader = "griff_station_bottom_section.fragment";
Line 241 now reads: textures = ("griff_station_bottom.png", "griff_station_paint_mask.png");
Lines 242-248. New Uniforms to pass information to the new shader added.
Line 246 MainhullColour - Floating Point R G B colour values to re-colour original texture map
Line 247 DecalColour - Floating Point R G B colour values to re-colour the 'stripe'
painted roughly halfway down the cylindrical top section of the station
Line 257: smooth = "false"; key added, change to smooth = "true"; if you prefer
Line 263 now reads: fragment_shader = "griff_station_top_section.fragment";
Line 241 now reads: textures = ("griff_station_top.png", "griff_station_paint_mask.png");
Lines 265-271. New Uniforms to pass information to the new shader added.
Line 269 MainhullColour - Floating Point R G B colour values to re-colour original texture map
Line 270 DecalColour - Floating Point R G B colour values to re-colour the 'stripe'
painted along the top of the 'arms' sticking out of the bottom part of the station.
Line 358: smooth = "true"; key added, change to smooth = "false"; if you prefer
Models Folder
-No Changes-
Shaders Folder
griff_station_adring.fragment - Updated with new code
griff_station_adring.vertex - Updated with new code
griff_station_animated_billboard.fragment - Updated with new code
griff_station_animated_w_rollbars.fragment - Updated with new code
griff_station_animated_w_rollbars.vertex - Updated with new code
griff_station_bottom_section.fragment - New Shader
griff_station_hull.fragment - Updated with new code
griff_station_top_section.fragment - New Shader
Textures Folder:
griff_station_paint_mask.png - New texture map, used by the relevant shaders to limit the recolouring of the station hull to certain areas of the model
griff_station_top.png & griff_station_bottom.png - original textures modified slightly to work with the new shaders (lights are now painted into the RGB channel and 'illuminated using the Alpha channel rather than being in a seperate texture map)
Code: Select all
[shader.compile.fragment.failure]: ***** GLSL fragment shader compilation failed for griff_station_bottom_section.fragment:
>>>>> GLSL log:
0(26) : error C0105: Syntax error in #define
>>>>> GLSL source code:
#define OO_USER_DEFINED_BINDINGS 1
#define OO_REDUCED_COMPLEXITY 1
#define OO_TEXTURE_UNIT_COUNT 4
// Texture Information from Oolite.
uniform sampler2D tex0; // Difuse and Illumination map
uniform sampler2D tex1; // Mask map
// Uniforms from Oolite
uniform float uTime; //Time from game clock
uniform float hull_heat_level;
uniform vec4 MainhullColor; // used with paintmask map to tint diffuse texture
uniform vec4 DecalColor; // used with paintmask map to tint decal strip in the diffuse texture
// Information from vertex shader.
varying vec3 v_normal; // Surface normal
varying vec3 v_pos; // Vertex/fragment position in eye space
// Constants
const float specExponent = 2.0;
// Irregular flickering function
#ifdef OO_REDUCED_COMPLEXITY
#define Pulse(v, ts) ((v) * 0.95)
#define Blink_on_off(1.0)
#else
float Pulse(float value, float timeScale)
{
float t = uTime * timeScale;
float s0 = t;
s0 -= floor(s0);
float sum = abs( s0 - 0.5);
float s1 = t * 0.7 - 0.05;
s1 -= floor(s1);
sum += abs(s1 - 0.5) - 0.25;
float s2 = t * 1.3 - 0.3;
s2 -= floor(s2);
sum += abs(s2 - 0.5) - 0.25;
float s3 = t * 5.09 - 0.6;
s3 -= floor(s3);
sum += abs(s3 - 0.5) - 0.25;
return (sum * 0.1 + 0.9) * value;
}
// Hull Temperate heat glow
vec4 TemperatureGlow(float level)
{
vec4 result = vec4(0);
result.r = level;
result.g = level * level * level;
result.b = max(level - 0.7, 0.0) * 2.0;
result.a = 1.0;
return result;
}
#endif
// Calculate the contribution of a single light. Ought to be a function, but OS X's GLSlang implementation isn't sufficiently clever.
#define LIGHT(idx) \
{ \
Code: Select all
// Texture Information from Oolite.
uniform sampler2D tex0; // Difuse and Illumination map
uniform sampler2D tex1; // Mask map
// Uniforms from Oolite
uniform float uTime; // Time from game clock
uniform float hull_heat_level;
uniform vec4 MainhullColor;
uniform vec4 DecalColor;
// Information from vertex shader.
varying vec3 v_normal; // Surface normal
varying vec3 v_pos; // Vertex/fragment position in eye space
// Constants
const float specExponent = 2.0;
// Irregular flickering function
#ifdef OO_REDUCED_COMPLEXITY
#define Pulse(v, ts) ((v) * 0.95)
#else
float Pulse(float value, float timeScale)
{
float t = uTime * timeScale;
float s0 = t;
s0 -= floor(s0);
float sum = abs( s0 - 0.5);
float s1 = t * 0.7 - 0.05;
s1 -= floor(s1);
sum += abs(s1 - 0.5) - 0.25;
float s2 = t * 1.3 - 0.3;
s2 -= floor(s2);
sum += abs(s2 - 0.5) - 0.25;
float s3 = t * 5.09 - 0.6;
s3 -= floor(s3);
sum += abs(s3 - 0.5) - 0.25;
return (sum * 0.1 + 0.9) * value;
}
// Hull Temperate heat glow
vec4 TemperatureGlow(float level)
{
vec4 result = vec4(0);
result.r = level;
result.g = level * level * level;
result.b = max(level - 0.7, 0.0) * 2.0;
result.a = 1.0;
return result;
}
#endif
// Calculate the contribution of a single light. Ought to be a function, but OS X's GLSlang implementation isn't sufficiently clever.
#define LIGHT(idx) \
{ \
vec3 lightVector = normalize(gl_LightSource[idx].position.xyz); \
vec3 reflection = normalize(-reflect(lightVector, v_normal)); \
diffuse += gl_FrontMaterial.diffuse * gl_LightSource[idx].diffuse * max(dot(v_normal, lightVector), 0.0); \
specular += gl_LightSource[idx].diffuse * pow(max(dot(reflection, eyeVector), 0.0), specExponent); \
}
void main(void)
{
vec4 diffuse = vec4(0.0), specular = vec4(0.0);
vec3 eyeVector = normalize(-v_pos);
// Load texture data
vec2 texCoord = gl_TexCoord[0].st;
vec4 diffuseMap = texture2D(tex0, texCoord);
vec4 maskMap = texture2D(tex1, texCoord);
// calculate specular effects
float specIntensity = (diffuseMap.r + diffuseMap.g + diffuseMap.b);
/* Light 0 is the "showroom" light, used in the demo screen and shipyard.
Light 1 is the sun.
*/
#ifdef OO_LIGHT_0_FIX
LIGHT(0);
#endif
LIGHT(1);
diffuse += gl_FrontMaterial.ambient * gl_LightModel.ambient;
// Calculate the lighting
vec4 color = diffuse * diffuseMap;
#ifdef OO_REDUCED_COMPLEXITY
// Add in the specular effects for simple shader mode
color += specular * color * 3.0 * specIntensity;
#endif
#ifndef OO_REDUCED_COMPLEXITY
// recolour the diffuse map
color += diffuse * maskMap.b * MainhullColor;
color += maskMap.a * DecalColor * diffuse;
// save the modified colour for use in colouring the illumination effect
vec4 colourTemp = color;
// Add in the specular effects for full shader mode
color += specular * color * 3.0 * specIntensity;
// Add in the illumination effects. Full Shader mode only
color += diffuseMap.a * 4.0 * colourTemp;
// Add the all over hull temperature glow
float hullHeat = max(hull_heat_level - 0.5, 0.0) * 2.0;
hullHeat = Pulse(hullHeat * hullHeat, 0.1);
color += TemperatureGlow(hullHeat);
#endif
// Output final color
gl_FragColor = vec4(color.rgb, 1.0);
}
Code: Select all
[shader.compile.fragment.failure]: ***** GLSL fragment shader compilation failed for griff_station_bottom_section.fragment:
>>>>> GLSL log:
0(68) : error C0000: syntax error, unexpected '{' at token "{"
0(68) : error C0501: type name expected at token "{"
0(69) : error C0000: syntax error, unexpected $undefined at token "<undefined>"
0(69) : error C0501: type name expected at token "<undefined>"
0(70) : error C1038: declaration of "vec3" conflicts with previous declaration at 0(69)
0(70) : error C1115: unable to find compatible overloaded function "reflect(error, vec3)"
0(70) : error C1115: unable to find compatible overloaded function "normalize(error)"
0(70) : error C0000: syntax error, unexpected $undefined at token "<undefined>"
0(70) : error C0501: type name expected at token "<undefined>"
0(71) : error C1038: declaration of "diffuse" conflicts with previous declaration at 0(71)
0(71) : error C1307: non constant expression for array size
0(71) : error C0000: syntax error, unexpected '.', expecting ',' or ';' at token "."
0(71) : error C0501: type name expected at token "."
0(71) : error C1038: declaration of "diffuse" conflicts with previous declaration at 0(71)
0(71) : error C0000: syntax error, unexpected '(' at token "("
0(71) : error C0501: type name expected at token "("
0(71) : warning C7022: unrecognized profile specifier "dot"
0(71) : error C0000: syntax error, unexpected ')' at token ")"
0(71) : error C0501: type name expected at token ")"
0(71) : warning C7022: unrecognized profile specifier "lightVector"
0(72) : error C1307: non constant expression for array size
0(72) : error C0000: syntax error, unexpected '.', expecting ',' or ')' at token "."
0(72) : error C0501: type name expected at token "."
0(72) : error C1121: pow: function type parameters not allowed
0(72) : error C0000: syntax error, unexpected '(' at token "("
0(72) : error C0501: type name expected at token "("
0(72) : warning C7022: unrecognized profile specifier "max"
0(72) : error C1121: dot: function type parameters not allowed
0(72) : error C0000: syntax error, unexpected ',' at token ","
0(72) : error C0501: type name expected at token ","
0(72) : warning C7022: unrecognized profile specifier "reflection"
0(72) : error C1109: function type not allowed for parameter "dot"
0(72) : error C0000: syntax error, unexpected floating point constant at token "<undefined>"
0(72) : error C0501: type name expected at token "<undefined>"
0(72) : error C1109: function type not allowed for parameter "pow"
0(75) : error C1109: function type not allowed for parameter "main"
0(76) : error C0000: syntax error, unexpected '{', expecting ',' or ')' at token "{"
0(76) : error C0501: type name expected at token "{"
0(77) : error C0000: syntax error, unexpected '=' at token "="
0(77) : error C0501: type name expected at token "="
0(77) : warning C7022: unrecognized profile specifier "specular"
0(77) : error C1109: function type not allowed for parameter "vec4"
0(78) : error C0000: syntax error, unexpected ';', expecting ',' or ')' at token ";"
0(78) : error C0501: type name expected at token ";"
0(81) : error C0000: syntax error, unexpected ';', expecting ',' or ')' at token ";"
0(81) : error C0501: type name expected at token ";"
0(82) : error C1115: unable to find compatible overloaded function "texture2D(sampler2D, error)"
0(82) : error C0000: syntax error, unexpected ';', expecting ',' or ')' at token ";"
0(82) : error C0501: type name expected at token ";"
0(83) : error C1115: unable to find compatible overloaded function "texture2D(sampler2D, error)"
0(83) : error C0000: syntax error, unexpected ';', expecting ',' or ')' at token ";"
0(83) : error C0501: type name expected at token ";"
0(86) : error C0000: syntax error, unexpected ';', expecting ',' or ')' at token ";"
0(86) : error C0501: type name expected at token ";"
0(98) : error C0000: syntax error, unexpected ';', expecting ',' or ')' at token ";"
0(98) : error C0501: type name expected at token ";"
0(125) : error C0000: syntax error, unexpected ';', expecting ',' or ')' at token ";"
0(125) : error C0501: type name expected at token ";"
>>>>> GLSL source code:
#define OO_USER_DEFINED_BINDINGS 1
#define OO_REDUCED_COMPLEXITY 1
#define OO_TEXTURE_UNIT_COUNT 4
// Texture Information from Oolite.
uniform sampler2D tex0; // Difuse and Illumination map
uniform sampler2D tex1; // Mask map
// Uniforms from Oolite
uniform float uTime; // Time from game clock
uniform float hull_heat_level;
uniform vec4 MainhullColor;
uniform vec4 DecalColor;
// Information from vertex shader.
varying vec3 v_normal; // Surface normal
varying vec3 v_pos; // Vertex/fragment position in eye space
// Constants
const float specExponent = 2.0;
// Irregular flickering function
#ifdef OO_REDUCED_COMPLEXITY
#define Pulse(v, ts) ((v) * 0.95)
#else
float Pulse(float value, float timeScale)
{
float t = uTime * timeScale;
float s0 = t;
s0 -= floor(s0);
float sum = abs( s0 - 0.5);
float s1 = t * 0.7 - 0.05;
s1 -= floor(s1);
sum += abs(s1 - 0.5) - 0.25;
float s2 = t * 1.3 - 0.3;
s2 -= floor(s2);
sum += abs(s2 - 0.5) - 0.25;
float s3 = t * 5.09 - 0.6;
s3 -= floor(s3);
sum += abs(s3 - 0.5) - 0.25;
return (sum * 0.1 + 0.9) * value;
}
// Hull Temperate heat glow
vec4 TemperatureGlow(float level)
{
vec4 result = vec4(0);
result.r = level;
result.g = level * level * level;
result.b = max(level - 0.7, 0.0) * 2.0;
result.a = 1.0;
return result;
}
#endif
// Calculate the contribution of a single light. Ought to be a function, but OS X's GLSlang implementation isn't sufficiently clever.
#define LIGHT(idx) \
{ \
vec3 lightVector = normalize(gl_LightSource[idx].position.xyz); \
vec3 reflection = normalize(-reflect(lightVector, v_normal)); \
diffuse += gl_FrontMaterial.diffuse * gl_LightSource[idx].diffuse * max(dot(v_normal, lightVector), 0.0); \
specular += gl_LightSource[idx].diffuse * pow(max(dot(reflection, eyeVector), 0.0), specExponent); \
}
void main(void)
{
vec4 diffuse = vec4(0.0), specular = vec4(0.0);
vec3 eyeVector = normalize(-v_pos);
// Load texture data
vec2 texCoord = gl_TexCoord[0].st;
vec4 diffuseMap = texture2D(tex0, texCoord);
vec4 maskMap = texture2D(tex1, texCoord);
// calculate specular effects
float specIntensity = (diffuseMap.r + diffuseMap.g + diffuseMap.b);
/* Light 0 is the "showroom" light, used in the demo screen and shipyard.
Light 1 is the sun.
*/
#ifdef OO_LIGHT_0_FIX
LIGHT(0);
#endif
LIGHT(1);
diffuse += gl_FrontMaterial.ambient * gl_LightModel.ambient;
// Calculate the lighting
vec4 color = diffuse * diffuseMap;
#ifdef OO_REDUCED_COMPLEXITY
// Add in the specular effects for simple shader mode
color += specular * color * 3.0 * specIntensity;
#endif
#ifndef OO_REDUCED_COMPLEXITY
// recolour the diffuse map
color += diffuse * maskMap.b * MainhullColor;
color += maskMap.a * DecalColor * diffuse;
// save the modified colour for use in colouring the illumination effect
vec4 colourTemp = color;
// Add in the specular effects for full shader mode
color += specular * color * 3.0 * specIntensity;
// Add in the illumination effects. Full Shader mode only
color += diffuseMap.a * 4.0 * colourTemp;
// Add the all over hull temperature glow
float hullHeat = max(hull_heat_level - 0.5, 0.0) * 2.0;
hullHeat = Pulse(hullHeat * hullHeat, 0.1);
color += TemperatureGlow(hullHeat);
#endif
// Output final color
gl_FragColor = vec4(color.rgb, 1.0);
}
[gameController.exitApp]: .GNUstepDefaults synchronized.
Closing log at 2009-01-10 17:11:38 +0200.
Code: Select all
#define LIGHT(idx) \
{ \
vec3 lightVector = normalize(gl_LightSource[idx].position.xyz); \
vec3 reflection = normalize(-reflect(lightVector, v_normal)); \
diffuse += gl_FrontMaterial.diffuse * gl_LightSource[idx].diffuse * max(dot(v_normal, lightVector), 0.0); \
specular += gl_LightSource[idx].diffuse * pow(max(dot(reflection, eyeVector), 0.0), specExponent); \
}
Nop!! no black linesGriff wrote:yes, i am using an old trunk version with the tangent space normal mapping code in it, but i don't think this error is related - i know this may sound like the ravings of a madman but i think it's my graphics card drivers, they leap in and fix errors in my shaders that other peoples graphics cards complain about and i always end up posting shaders full of bugs that run ok on my pc!
in this bit of the shaderare there any blank lines? there musn't be any blank lines or characters (including spaces) after the \ at the end of every lineCode: Select all
#define LIGHT(idx) \ { \ vec3 lightVector = normalize(gl_LightSource[idx].position.xyz); \ vec3 reflection = normalize(-reflect(lightVector, v_normal)); \ diffuse += gl_FrontMaterial.diffuse * gl_LightSource[idx].diffuse * max(dot(v_normal, lightVector), 0.0); \ specular += gl_LightSource[idx].diffuse * pow(max(dot(reflection, eyeVector), 0.0), specExponent); \ }
Yes we have the same drivers.Griff wrote:i think the same graphics drive, that's the latest November 19th one isn't it?