Hi All,
I was trying to find a way to change the textures of an entity. There are some OXP's doing that. But when I look at wiki, I could not find any documentation such as Textures for the shipdata.plist. and also files with .fragmentation is not documented at all. Any help on that will be apreciated.
Thanks
Okti
wiki seems to be out of date on certain topics
Moderators: winston, another_commander
Re: wiki seems to be out of date on certain topics
This page on the wiki is useful on the subject.
One such OXP which makes use of this is my Butterflies demo OXP. That one uses this technique to change the texture colour, but you can also use it to change the whole texture diffusion map.
Fragmentation sounds like shader stuff - time for the Griff signal
One such OXP which makes use of this is my Butterflies demo OXP. That one uses this technique to change the texture colour, but you can also use it to change the whole texture diffusion map.
Fragmentation sounds like shader stuff - time for the Griff signal
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
- DaddyHoggy
- Intergalactic Spam Assassin
- Posts: 8515
- Joined: Tue Dec 05, 2006 9:43 pm
- Location: Newbury, UK
- Contact:
Re: wiki seems to be out of date on certain topics
Oolite Life is now revealed hereSelezen wrote:Apparently I was having a DaddyHoggy moment.
- Griff
- Oolite 2 Art Director
- Posts: 2483
- Joined: Fri Jul 14, 2006 12:29 pm
- Location: Probably hugging his Air Fryer
Re: wiki seems to be out of date on certain topics
@ the griff signal, doesn't look like a welsh sky though, not enough rain clouds, also needs more sheep
fragment & vertex shaders are written in GLSL http://en.wikipedia.org/wiki/GLSL (GLSL version 2.1 i think is what Oolite uses)
I don't really know much about the language but i can certainly write out how texture re-colouring is done in the shaders in my shipset if it's any help.
first in the shipdata.plist, we'll list the texture files, in this example a diffuse texture (or 'skin' texture) and a normal map
next, we need to send these textures to the fragment shader as an 'uniform' - we're going to call them UColorMap and uNormalMap, the bit to be careful of here is that you set the value numbers to the order they are listed earlier as 'Textures' - start numbering them at # 0
right, lets have a look at the fragment shader, in the first few lines we need to declare our uniforms, sampler2D is used when decalaring a 2d image, it's a Vec4 and the 4 components can be thought of as the RGBA channel values in a .png
I'm going to stop mentioning the normal map from here on in as it's just confusing me, i'll just concentrate on what happens to re-colour the uColorMap, first we'll use data from the vertex shader ("VTexCoord") to look up the particular uColourMap pixel we need for this polygon fragment and store it in a Vec4 called 'baseTex'
next, we'll use a greyscale image stored in the alpha channel of the normal map as a 'mask' to control the re-colouring (where the pixels in this mask image are dark there will be little re-colouring, where the pixels are light there will be the most re-colouring, we'll store the mask data in a floating point variable called 'PaintMap'
now we just multiply the mask by our paint colour -in this example a vec4(1.0, 0.5, 0.0, 1.0) which gives us a nice orange (the 4 numbers correspond to RGBA):
and add it into the baseTex
and that's it, our baseTex has now been tinted orange, let's send it on to the video buffer
and that's it! The fragment shader has now processed this particular polygon fragment and starts again on the next polygon fragment until they're all done, then it all starts again for the next frame
fragment & vertex shaders are written in GLSL http://en.wikipedia.org/wiki/GLSL (GLSL version 2.1 i think is what Oolite uses)
I don't really know much about the language but i can certainly write out how texture re-colouring is done in the shaders in my shipset if it's any help.
first in the shipdata.plist, we'll list the texture files, in this example a diffuse texture (or 'skin' texture) and a normal map
Code: Select all
textures =
(
"griff_adder_diffuse.png",
"griff_adder_normalmap.png"
);
Code: Select all
uniforms =
{
uColorMap = { type = texture; value = 0; };
uNormalMap = { type = texture; value = 1; };
};
Code: Select all
uniform sampler2D uColorMap;
uniform sampler2D uNormalMap;
Code: Select all
vec4 baseTex = texture2D(uColorMap, vTexCoord);
Code: Select all
float PaintMap = texture2D(uNormalMap, vTexCoord).a;
and add it into the baseTex
Code: Select all
baseTex += PaintMap * vec4(1.0, 0.5, 0.0, 1.0);
Code: Select all
gl_FragColor = vec4(baseTex);
Last edited by Griff on Sat Apr 09, 2011 9:56 pm, edited 1 time in total.
Wiki homepage for my OXP: http://wiki.alioth.net/index.php/Griff_Industries
- Okti
- ---- E L I T E ----
- Posts: 700
- Joined: Sun Sep 26, 2010 1:51 pm
- Location: A GH shop, near witchpoint to Oresrati in Galaxy 8
Re: wiki seems to be out of date on certain topics
Thanks for all the help,