Thanks for that Griff.
I have had a go at incorporating this however the damage texture still didn't work and also the normal map details disappear when in direct sunlight
I'm going to get the Fireball OXP issued tomorrow and then I intend to concentrate on getting to grips with shaders.
I'm going to start the Elite style ship hopefully Wednesday and produce the how to apply shaders guide as I progress.
A request for a simple example of using shaders
Moderators: winston, another_commander
- Shipbuilder
- ---- E L I T E ----
- Posts: 877
- Joined: Thu May 10, 2012 9:41 pm
- Location: Derby
Re: A request for a simple example of using shaders
The GalTech Industries Corporation - Building ships to populate the galaxies.
Increase the variety of ships within your Ooniverse by downloading my OXPs
Flying the [wiki]Serpent_Class_Cruiser[/wiki] "Thargoid's Bane"
Increase the variety of ships within your Ooniverse by downloading my OXPs
Flying the [wiki]Serpent_Class_Cruiser[/wiki] "Thargoid's Bane"
- Griff
- Oolite 2 Art Director
- Posts: 2483
- Joined: Fri Jul 14, 2006 12:29 pm
- Location: Probably hugging his Air Fryer
Re: A request for a simple example of using shaders
re: damage texture not working - is this on a player ship? if i remember correctly you have to calculate energy levels differently for a player ship, the uniforms that send the relevant energy levels data from oolite to the shader are in a different format for players than they are for NPC ships, i remember being stuck on this for a while then someone (possibly Frame or Svengali) posed up a few lines of code to get it working, i'll have a dig through my shipset shaders to find the particular lines you need.
edit:
ok, i think this is the code you need for the damage glow texture on a player ship,
in your players ship in shipdata.plist, in the shaders\uniforms section write:
in your players ship fragment shader, have
then further down in the 'void main(void)' section of your shader have this code
so now we've got a new floating point number called DamageAmount (note: case sensitive) that we can use as an opacity setting for mixing in your damage texture
If you want the texture drawn at full opacity when the ship is full of energy and gradually have it fade out as the ship energy level falls then subtract DamageAmount from 1.0 and use that result as the opacity level at least i think that'll work i haven't tested it! - you could do that to your Lights texture map so they fade as the ship gets more and more beaten up and the energy banks start draining
edit:
ok, i think this is the code you need for the damage glow texture on a player ship,
in your players ship in shipdata.plist, in the shaders\uniforms section write:
Code: Select all
damage_amount = "damage";
Code: Select all
uniform int damage_amount;
Code: Select all
// Damage Calculator
float tempvar = float(damage_amount);
float DamageAmount = mod(tempvar, 100.0) / 100.0;
Code: Select all
finalColor += IlluminationMap2 * DamageAmount;
Code: Select all
finalColor += IlluminationMap2 * (1.0 - DamageAmount);
Wiki homepage for my OXP: http://wiki.alioth.net/index.php/Griff_Industries
- Shipbuilder
- ---- E L I T E ----
- Posts: 877
- Joined: Thu May 10, 2012 9:41 pm
- Location: Derby
Re: A request for a simple example of using shaders
Griff - Thanks for the info regarding the damaged texture for player ships I'll give it a go this week and let you know how I get on.
The GalTech Industries Corporation - Building ships to populate the galaxies.
Increase the variety of ships within your Ooniverse by downloading my OXPs
Flying the [wiki]Serpent_Class_Cruiser[/wiki] "Thargoid's Bane"
Increase the variety of ships within your Ooniverse by downloading my OXPs
Flying the [wiki]Serpent_Class_Cruiser[/wiki] "Thargoid's Bane"
- Shipbuilder
- ---- E L I T E ----
- Posts: 877
- Joined: Thu May 10, 2012 9:41 pm
- Location: Derby
Re: A request for a simple example of using shaders
I am getting close to being in a position where I should be able to release the first version of my How to use shaders guide that I have been putting together. I'm currently reading through the first draft to try to spot any errors
I also plan to release a number of resource packs to accompany the guide.
Does anyone know if this should be released with a licence or should I simply provide a download link/Wiki page ?
I also plan to release a number of resource packs to accompany the guide.
Does anyone know if this should be released with a licence or should I simply provide a download link/Wiki page ?
The GalTech Industries Corporation - Building ships to populate the galaxies.
Increase the variety of ships within your Ooniverse by downloading my OXPs
Flying the [wiki]Serpent_Class_Cruiser[/wiki] "Thargoid's Bane"
Increase the variety of ships within your Ooniverse by downloading my OXPs
Flying the [wiki]Serpent_Class_Cruiser[/wiki] "Thargoid's Bane"
Re: A request for a simple example of using shaders
If you're intending that people be able to play around with the code samples and perhaps incorporate bits into their own work, then it's much clearer to have a license. There are basically two options for this:Shipbuilder wrote:Does anyone know if this should be released with a licence or should I simply provide a download link/Wiki page ?
1) Pick a license that you personally approve of to encourage more OXPs to be released under that license (picking anything other than CC-BY-NC-SA 3.0 at this point is likely to mean very few people use your code, of course, since that's probably the most common OXP license)
2) Pick a very permissive license like the MIT license (if you want to be formal) or a "do what you want with this" statement (if you want to be informal) so that people can use it in any project they like.
- Diziet Sma
- ---- E L I T E ----
- Posts: 6312
- Joined: Mon Apr 06, 2009 12:20 pm
- Location: Aboard the Pitviper S.E. "Blackwidow"
Re: A request for a simple example of using shaders
Further to the above, I'd like to see the guide itself made available as a wiki reference page, a PDF and a forum thread..Shipbuilder wrote:I am getting close to being in a position where I should be able to release the first version of my How to use shaders guide that I have been putting together. I'm currently reading through the first draft to try to spot any errors
I also plan to release a number of resource packs to accompany the guide.
Does anyone know if this should be released with a licence or should I simply provide a download link/Wiki page ?
Most games have some sort of paddling-pool-and-water-wings beginning to ease you in: Oolite takes the rather more Darwinian approach of heaving you straight into the ocean, often with a brick or two in your pockets for luck. ~ Disembodied
- Shipbuilder
- ---- E L I T E ----
- Posts: 877
- Joined: Thu May 10, 2012 9:41 pm
- Location: Derby
Re: A request for a simple example of using shaders
This is exactly what I have planned.Diziet Sma wrote:Further to the above, I'd like to see the guide itself made available as a wiki reference page, a PDF and a forum thread..Shipbuilder wrote:I am getting close to being in a position where I should be able to release the first version of my How to use shaders guide that I have been putting together. I'm currently reading through the first draft to try to spot any errors
I also plan to release a number of resource packs to accompany the guide.
Does anyone know if this should be released with a licence or should I simply provide a download link/Wiki page ?
The GalTech Industries Corporation - Building ships to populate the galaxies.
Increase the variety of ships within your Ooniverse by downloading my OXPs
Flying the [wiki]Serpent_Class_Cruiser[/wiki] "Thargoid's Bane"
Increase the variety of ships within your Ooniverse by downloading my OXPs
Flying the [wiki]Serpent_Class_Cruiser[/wiki] "Thargoid's Bane"