Re: Recovering "Lost" OXPs
Posted: Wed Sep 23, 2020 6:01 pm
For information and discussion about Oolite.
https://bb.oolite.space/
Ye, that's how it works. It's the default shader (materials) or custom shader. If you want to have the special effects from some custom shader, you need to do some shader coding. If you want to dive deeper, have a look at Griff's shaders .
Took me quite a while to alter acdk's shader in the past to include ship name as an image for behemoths Had to do a lot of reading. There's a sticky thread for this in the expansion section. You can do some serious magic with shaders, but it ain't exactly easy.
Personally I would prefer to keep them with the fixes, easier to maintain in the future. I did some tests with NPC's but I need to test the player ships as well. It might be necessary to add another energy bank or correct the views. So, I guess, I need another 2 - 3 days before I can upload them.dybal wrote: ↑Wed Sep 23, 2020 3:52 pmDo you have a user for oolite.org to add manifests to the Expansion Manager?
If you do and want to add it to the fix, we can ask phkb to transfer them to you, otherwise after you are satisfied with the work sent them to me and I will add them to the fix OXP (or create a new one if you prefer so).
All normal maps are ready to go, my problem is to modify the custom shaders so that normal maps are accepted as well without loosing the effects. If I disable the shaders and use Oolite shaders instead the normal maps work perfectly fine.another_commander wrote: ↑Wed Sep 23, 2020 4:01 pmDo you need help with creating the normal maps themselves or you have them ready and need help to add them to the ships? In the second case, can you upload the relevant shipdata.plists to pastebin or someplace similar so we can have a look?
Code: Select all
// Information from Oolite.
uniform sampler2D uColorMap; // Main texture
uniform sampler2D uEmissionMap; // Engine glow, speedFactor dependent
uniform sampler2D uIlluminationMap; // Lights
uniform float speedFactor;
uniform float hull_heat_level; // Hull glow, temperature dependent
// Information from vertex shader.
varying vec3 v_normal;
#define LIGHT(idx) { vec3 lightVector = normalize(gl_LightSource[idx].position.xyz); color += gl_FrontMaterial.diffuse * gl_LightSource[idx].diffuse * max(dot(v_normal, lightVector), 0.0); }
void main(void)
{
// Calculate illumination.
vec4 color = gl_FrontMaterial.ambient * gl_LightSource[0].ambient;
LIGHT(1);
// Load texture data
vec2 texCoord = gl_TexCoord[0].st;
vec4 colorMap = texture2D(uColorMap, texCoord);
vec4 emissionMap = texture2D(uEmissionMap, texCoord);
vec4 illuminationMap = texture2D(uIlluminationMap, texCoord);
// Add the all over hull temperature glow.
float hullHeat = max(hull_heat_level - 0.5, 0.0) * 2.0;
colorMap.r += hullHeat;
color *= colorMap;
// Add the engine exhaust glow, controlled by speed factor the lights and merge the maps
color += ((speedFactor * emissionMap) + illuminationMap);
gl_FragColor = vec4(color.rgb, 1.0);
}
Code: Select all
// Information sent to fragment shader.
varying vec3 v_normal; // Surface normal
void main()
{
v_normal = normalize(gl_NormalMatrix * gl_Normal);
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
gl_Position = ftransform();
}
Code: Select all
"materials" =
{
"Arachnid_Mark_1_auv.png" =
{
"diffuse_map" = "Arachnid_Mark_1_auv.png";
"emission_map" = "Arachnid_Mark_1_glow.png";
"emission_modulate_color" = ( 1.0, 0.0, 0.0, 1.0 );
"normal_map" = "GalTech_arachnid_mk1_normal.png";
"gloss" = 0.62;
"shininess" = 128;
"specular_color" = ( 0.25, 0.25, 0.25, 1.0 );
};
};
"shaders" =
{
"Arachnid_Mark_1_auv.png" =
{
"vertex_shader" = "Arachnid_Mark_1.vertex";
"fragment_shader" = "Arachnid_Mark_1.fragment";
"textures" =
(
"Arachnid_Mark_1_auv.png",
"Arachnid_Mark_1_Engine_shader.png",
"Arachnid_Mark_1_shader_glow.png",
"GalTech_arachnid_mk1_normal.png"
);
"uniforms" =
{
"uColorMap" = { type = texture; value = 0; };
"uEmissionMap" = { type = texture; value = 1; };
"uIlluminationMap" = { type = texture; value = 2; };
"uNormalMap" = { type = texture; value = 3; }; // new added
"speedFactor" = { binding = "speedFactor"; clamped = true; };
"hull_heat_level" = "hullHeatLevel";
};
};
};
Code: Select all
// Information from vertex shader.
varying vec3 v_normal;
#define LIGHT(idx) { vec3 lightVector = normalize(gl_LightSource[idx].position.xyz); color += gl_FrontMaterial.diffuse * gl_LightSource[idx].diffuse * max(dot(v_normal, lightVector), 0.0); }
void main(void)
{
// Calculate illumination.
vec4 color = gl_FrontMaterial.ambient * gl_LightSource[0].ambient;
LIGHT(1);
// Load texture data
vec2 texCoord = gl_TexCoord[0].st;
vec4 colorMap = texture2D(uColorMap, texCoord);
vec4 emissionMap = texture2D(uEmissionMap, texCoord);
vec4 illuminationMap = texture2D(uIlluminationMap, texCoord);
// Add the all over hull temperature glow.
float hullHeat = max(hull_heat_level - 0.5, 0.0) * 2.0;
colorMap.r += hullHeat;
color *= colorMap;
// Merge the maps by damage weighting
float damageLevel = 1.0 - (energy / maxEnergy);
// Add the engine exhaust glow, controlled by speed factor the lights and merge the maps by damage weighting
color += ((speedFactor * emissionMap) + illuminationMap);
gl_FragColor = vec4(color.rgb, 1.0);
}
Code: Select all
// Information sent to fragment shader.
varying vec3 v_normal; // Surface normal
void main()
{
v_normal = normalize(gl_NormalMatrix * gl_Normal);
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
gl_Position = ftransform();
}
Code: Select all
"materials" =
{
"Serpent_auv.png" =
{
"diffuse_map" = "Serpent_auv.png";
"emission_map" = "Serpent_glow.png";
"normal_map" = "GalTech_serpent_class_cruiser_normal.png";
"gloss" = 0.60;
"shininess" = 10;
"specular_color" = ( 0.25, 0.25, 0.25, 1.0 );
};
};
"shaders" =
{
"Serpent_auv.png" =
{
"vertex_shader" = "Serpent.vertex";
"fragment_shader" = "Serpent.fragment";
"textures" =
(
"Serpent_auv.png",
"Serpent_Engine_shader.png",
"Serpent_glow.png",
"GalTech_serpent_class_cruiser_normal.png"
);
"uniforms" =
{
"uColorMap" = { type = texture; value = 0; };
"uEmissionMap" = { type = texture; value = 1; };
"uIlluminationMap" = { type = texture; value = 2; };
"uNormalMap" = { type = texture; value = 3; }; // new added
"speedFactor" = { binding = "speedFactor"; clamped = true; };
"hull_heat_level" = "hullHeatLevel";
};
};
};
That is exacly my problem. Just materials with Oolite shaders are working well but I lose the custom effects. Since this is actually a "bugfix" I would like to stick to Shipbuilders original as close as possible, means I need to modify the custom shaders.
Code: Select all
// Information from Oolite.
uniform sampler2D uColorMap; // Main texture
uniform sampler2D uEmissionMap; // Engine glow, speedFactor dependent
uniform sampler2D uIlluminationMap; // Lights
uniform sampler2D uNormalMap; // Normal map
uniform float speedFactor;
uniform float hull_heat_level; // Hull glow, temperature dependent
#define LIGHT(idx) { vec3 lightVector = normalize(gl_LightSource[idx].position.xyz); color += gl_FrontMaterial.diffuse * gl_LightSource[idx].diffuse * max(dot(normal, lightVector), 0.0); }
void main(void)
{
// Calculate illumination.
vec4 color = gl_FrontMaterial.ambient * gl_LightSource[0].ambient;
vec3 normal = texture2D(uNormalMap, texCoord).rgb;
LIGHT(1);
// Load texture data
vec2 texCoord = gl_TexCoord[0].st;
vec4 colorMap = texture2D(uColorMap, texCoord);
vec4 emissionMap = texture2D(uEmissionMap, texCoord);
vec4 illuminationMap = texture2D(uIlluminationMap, texCoord);
// Add the all over hull temperature glow.
float hullHeat = max(hull_heat_level - 0.5, 0.0) * 2.0;
colorMap.r += hullHeat;
color *= colorMap;
// Add the engine exhaust glow, controlled by speed factor the lights and merge the maps
color += ((speedFactor * emissionMap) + illuminationMap);
gl_FragColor = vec4(color.rgb, 1.0);
}
Thank you a lot another_commander,
Code: Select all
// Information from Oolite.
uniform sampler2D uColorMap; // Main texture
uniform sampler2D uEmissionMap; // Engine glow, speedFactor dependent
uniform sampler2D uIlluminationMap; // Lights
uniform sampler2D uNormalMap; // Normal map
uniform float speedFactor;
uniform float hull_heat_level; // Hull glow, temperature dependent
#define LIGHT(idx) { vec3 lightVector = normalize(gl_LightSource[idx].position.xyz); color += gl_FrontMaterial.diffuse * gl_LightSource[idx].diffuse * max(dot(normal, lightVector), 0.0); }
void main(void)
{
vec2 texCoord = gl_TexCoord[0].st;
// Calculate illumination.
vec4 color = gl_FrontMaterial.ambient * gl_LightSource[0].ambient;
vec3 normal = texture2D(uNormalMap, texCoord).rgb;
LIGHT(1);
// Load texture data
vec4 colorMap = texture2D(uColorMap, texCoord);
vec4 emissionMap = texture2D(uEmissionMap, texCoord);
vec4 illuminationMap = texture2D(uIlluminationMap, texCoord);
// Add the all over hull temperature glow.
float hullHeat = max(hull_heat_level - 0.5, 0.0) * 2.0;
colorMap.r += hullHeat;
color *= colorMap;
// Add the engine exhaust glow, controlled by speed factor the lights and merge the maps
color += ((speedFactor * emissionMap) + illuminationMap);
gl_FragColor = vec4(color.rgb, 1.0);
}
First test run, the normal map is now shown, no error messages. It certainly looks different from the version with Oolite shaders but I guess it's up to the eye of the beholder to decide which is better. Thank you very much again another_commander.another_commander wrote: ↑Thu Sep 24, 2020 1:20 pmOops, sort of a small error is expected with the previous shader I posted. Reposting the (hopefully correct one) now: