Griff wrote:A_C, Thanks for fixing the shaders!
Should i replace the ones in the original upload with your fixed ones? If poss, could you post a bit of info about what you had to fix so i could make sure to include it in future shaders?
I am not sure if the original ones should be replaced. If they worked for you as they were, then it probably means that it's my gfx driver that misbehaves. However, you can try using them on your system and if they work as expected anyway, then you can probably replace them so that they will work on any card, even the semi-decent ones
.
The correction was in how variables are declared. Initially it was
Code: Select all
// Constants
float kInitialHeat = 5.0;
const float KspecExponent = 5.0;
const float kSpecular = 0.4;
// Set up the total burntime
float FadeTime2 = FadeTime * 100.0; // Multiply FadeTime by 100 to lengthen the burn time
float FadeFactor = kInitialHeat / FadeTime2;
All this was declared outside of main(). I brought most of it in, making main look like this (note I did not touch the two const variables):
Code: Select all
void main()
{
vec3 eyeVector = normalize(vEyeVector);
vec2 texCoord = vTexCoord;
vec3 normal = normalize( texture2D(uNormalMap, texCoord).xyz - 0.5);
normal = normalize(normal);
vec4 colorMap = texture2D(uColorMap, texCoord);
vec4 effectsMap = texture2D(uEffectsMap, texCoord);
vec4 diffuse = vec4(0.0), specular = vec4(0);
float specIntensity = colorMap.a;
// ------------ Brought in from outside of main ---------------
// Set up the total burntime
float kInitialHeat = 5.0;
float FadeTime2 = FadeTime * 100.0; // Multiply FadeTime by 100 to lengthen the burn time
float FadeFactor = kInitialHeat / FadeTime2;
//------------------------------------------------------------------
#ifdef OO_LIGHT_0_FIX
LIGHT(0, normalize(vLight0Vector));
#endif
LIGHT(1, normalize(vLight1Vector)); // change the 0 to 1 when saving the shader for oolite
diffuse += gl_FrontMaterial.ambient * gl_LightSource[0].ambient;
float NonClipHeatGlow = effectsMap.r; // just the hot metal effect, no polygon clipping
// Calculate the lighting,
vec4 color = diffuse * colorMap + specular * specIntensity;
// Add the glowing metal effect
float metalTemperature = max(0.0, kInitialHeat - FadeFactor * timeElapsedSinceSpawn * 0.5); // half speed cooling for the no-clipping heat glow
float Heat = max(metalTemperature - 0.5, 0.0);
Heat = Pulse(metalTemperature, 0.5);
float FinalTemperature = NonClipHeatGlow * (Heat + metalTemperature);
color += MetalGlow(FinalTemperature) * colorMap;
// Add the Sparking Illumination
color += effectsMap.g * SparkColor * Blink_on_off(Pulse(1.0, 1.0)) +
effectsMap.b * SparkColor * Blink_on_off(Pulse(1.0, 0.4));
gl_FragColor = color;
}
and that seemed to have been enough to fix it. Same fix for all of the fragment shaders. But since you have a new version out, I would like to try that as well.