Recovering "Lost" OXPs

General discussion for players of Oolite.

Moderators: another_commander, winston

User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2676
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

Re: Recovering "Lost" OXPs

Post by spara »

cbr wrote: Wed Sep 23, 2020 4:58 pm
But more in how to add normalmaps to ships with custom shaders ( custom effects )...
Try replacing the custom shader entry with materials entry (in other words the default shader). Otherwise you'll need to add normal map code into the custom shader.
User avatar
cbr
---- E L I T E ----
---- E L I T E ----
Posts: 1377
Joined: Thu Aug 27, 2015 4:24 pm

Re: Recovering "Lost" OXPs

Post by cbr »

The picture in my previous post used the materials option.

But you lose the custom effect from the included shader, i think :shock:
User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2676
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

Re: Recovering "Lost" OXPs

Post by spara »

cbr wrote: Wed Sep 23, 2020 6:41 pm
The picture in my previous post used the materials option.

But you lose the custom effect from the included shader, i think :shock:
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 :mrgreen: .
User avatar
cbr
---- E L I T E ----
---- E L I T E ----
Posts: 1377
Joined: Thu Aug 27, 2015 4:24 pm

Re: Recovering "Lost" OXPs

Post by cbr »

Lol, I did look at Griff's shaders hoping to learn something but the solution did not come any closer :p :shock: :shock: :lol:
User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2676
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

Re: Recovering "Lost" OXPs

Post by spara »

cbr wrote: Wed Sep 23, 2020 7:00 pm
Lol, I did look at Griff's shaders hoping to learn something but the solution did not come any closer :p :shock: :shock: :lol:
Took me quite a while to alter acdk's shader in the past to include ship name as an image for behemoths :mrgreen: 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.
User avatar
montana05
---- E L I T E ----
---- E L I T E ----
Posts: 1166
Joined: Mon May 30, 2016 3:54 am
Location: lurking in The Devils Triangle (G1)

Re: Recovering "Lost" OXPs

Post by montana05 »

First of all, thanks a lot to all for the quick replies. Here what I got so far:

Image
Arachnid Mark 1 (custom shaders dissabled, used Oolite shaders)

Image
Constitution Class Heavy Cruiser (now with emission map as well, diffuse map slightly modified)

Image
Cylon Raider Mark 1

Image
GalTech Escort Fighter (escort variant)

Image
GalTech Escort Fighter (pirate variant)

Image
Fireball (player variant)

Image
Fireball (police variant)

Image
Serpent Class Cruiser

All ships with normal maps, Fireball and GalTech Escort Fighter got 1 map for all variants. By using Oolite shaders for Arachnid Mark 1 and Serpent Class Cruiser the effects of the custom shaders obviously are gone but more to that in a following message.

If anybody could offer better maps, I will be more than happy to replace mine with yours, the target is improvment. Ideas for better lightning (gloss, shininess and specular_color) are welcome as well. :)
Scars remind us where we've been. They don't have to dictate where we're going.
User avatar
montana05
---- E L I T E ----
---- E L I T E ----
Posts: 1166
Joined: Mon May 30, 2016 3:54 am
Location: lurking in The Devils Triangle (G1)

Re: Recovering "Lost" OXPs

Post by montana05 »

dybal wrote: Wed Sep 23, 2020 3:52 pm
montana05 wrote: Wed Sep 23, 2020 2:54 pm
Btw, I did assign some multiple lasers as well, not sure so if this should be added to a fix (maybe as an alternative ship) or in an entirely new package.
Do 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).
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.

Here the multiple lasers I have in mind:

Constitution Class Heavy Cruiser (NPC only)
2x fore, 1x rear (now 1x fore, 1x rear)

Cylon Raider Mark 1 (NPC only)
2x fore, (now 1x fore)

Chimera Gunship
3x fore, 1x rear (now 1x fore, 1x rear, 1x starboard, 1x port)

GalTech Escort Fighter
2x fore, 1x rear (now 1x fore, 1x rear)

Serpent Class Cruiser
2x front, 2x rear , 5x starboard, 5x port (now 1x fore, 1x rear, 1x starboard, 1x port) - this is based on Norby's orignal idea for [EliteWiki] Multiple Lasers

Arachnid Mark 1 and Fireball I don't think need modifications, maybe for Fireball police only.

Edit:
Added proper link to Multiple Lasers OXP
Last edited by montana05 on Thu Sep 24, 2020 12:51 pm, edited 1 time in total.
Scars remind us where we've been. They don't have to dictate where we're going.
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6547
Joined: Wed Feb 28, 2007 7:54 am

Re: Recovering "Lost" OXPs

Post by another_commander »

montana05 wrote: Thu Sep 24, 2020 10:02 am
Ideas for better lightning (gloss, shininess and specular_color) are welcome as well. :)

Some lighting and material tips here:

1. Decide what your ship should look like early on. Decide on the type of materials you need for each single part of it. Don't just go with it thinking that you just need to "dress it up" with a texture. If you do, it will most likely end up looking like the texture is a piece of color paper wrapped around a model.

2. Materials are divided into two major categories: metals and dielectrics (i.e. non-metals). Here are some basic guidelines for each:
Metals:
- Specular: Usually white or some shade of gray, values usually in the range of 0.65 - 0.75. Metals can have tinted specular too, e.g. gold, copper. You define this tint in the specular map or with specular_color.
- Gloss: Up to the artist. Experiment until you see something you like.
- Diffuse: Pure metals always have black diffuse color.
Dielectrics:
- Specular: Very low. Usually around (0.04, 0.04, 0.04). Dielcetrics never have tinted specular, unless you are trying to create impossible materials. Things like water have even less specular. For example, the specular value used for the ocean specular reflections in the Lave is Earth OXP is 0.02. Some materials may have slightly different specular values, but normally they are low and materials with specular at around 0.4-0.5 are extremely rare to non-existent. If you are unsure what value to use for your material and you know it is a dielectric, use 0.04.
- Gloss: Depends. Normally on the artist and the appearance they want to achieve. Plastic for example usually has high gloss values but it is not a rule, just a guideline.
- Diffuse: Whatever color your material is. Important - DO NOT include lighting information in a diffuse map - it will look totally off when viewed from the wrong angles. Just put the color of the material there and let the shaders decide on how the lighting will look.

3.The type of material you want to use is not what your object of interest is made of, but what it is on the surface that will reflect the light. Practical example: If your ship is made of titanium and has a coat of paint all over it, the material you want to try to reproduce is paint (which is dielectric) and not titanium.

4. Re normal maps - Try to make details that have a purpose on them. The Arachnid above has a normal map with lots of details, but they are just fluff without purpose. Griff's ships have details on the normal map that seem to outline objects that "do something". The Serpent class above also.

5. Generally speaking, you will get much better results if you use spec and gloss maps rather than numeric values for spec and gloss in the material definition. The reason is that you can describe much better the variations of materials over your surface. You can also describe variations within the same material (e.g. a shiny ship that has a part of a wing that's rusty or dusty - this can be achieved only by texture).

6. Gloss is where an artist has completely free reign. While the other properties are more or less governed by physics, gloss is whatever you want it to be. That is your chance to be truly creative.
User avatar
montana05
---- E L I T E ----
---- E L I T E ----
Posts: 1166
Joined: Mon May 30, 2016 3:54 am
Location: lurking in The Devils Triangle (G1)

Re: Recovering "Lost" OXPs

Post by montana05 »

another_commander wrote: Wed Sep 23, 2020 4:01 pm
montana05 wrote: Wed Sep 23, 2020 2:54 pm
I do have a problem with Arachnid Mark 1 and Serpent Class Cruiser, since I got no experience with shaders at all I got no idea how to add a normal map there, any expert could help with some advice ? :)
Do 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?
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.

So here some code:

Arachnid_Mark_1.fragment:

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);
}
Arachnid_Mark_1.vertex:

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();
}
shipdata.plist:

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";
				};
			}; 
		};
		
serpent.fragment:

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);
}
serpent.vertex:

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();
}
shipdata.plist:

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";
				};
			}; 
		};
	
Scars remind us where we've been. They don't have to dictate where we're going.
User avatar
montana05
---- E L I T E ----
---- E L I T E ----
Posts: 1166
Joined: Mon May 30, 2016 3:54 am
Location: lurking in The Devils Triangle (G1)

Re: Recovering "Lost" OXPs

Post by montana05 »

spara wrote: Wed Sep 23, 2020 6:55 pm
cbr wrote: Wed Sep 23, 2020 6:41 pm
The picture in my previous post used the materials option.

But you lose the custom effect from the included shader, i think :shock:
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 :mrgreen: .
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.

I did have a close look at Griff's shaders and, I am not shy to admit, he is at a level I probably will never reach. I settled for some of KillerWolf's (much easier) shaders instead and tried to adopt them with GalTech shaders, for now with no success. :oops:
Scars remind us where we've been. They don't have to dictate where we're going.
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6547
Joined: Wed Feb 28, 2007 7:54 am

Re: Recovering "Lost" OXPs

Post by another_commander »

Re Arachnid, please try this fragment shader. If you get errors, please post them here and we'll try to work it out.

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);
}
User avatar
montana05
---- E L I T E ----
---- E L I T E ----
Posts: 1166
Joined: Mon May 30, 2016 3:54 am
Location: lurking in The Devils Triangle (G1)

Re: Recovering "Lost" OXPs

Post by montana05 »

another_commander wrote: Thu Sep 24, 2020 11:35 am
montana05 wrote: Thu Sep 24, 2020 10:02 am
Ideas for better lightning (gloss, shininess and specular_color) are welcome as well. :)
Some lighting and material tips here:
Thank you a lot another_commander,
while I was aware of some of it a lot I didn't know. Still a long way to go for me.
Scars remind us where we've been. They don't have to dictate where we're going.
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6547
Joined: Wed Feb 28, 2007 7:54 am

Re: Recovering "Lost" OXPs

Post by another_commander »

Oops, sort of a small error is expected with the previous shader I posted. Reposting the (hopefully correct one) now:

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);
}
User avatar
montana05
---- E L I T E ----
---- E L I T E ----
Posts: 1166
Joined: Mon May 30, 2016 3:54 am
Location: lurking in The Devils Triangle (G1)

Re: Recovering "Lost" OXPs

Post by montana05 »

Ok, (hopefully) my last message for today, a quick schedule of mine:

After finishing the GalTech fix I intend to check Isis Interstellar for another fix. Werewolf got problems with the material files (wrong format) and some subentities at other ships are wrong designed, the OXPs never published need a complete check. Parallel I hope I could finish starwars_remake.OXP and continue on Dictators.OXP. :roll:
Scars remind us where we've been. They don't have to dictate where we're going.
User avatar
montana05
---- E L I T E ----
---- E L I T E ----
Posts: 1166
Joined: Mon May 30, 2016 3:54 am
Location: lurking in The Devils Triangle (G1)

Re: Recovering "Lost" OXPs

Post by montana05 »

another_commander wrote: Thu Sep 24, 2020 1:20 pm
Oops, sort of a small error is expected with the previous shader I posted. Reposting the (hopefully correct one) now:
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. :)
Scars remind us where we've been. They don't have to dictate where we're going.
Post Reply