Shaders’ Outpost
Moderators: winston, another_commander
- Arexack_Heretic
- Dangerous Subversive Element
- Posts: 1876
- Joined: Tue Jun 07, 2005 7:32 pm
- Location: [%H] = Earth surface, Lattitude 52°10'58.19"N, longtitude 4°30'0.25"E.
- Contact:
Shaders’ Outpost
Thread meant for compiling experiences, tuts, good advice and FAQ about the revolutionary concept of texture shaders.
(as available from version 1.68 upwards.)
-insert links to relevant wiki and other handy resources-
https://bb.oolite.space/viewtopic.php?t= ... highlight=
https://bb.oolite.space/viewtopic.php?t=3368&start=15
https://bb.oolite.space/viewtopic.php?t=3407&start=105
Explaining texture-sampling and working the coordinates
Griff Ruining the Classics thread
Example_OXPs:
Griff Rocket Example 1 Custom specularity, laser_heat/exhaust_heat glow, constant glow
Griff Rocket Example 2 Custom specularity, laser_heat/exhaust_heat glow/engine_level glow
Griff Pod Example 3 Specularity Settings driven by a Texture Map, Laser_Heat Glow, Exhaust_Heat Glow, Constantly lit glow map for hull lights etc
Griff lighted hangar Bright illumination and red-alert versions
Thargoids: they had it 1st. The classic Aegidian example of a timer driven sine-function additive texture shader.
Shady PythonClass Cruiser Another classic example ship-oxp by Aegidian.
Hot 2Cool alloys Another timer-driven shader this time single direction and started on spawn_time, coloursamples applied instead of a texture.
Shady Billboard An illuminated billboard.
Ahruman's 'Electric' Billboard Advanced billboard that mimics led-array billboards.
Fixed texture for 'Electric' Billboard
Griff sign concept1 Uses discard-clipping.
Ahruman Animation concept Examplifies how animation can be accomplished by shader, also Uses colour-discard-clipping.
Cobra_OXP Example by Ahruman.
Krait OXP full Great example OXP by Griff.
Griff Krait OXP lowspec
Griff Boa optimized Another beauty. showoff -no, go on we loves them.
Griff's optimized krait[/url]
(as available from version 1.68 upwards.)
-insert links to relevant wiki and other handy resources-
https://bb.oolite.space/viewtopic.php?t= ... highlight=
https://bb.oolite.space/viewtopic.php?t=3368&start=15
https://bb.oolite.space/viewtopic.php?t=3407&start=105
Explaining texture-sampling and working the coordinates
Griff Ruining the Classics thread
Example_OXPs:
Griff Rocket Example 1 Custom specularity, laser_heat/exhaust_heat glow, constant glow
Griff Rocket Example 2 Custom specularity, laser_heat/exhaust_heat glow/engine_level glow
Griff Pod Example 3 Specularity Settings driven by a Texture Map, Laser_Heat Glow, Exhaust_Heat Glow, Constantly lit glow map for hull lights etc
Griff lighted hangar Bright illumination and red-alert versions
Thargoids: they had it 1st. The classic Aegidian example of a timer driven sine-function additive texture shader.
Shady PythonClass Cruiser Another classic example ship-oxp by Aegidian.
Hot 2Cool alloys Another timer-driven shader this time single direction and started on spawn_time, coloursamples applied instead of a texture.
Shady Billboard An illuminated billboard.
Ahruman's 'Electric' Billboard Advanced billboard that mimics led-array billboards.
Fixed texture for 'Electric' Billboard
Griff sign concept1 Uses discard-clipping.
Ahruman Animation concept Examplifies how animation can be accomplished by shader, also Uses colour-discard-clipping.
Cobra_OXP Example by Ahruman.
Krait OXP full Great example OXP by Griff.
Griff Krait OXP lowspec
Griff Boa optimized Another beauty. showoff -no, go on we loves them.
Griff's optimized krait[/url]
Last edited by Arexack_Heretic on Thu Oct 25, 2007 8:43 pm, edited 12 times in total.
Riding the Rocket!
- Griff
- Oolite 2 Art Director
- Posts: 2484
- Joined: Fri Jul 14, 2006 12:29 pm
- Location: Probably hugging his Air Fryer
Shader Example, featuring:-
. Customisable Specularity Settings
. Laser Heat Glow
. Exhaust Heat Glow
. Constantly lit glow map for hull lights etc
Link to OXP:-
http://www.box.net/shared/ogotygiqui (550KB)
Customisable Specularity Settings
Edit the fragment shader to produce various specularity effects:-
search for the following lines in the griff_rocket.fragment file, you can safely open them in any text editor:-
Next, i'll upload a variation of the fragment shader that links the hull lights to the engine_level so they brighten or dim depending on how fast the ship is flying
. Customisable Specularity Settings
. Laser Heat Glow
. Exhaust Heat Glow
. Constantly lit glow map for hull lights etc
Link to OXP:-
http://www.box.net/shared/ogotygiqui (550KB)
Customisable Specularity Settings
Edit the fragment shader to produce various specularity effects:-
search for the following lines in the griff_rocket.fragment file, you can safely open them in any text editor:-
Code: Select all
specular += gl_LightSource[idx].diffuse * pow(max(dot(reflection, eyeVector), 0.0), 5.0); \
}
// The 5.0 at the end of the line above is the Specular Exponent setting, higher values = more glossy (highlight is smaller)
Code: Select all
vec4 color = diffuse * colorMap + specular * 0.6; // the 0.6 in this line is the SpecularIntensity, higher values = stronger highlight
Last edited by Griff on Sat Jun 02, 2007 4:23 pm, edited 2 times in total.
- Griff
- Oolite 2 Art Director
- Posts: 2484
- Joined: Fri Jul 14, 2006 12:29 pm
- Location: Probably hugging his Air Fryer
Shader Example 2, featuring:-
. Customisable Specularity Settings
. Laser Heat Glow
. Exhaust Heat Glow
. Glow map for hull lights etc, brightness linked to engine_level variable
Here's a new version of the above oxp that links the hull lights glow map to the engine level of the ship. I've modified the glowmap texture to have a lot more lurid coloured lights on it and given the ship a fuel injector so it can really work up some speed and get them lights blazing away!
Download here:-
http://www.box.net/shared/h95rd0n25x
the only 2 differences between this version of the fragment shader and the previous one are as follows:-
first, this addition of this line
uniform float engine_level;
which adds a variable called engine_level which links the shader to information from the Oolite engine
and this line:-
color += glowMapEngine_level * Pulse(engine_level, 1.0);
which used to read :-
color += glowMapEngine_level * Pulse(2.0, 1.0);
which kept the light glow level constant at 2.0
. Customisable Specularity Settings
. Laser Heat Glow
. Exhaust Heat Glow
. Glow map for hull lights etc, brightness linked to engine_level variable
Here's a new version of the above oxp that links the hull lights glow map to the engine level of the ship. I've modified the glowmap texture to have a lot more lurid coloured lights on it and given the ship a fuel injector so it can really work up some speed and get them lights blazing away!
Download here:-
http://www.box.net/shared/h95rd0n25x
the only 2 differences between this version of the fragment shader and the previous one are as follows:-
first, this addition of this line
uniform float engine_level;
which adds a variable called engine_level which links the shader to information from the Oolite engine
and this line:-
color += glowMapEngine_level * Pulse(engine_level, 1.0);
which used to read :-
color += glowMapEngine_level * Pulse(2.0, 1.0);
which kept the light glow level constant at 2.0
Last edited by Griff on Sat Jun 02, 2007 4:23 pm, edited 1 time in total.
- Griff
- Oolite 2 Art Director
- Posts: 2484
- Joined: Fri Jul 14, 2006 12:29 pm
- Location: Probably hugging his Air Fryer
Shader Example 3, featuring:-
. Specularity Settings driven by a Texture Map
. Laser Heat Glow
. Exhaust Heat Glow
. Constantly lit glow map for hull lights etc
It's possible to drive shader Specular Exponent & Specular Intensity values using a texturemap, which is great if you want to vary specularity across your ships surface, eg - give the cockpit window an intense, narrow highlight for a 'glassy' look whilst the engines and hull get a weak wide specular highlight for dull metal look
This isn't a very good example, but notice the orange area on this object (it's supposed to be leaking fuel!) is more shiny that the metal around it and the grill areas don't have a highlight to give the impression that they are openings into the object
This shader requires an aditional texturemap, the Red Channel of which drives the Specular Exponent and the Green Channel drives the Specular Intensity, the Blue Channel is not used.
Download Here:=
http://www.box.net/shared/m3lnqejld9
. Specularity Settings driven by a Texture Map
. Laser Heat Glow
. Exhaust Heat Glow
. Constantly lit glow map for hull lights etc
It's possible to drive shader Specular Exponent & Specular Intensity values using a texturemap, which is great if you want to vary specularity across your ships surface, eg - give the cockpit window an intense, narrow highlight for a 'glassy' look whilst the engines and hull get a weak wide specular highlight for dull metal look
This isn't a very good example, but notice the orange area on this object (it's supposed to be leaking fuel!) is more shiny that the metal around it and the grill areas don't have a highlight to give the impression that they are openings into the object
This shader requires an aditional texturemap, the Red Channel of which drives the Specular Exponent and the Green Channel drives the Specular Intensity, the Blue Channel is not used.
Download Here:=
http://www.box.net/shared/m3lnqejld9
- Arexack_Heretic
- Dangerous Subversive Element
- Posts: 1876
- Joined: Tue Jun 07, 2005 7:32 pm
- Location: [%H] = Earth surface, Lattitude 52°10'58.19"N, longtitude 4°30'0.25"E.
- Contact:
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
Exactly the opposite. :-)Arexack_Heretic wrote:Then red is providing the brightness and green the shineyness?
E-mail: [email protected]
- Arexack_Heretic
- Dangerous Subversive Element
- Posts: 1876
- Joined: Tue Jun 07, 2005 7:32 pm
- Location: [%H] = Earth surface, Lattitude 52°10'58.19"N, longtitude 4°30'0.25"E.
- Contact:
- Griff
- Oolite 2 Art Director
- Posts: 2484
- Joined: Fri Jul 14, 2006 12:29 pm
- Location: Probably hugging his Air Fryer
It's not a very good example i provided i'm afraid, the glossyness on the 'fuel leak' isn't high enough, the specular highlight should be a little dot and not a great big wide streak. It's easy to modify the fragment shader to add a multiplier to the intensity of the red channel to get the correct glossy effect, but you'd have to make sure it doesn't break the highlight across the rest of the object. Another solution would be to use the currently unused blue channel to drive a highly multiplied specular effect just for the more extremely glossy areas.
Edit: I've added another version of this shader that now allows you to use the previously unused blue channel in the specular map texture to add highly glossy areas to your object, notice the fuel leak now looks a lot more 'wet' as it's specular exponent has a much higher value than before.
download here:-
http://www.box.net/shared/mprc65klvi
The only change to the fragment shader is this line
which used to read
you can see it just adds in the blue channel (multiplied by 200) of the specMap texture to the specular effect.
Edit: I've added another version of this shader that now allows you to use the previously unused blue channel in the specular map texture to add highly glossy areas to your object, notice the fuel leak now looks a lot more 'wet' as it's specular exponent has a much higher value than before.
download here:-
http://www.box.net/shared/mprc65klvi
The only change to the fragment shader is this line
Code: Select all
float specExponent = specMap.r + 2.0 + specMap.b * 200;
Code: Select all
float specExponent = specMap.r + 2.0;
Last edited by Griff on Sun Jun 03, 2007 5:08 pm, edited 3 times in total.
- Griff
- Oolite 2 Art Director
- Posts: 2484
- Joined: Fri Jul 14, 2006 12:29 pm
- Location: Probably hugging his Air Fryer
Illumination Shader for Docking Bays
the zip contains two oxp's for docking bay illumination, one of which has a pulsing red ambient light effect to give a "red alert!" feeling, might be fun to use on a mission where you're sent to defend a station or carrier that is under attack?
I've meddled with ahrumans shader code quite a bit on this one so i hope i haven't broken it too much, it seems to work on my windows xp system.
Download here:-
http://www.box.net/shared/uuju6d5fji
the zip contains two oxp's for docking bay illumination, one of which has a pulsing red ambient light effect to give a "red alert!" feeling, might be fun to use on a mission where you're sent to defend a station or carrier that is under attack?
I've meddled with ahrumans shader code quite a bit on this one so i hope i haven't broken it too much, it seems to work on my windows xp system.
Download here:-
http://www.box.net/shared/uuju6d5fji
- Arexack_Heretic
- Dangerous Subversive Element
- Posts: 1876
- Joined: Tue Jun 07, 2005 7:32 pm
- Location: [%H] = Earth surface, Lattitude 52°10'58.19"N, longtitude 4°30'0.25"E.
- Contact:
I would rather have darkened dockingbays
(As I find the sunlight that shines through the station to illuminate the dock unreal)
with a few bright floodlights or red lights, etc, according to the atmosphere of the situation.
I may look at that pack as well and take some of your work.
(I just scripted a station with a devastated dock)
I already switched the green flashers to yellow and yellow ones to red. But a dark hole with some red lighting would be cool.
(As I find the sunlight that shines through the station to illuminate the dock unreal)
with a few bright floodlights or red lights, etc, according to the atmosphere of the situation.
I may look at that pack as well and take some of your work.
(I just scripted a station with a devastated dock)
I already switched the green flashers to yellow and yellow ones to red. But a dark hole with some red lighting would be cool.
Riding the Rocket!
- Griff
- Oolite 2 Art Director
- Posts: 2484
- Joined: Fri Jul 14, 2006 12:29 pm
- Location: Probably hugging his Air Fryer
Hi A_H
you can edit the level of lighting inside the docking bay by changing the brightness of the blue channel in the ambientmap texture
excuse the roughness of this image, it's a screen grab straight out of rendermonkey:-
i've just reduced the brightness of the blue channel all the way down to black to remove the ambient lighting, the red channel is providing the glows on the redlights at the back of the bay as well as the pools of light on the floor.
applying this shader to the bay removes the effect of the sunlight on the bay so you don't get that sometime odd effect of light passing through the hull to light the walls/floor etc
you can edit the level of lighting inside the docking bay by changing the brightness of the blue channel in the ambientmap texture
excuse the roughness of this image, it's a screen grab straight out of rendermonkey:-
i've just reduced the brightness of the blue channel all the way down to black to remove the ambient lighting, the red channel is providing the glows on the redlights at the back of the bay as well as the pools of light on the floor.
applying this shader to the bay removes the effect of the sunlight on the bay so you don't get that sometime odd effect of light passing through the hull to light the walls/floor etc
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
Yeah; the difference between 2 and 3 isn’t all that great, so the red channel won’t be doing much.Griff wrote:The only change to the fragment shader is this linewhich used to readCode: Select all
float specExponent = specMap.r + 2.0 + specMap.b * 200;
you can see it just adds in the blue channel (multiplied by 200) of the specMap texture to the specular effect.Code: Select all
float specExponent = specMap.r + 2.0;
The exponent is effectively an exponential scale of shininess; the difference between 32 and 64 is comparable to the difference between 4 and 8. If you multiply by a large factor, you get a lot of detail at the high end, but only unsubtle stops at the low end. The mathematically precise way to compensate this is to use something like pow(2.0, specMap.b * 8.0) (for a range of 0 to 2**8 = 256), but a computationally simpler way is to use a quadratic curve, 256.0 * specMap.b * specMap.b.
Incidentally, the reason I add 1 to the exponent in the Krait shaders is that 0 is a useless value; it just makes half the object glow.
E-mail: [email protected]
- Uncle Reno
- ---- E L I T E ----
- Posts: 648
- Joined: Mon Apr 24, 2006 12:54 pm
- Location: UK
Possibly it's just my system but that looks as if the metal has been eaten away and the highlight is some internal structure, having said that it does look good!Griff wrote:Edit: I've added another version of this shader that now allows you to use the previously unused blue channel in the specular map texture to add highly glossy areas to your object, notice the fuel leak now looks a lot more 'wet' as it's specular exponent has a much higher value than before.
"Get back or I unleash my lethal spotted batoid!!"
What I do when not reading the Oolite bulletin board!
What I do when not reading the Oolite bulletin board!
- Arexack_Heretic
- Dangerous Subversive Element
- Posts: 1876
- Joined: Tue Jun 07, 2005 7:32 pm
- Location: [%H] = Earth surface, Lattitude 52°10'58.19"N, longtitude 4°30'0.25"E.
- Contact: