Page 2 of 3

Posted: Wed May 19, 2010 8:01 am
by Griff
ah, you're right, i mangled the settings when i was coping bits over from other shaders, i've put the original specIntensity settings back into the capt_kev_dodo.fragment shader and updated the download
if anyone would like to add the changes into their already downloaded oxp without having to fetch todays updated one, open capt_kev_dodo.fragment using a text editor, and change line 31 to

Code: Select all

float specIntensity = 12.0 * colorMap.r * colorMap.r;
then save, then restart Oolite whilst holding down the shift key until the spinning cobra comes up (in order to get Oolite to re-read the changes made to the shader)

Posted: Wed May 19, 2010 8:27 am
by CaptKev
Thanks for the change Griff, it's my fault I didn't upload the correct version that's using bump-maps (I think that's what there called).

But running on the latest version of Oolite (1.74) the Dodo appears very shiny indeed.

Image

This is the code in the fragment shader, have you got any ideas what might be causing it?

Code: Select all

uniform sampler2D    tex0;
uniform sampler2D    tex1;

varying vec2         vTexCoord;
varying vec3         vEyeVector;   // These are all in tangent space
varying vec3         vLight0Vector;
varying vec3         vLight1Vector;

const float          kSpecExponent = 2.0;
const float          kSpecular = 0.8;

vec4 LampColor = vec4(0.9, 0.9219, 0.6436, 1.0);

void Light(in vec3 lightVector, in vec3 normal, in vec4 lightColor, in vec3 eyeVector, 
           in float specExponent, inout vec4 totalDiffuse, inout vec4 totalSpecular)
{
   lightVector = normalize(lightVector);
   vec3 reflection = normalize(-reflect(lightVector, normal));
   
   totalDiffuse += gl_FrontMaterial.diffuse * lightColor * max(dot(normal, lightVector), 0.0);
   totalSpecular += lightColor * pow(max(dot(reflection, eyeVector), 0.0), specExponent);
}


#define LIGHT(idx, vector) Light(vector, normal, gl_LightSource[idx].diffuse, eyeVector, kSpecExponent, diffuse, specular)


void main()
{
   vec3 eyeVector = normalize(vEyeVector);
   
   vec2 texCoord = vTexCoord;
   
   vec3 normal = normalize( texture2D(tex1, texCoord).xyz - 0.5);
   normal = normalize(normal);
   vec4 colorMap = texture2D(tex0, texCoord);
   
   vec4 diffuse = vec4(0.0), specular = vec4(0);
   
#ifdef OO_LIGHT_0_FIX
   LIGHT(0, normalize(vLight0Vector));
#endif
   LIGHT(1, normalize(vLight1Vector));
   
   diffuse += gl_FrontMaterial.ambient * gl_LightSource[0].ambient;
   
   vec4 color = diffuse * colorMap;
   
// calculate the specular, colour it using the diffuseMap 
   color += colorMap * 3.5 * specular * kSpecular;

// add in the glowing window lights   
   color += LampColor * colorMap.a; // multiplier here to increase glow effect
   
   color.a = 1.0;
   
   gl_FragColor = color;
}

Posted: Wed May 19, 2010 8:48 am
by Griff
ee, that looks really odd to say the least!
Capt Kev, i'm not sure if that's the correct shader to use
try this as the dodo's fragment (from todays updated version of the oxp)

Code: Select all

varying vec2         vTexCoord;
varying vec3         vEyeVector;
varying vec3         vLight0Vector;
varying vec3         vLight1Vector;
varying vec3         v_normal;

// Constants
const float KspecExponent = 8.0;
   
// Uniforms from Oolite
   uniform sampler2D    uColorMap;

void Light(in vec3 lightVector, in vec3 lightColor, in vec3 eyeVector, 
           in float KspecExponent, inout vec3 totalDiffuse, inout vec3 totalSpecular)
{
   lightVector = normalize(lightVector);
   vec3 reflection = normalize(-reflect(lightVector, v_normal));
   
   totalDiffuse += gl_FrontMaterial.diffuse.rgb * lightColor * max(dot(v_normal, lightVector), 0.0);
   totalSpecular += lightColor * pow(max(dot(reflection, eyeVector), 0.0), KspecExponent);
}

#define LIGHT(idx, vector) Light(vector, gl_LightSource[idx].diffuse.rgb, eyeVector, KspecExponent, diffuse, specular)

void main()
{
   vec3 eyeVector = normalize(vEyeVector);
   vec3 colorMap = texture2D(uColorMap, vTexCoord).rgb;
   float glowMap = texture2D(uColorMap, vTexCoord).a;
   float specIntensity = 12.0 * colorMap.r * colorMap.r;

   vec3 diffuse = vec3(0.0), specular = vec3(0);

#ifdef OO_LIGHT_0_FIX
   LIGHT(0, normalize(vLight0Vector));
#endif
   LIGHT(1, normalize(vLight1Vector));
   diffuse += gl_FrontMaterial.ambient.rgb * gl_LightModel.ambient.rgb;

// Add in the glow map
diffuse += glowMap * 3.0; 
   
// Calculate the lighting 
   vec3 color = diffuse * colorMap + specular * specIntensity;
    
   gl_FragColor = vec4(color.rgb, 1.0);
}
and this as its vertex shader

Code: Select all

varying vec2         vTexCoord;
varying vec3         vEyeVector;
varying vec3         vLight0Vector;
varying vec3         vLight1Vector;
varying vec3         v_normal;

void main()
{

   v_normal = normalize(gl_NormalMatrix * gl_Normal);
   
   vec3 eyeVector = -vec3(gl_ModelViewMatrix * gl_Vertex);
   vEyeVector = eyeVector;
   
#ifdef OO_LIGHT_0_FIX
   vec3 light0Vector = gl_LightSource[0].position.xyz + vEyeVector;
   vLight0Vector = light0Vector;
#endif
   vec3 light1Vector = gl_LightSource[1].position.xyz + vEyeVector;
   vLight1Vector = light1Vector;
   vTexCoord = gl_MultiTexCoord0.st;
   
   gl_Position = ftransform();
}
support for the tex0, tex1 bit at the top of the shader to get the texture files into the shader has been dropped or is due to be dropped by Oolite soon i think, there's a much more human friendly way of doing it in the shipdata.plist, the shaders bit for the dodo should now look something like this, first you list your texture png's, then you can link them using uniforms to the shader, i've chosen to use an uniform called "uColorMap" which is assigned to the texture, then referenced in the shader by using the same uniform name

Code: Select all

	shaders = 
		{ 
            "capt_kev_dodo_plain.png" = 
			{ 
                vertex_shader = "capt_kev_dodo.vertex"; 
                fragment_shader = "capt_kev_dodo.fragment"; 
                textures = (
							"capt_kev_dodo_plain.png"
							);
				uniforms =
						{
						uColorMap = { type = texture; value = 0; };
						}; 	
			}; 
		}; 

see if that makes it work better.
These 2 shaders above don't support normal mapping, do you have a bump map made for the station? if so i can send some new shaders that will be able to use it (the ones from the coriolis in the normal mapped shipset i'm working on)

Posted: Wed May 19, 2010 9:14 am
by NorthenderPNE
Downloaded the fixed version and it runs okay on my nVidia based laptop trunk 3375. The previous one was fine also.

As someone asked earlier if i'm not mistaken, did you do the other two stations. It would be cool.

Keep up the good work guys! :wink:

Posted: Thu May 20, 2010 7:13 am
by CaptKev
@Griff, thanks you're a star! Will give this a try later and let you know how I get on. I will need to include the normal map at some point, should I use the shaders from your normal mapped coriolis? (BTW Love all the new normal mapped ships you've recently added)

@bigmike20vt & NorthenderPNE, The newer version of the OXP contains three variants of the Dodo and the Ico.

Posted: Thu May 20, 2010 8:54 am
by Griff
@ Capt Kev, yeah we could use those shaders, but thinking about it, we might earn ourselves a gold star from Ahruman or at least, lower his exasperation levels if we did it all with Materials in the shipdata.plist,
http://wiki.alioth.net/index.php/Materials_in_Oolite
https://bb.oolite.space/viewtopic.php?t=7876

when you've got the artwork ready we'll have a look into it, the cool thing about materials is that there's no need for writing any custom shaders, you just list your textures files and the job you'd like them to do (eg diffusemap, normalmap etc) and the built in oolite shaders will do all the magic

Posted: Thu May 20, 2010 9:44 am
by Eric Walch
CaptKev wrote:
@Griff, thanks you're a star! Will give this a try later and let you know how I get on. I will need to include the normal map at some point, should I use the shaders from your normal mapped coriolis?
Bad idea. That shader does not work in trunk. (also the freaky thargoid shader stopped working correct). As far as I understood it is using a very early technique that should be replaced in future shaders of this type.

Posted: Thu May 20, 2010 10:14 am
by Griff
Is that the 'textures are missing' bug Eric? I'm sure that got fixed in one of the recent updates. although it's very possible i forgot to update everything and missed the coriolis out!
i just checked the current dizzy all-in-1 bundle oxp with trunk version 3384 and it seemed to be ok

Posted: Thu May 20, 2010 12:45 pm
by Eric Walch
Griff wrote:
Is that the 'textures are missing' bug Eric? I'm sure that got fixed in one of the recent updates. although it's very possible i forgot to update everything and missed the coriolis out!
i just checked the current dizzy all-in-1 bundle oxp with trunk version 3384 and it seemed to be ok
A_C spotted it first, but when looking carefully you notice the lighting is not constant were it should be constant. (top and bottom part) And the normal map is not used for that station in trunk since a month or so.
----
I just downloaded your latest version. There everything is okay. So it seems you already fixed things.

Posted: Thu May 20, 2010 2:28 pm
by Cody
Is this the Mayan version?

Image

Posted: Thu May 20, 2010 3:27 pm
by Griff
yes, there's also a 'plain' one which doesn't have a decal and an 'imperial' one which has the red decal seen in the other screenshots in this thread
aww, look at the tiny little adder heading in for docking, looks like he's going to land on the hanger floor on his roof

Posted: Fri May 21, 2010 12:29 am
by JazHaz
Anyone got an image of the Ico stations?

Posted: Fri May 21, 2010 12:33 am
by Cody
I don't think the Ico is in the oxp... been to a couple of systems that have Icos today, and they were normal Oolite stations.
Not in the demo screen either. In fact, there's no Ico of any type in the demo screen.

Just checked the shipdata.plist... no Ico.

Posted: Fri May 21, 2010 1:01 am
by JazHaz
El Viejo wrote:
I don't think the Ico is in the oxp... been to a couple of systems that have Icos today, and they were normal Oolite stations.
Not in the demo screen either. In fact, there's no Ico of any type in the demo screen.

Just checked the shipdata.plist... no Ico.
Weird!
CaptKev wrote:
There should be a Imperial and Mayan version of the Dodo and a Ico station within the OXP, I'll have a look to see if I can find a later version.

Posted: Fri May 21, 2010 6:41 am
by CaptKev
Griff wrote:
@ Capt Kev, yeah we could use those shaders, but thinking about it, we might earn ourselves a gold star from Ahruman or at least, lower his exasperation levels if we did it all with Materials in the shipdata.plist,
http://wiki.alioth.net/index.php/Materials_in_Oolite
https://bb.oolite.space/viewtopic.php?t=7876

when you've got the artwork ready we'll have a look into it, the cool thing about materials is that there's no need for writing any custom shaders, you just list your textures files and the job you'd like them to do (eg diffusemap, normalmap etc) and the built in oolite shaders will do all the magic
Thanks again Griff, using the built in shaders to do all the work will certainly make the job easier. I will have a look at the links you've supplied but in the meantime here's the beta version (using normal maps along with the Ico station)

http://www.msdownload.co.uk/Oolite/dodo ... s_beta.zip