Page 8 of 21
Posted: Sat May 05, 2007 3:00 pm
by Griff
I've uploaded the glowing alloy oxp here (it's 274 Kb)
Edit: Link removed - i've updated the oxp, see below
it doesn't replace the standard alloy object but sometimes appears instead of one when a ship gets destroyed.
I might make some more versions of the alloy object for a bit of variety and i'll try and write out some stuff about what the various textures do, how to draw them in photoshop and how the shader works with them to make the glow effect.
Posted: Sat May 05, 2007 9:42 pm
by JensAyton
Initial comments:
1) Nice.
2) The line “specular = mix(specular, specular * diffuse, 0.0);” has no effect. (This is probably inherited from when I was trying out variations on specular effects in the Krait.)
3) You’ve got the value 1.51 repeatedly in the code. Good practice here is to use a constant, i.e. “const float kHeatLevel = 1.51;” (I’d put it at the top with the uniforms) and then use kHeatLevel as appropriate - this lets you change it in one place and also makes it more obvious what it’s for. This also makes it trivial to change it to a uniform so you can twiddle it interactively in a GLSL editor. The “k” prefix is a convention used in Mac programming to differentiate between constants and variables; use whatever convention you want.
Posted: Sun May 06, 2007 5:11 pm
by Griff
Hi Ahruman, thanks for picking through the shader code! the 1.51 value was the metal_temperature variable which i was controlling with a slider in rendermonkey, i didn't know the correct way to give it a value but i noticed that replacing metal_temperature with a number seemed to work so i chose an easily spottable value so i could quickly do a find & replace when changing between '1.51' & 'metal_temperature' when testing out the shader, i'll make the changes you suggest and re-up the oxp.
i was wondering why the specularity effects don't appear in rendermonkey, is it something to do with "gl_LightSource[idx]", is this making a reference to the 'sun' in oolite.
when (if?) my brain is up to it it'll have a look at the examples in rendermonkey, there's some phong lighting examples in there that i might be able to bring your lighting code into so i can preview specular maps.
Edit: I've made the changes to the shader and re-uploaded it. I've edited the link in my post to go to the new version.
Posted: Sun May 06, 2007 10:47 pm
by JensAyton
Hmm. It’s basically impossible with this shader for the specular lighting not to show up if diffuse lighting is (assuming tex0 and tex1 are set up correctly, i.e. you can see the glow effect). However, the specular map is rather subtle since the specular intensity channel (green) is rather dim. Here’s the shader with specular lighting on and off (by commenting out the “specular +=” line in LIGHT):
That’s on one of the parts of the texture where the effect is most noticable. However, I do see it when I put it on a plane and turn it towards the light.
If you want to make it less subtle, the best approach would be to use the full dynamic range of the green channel (i.e., make it less dim from the start), then adjust overall intensity with the tweak factor (currently 1.2) in the code. Change that 1.2 to 20.0 and you should have no problem seeing the effect is there. :-)
Another issue: while testing on a MacBook (with Intel GMA 950 graphics) over the weekend, I discovered that the Pulse function used in many of my shaders and in your glowing alloy one cause it to fall back to software. To avoid/work around this in future versions of Oolite, I suggest providing a low-definition version of it which removes the pulse/flicker effects but allows hardware rendering on GMA 950s:
Code: Select all
#ifdef OO_REDUCED_COMPLEXITY
#define Pulse(v, ts) ((v) * 0.95)
#else
float Pulse(float value, float timeScale)
{
float t = time * timeScale; // multiplier on end of this line increases the flicker effect
float s0 = t;
s0 -= floor(s0);
float sum = abs( s0 - 0.5);
float s1 = t * 1.7 - 0.05;
s1 -= floor(s1);
sum += abs(s1 - 0.5);
float s2 = t * 2.3 - 0.3;
s2 -= floor(s2);
sum += abs(s2 - 0.5);
float s3 = t * 5.09;
s3 -= floor(s3);
sum += abs(s3 - 0.5);
return (sum * 0.25) * value;
}
#endif
You can test this by adding the line “#define OO_REDUCED_COMPLEXITY” before this code. I intend to have Oolite predefine OO_REDUCED_COMPLEXITY when the user selects simple shaders in preferences, and also to try realoading shaders with it defined if they fall back to software rendering with full complexity (although it may only be possible to detect this under OS X).
Posted: Sun May 06, 2007 11:38 pm
by Griff
heh, wow that specular effect really is subtle, i spent ages trying to spot it, it's about 4 pixels slightly brighter in one image and not the other!
mind you, i quite like that texture wrapped around a sphere as in your example, it looks like some sort of volcano planet!
about the lighting in rendermonkey, i had to add a * 20.0; multiplier to the end of this line in the LIGHT(1); macro part of the shader to 'brighten' up the lights otherwise the objects appear so dark it's as if there's no lighting in the scene at all with just the glow maps appearing:-
diffuse += gl_FrontMaterial.ambient * gl_LightModel.ambient
I wonder if this is canceling out the calculations that add the specular effects?
i guess what i need to do is to write a shader specifically for previewing specular maps in render monkey, setting fixed values for variables in lines like these:-
vec3 lightVector = normalize(gl_LightSource[idx].position.xyz); \
edit: oh hang on, that's not going to work is it, it's going to make the light shine onto the object from all possible directions at once
i suppose to be fair, the shader is relying on information from the Oolite game engine that doesn't exist when running the shader in rendermonkey so the gl_LightSource doesn't exist or has zero value.
Edit: I've added the changes to the pulse function to the oxp and updated the link in the post above
Posted: Mon May 07, 2007 5:58 am
by JensAyton
Griff wrote:about the lighting in rendermonkey, i had to add a * 20.0; multiplier to the end of this line in the LIGHT(1); macro part of the shader to 'brighten' up the lights otherwise the objects appear so dark it's as if there's no lighting in the scene at all with just the glow maps appearing:-
diffuse += gl_FrontMaterial.ambient * gl_LightModel.ambient
Ahh, right. In that case, you haven’t set up ligh #1 in RenderMonkey. Changing LIGHT(1) to LIGHT(0) is a hack solution, but the correct way is to work out how to set up lights. :-) (Or you could #define OO_LIGHT_0_FIX)
Posted: Mon May 07, 2007 10:24 am
by Griff
wow, thanks man! i took the easy option and changed light(1) to light(0)
it's great being able to quickly preview the specular maps in rendermonkey, i've gone back to working on the krait for a moment to work on giving it a more dull metal like look.
Edit: ooh, shiny!
Posted: Mon May 07, 2007 11:06 am
by Uncle Reno
I think it looks like a planet with centres of habitation illuminated.
Posted: Mon May 07, 2007 8:09 pm
by Arexack_Heretic
That is really pretty!
(I need my shades for that specular glow)
If you are looking for a quick alternates, feel free to browse:
Wrex_OXP_DEV which has several lowpoly debris-sized alloy models.
http://home.tiscali.nl/arexack/arexack/ ... ks/models/
Posted: Tue May 08, 2007 10:20 am
by Griff
Edit:
Cool models A_H, i grabbed a few and added the glowing metal shader to them, i'll add them into the glowing_alloys.oxp if that's ok :-
Posted: Thu May 10, 2007 8:42 pm
by Griff
I've uploaded a newer version, this one features some great new debris models by Arexack_Heretic (see above) as well as some tweaks to the specularity maps.
Edit: added the 'smooth' option to the models and Ahrumans new cooling effect shader. Note: this .oxp now needs at least version 1.69 of Oolite to work.
http://www.box.net/shared/ha4vs8ntkb
Posted: Thu May 10, 2007 9:17 pm
by Arexack_Heretic
Wow!
I just love glowing metal.
Looks awesome as always Griff!
Posted: Sat Aug 04, 2007 8:18 pm
by Griff
it's the turn of the poor old boa
good job you upped the model vertex and face limits Ahruman!
Posted: Sat Aug 04, 2007 9:01 pm
by JensAyton
Mmmm… light maps. :-)
Posted: Sat Aug 04, 2007 9:09 pm
by Cmdr. Maegil
The word "awesome" is getting beaten up, but still holds true. Unfortunately, regardless of how much I love the model (and I do, a lot), I can't see the Boa in it...