Page 3 of 14

Posted: Thu Mar 22, 2007 1:37 pm
by Selezen
Hmm... Chitin plates. I like that. I'll give that a whirl...

Posted: Thu Mar 22, 2007 2:02 pm
by JensAyton
Since we’re talking about chitin and stuff, I should probably point out that the next Windows release (like the 1.67 Mac releases) will support pixel shaders. When I get home I’ll post the freaky-thargoids demo OXP somewhere for reference. I’ll try to throw together a specular map example, too.

Posted: Thu Mar 22, 2007 2:24 pm
by Killer Wolf
i have no idea how pixel shaders and such like actually work - is it just a case of the oxp having a texture map, a bump map etc etc all packaged in together and the code knowing what to do w/ it?

Posted: Thu Mar 22, 2007 2:53 pm
by JensAyton
Nope, in the current implementation you must code the shader in GLSL… or copy and paste from someone else.

A simpler approach – where you specify a number of effect maps, and Oolite builds an appropriate shader, scaling down complexity to what the hardware can handle if necessary – is on my “things I’d like to do” list. It comes after “Operation Major Surgery”, and isn’t likely to materialize for at least several months. When/if it does, existing custom shaders will continue to work.

Posted: Thu Mar 22, 2007 3:04 pm
by Star Gazer
ooooooo... ....starting to shows signs of uncontrollable twitching and drooling in anticipation...

Posted: Thu Mar 22, 2007 4:57 pm
by JensAyton
I’ve posted the Freaky Thargoids OXP to the wiki. I’m working on an overview of fragment shaders as they apply to Oolite.

Posted: Thu Mar 22, 2007 5:48 pm
by JensAyton
Overview thingy done (with a terse explanation of the Freaky Thargoids shader code). In the process, I found (via Wikipedia) an article on normal mapping for artists, which might be considered somewhat depressing since (I believe) the current shader implementation is not usable for that form of normal mapping, but it begins with a good description of how lighting in 3D works, which should help understand how smoothing currently works in Oolite.

I’m actually about to modify the way shader loading works, in a way that breaks compatibility; the current version of freaky-thargoids, or anything based on it, will not use shaders in future releases. However, modifying it to work will be easy, so if you want to start playing with shaders, don’t let this put you off.

Posted: Thu Mar 22, 2007 7:31 pm
by Killer Wolf

Posted: Thu Mar 22, 2007 8:06 pm
by Arexack_Heretic
I wasn't aware it already worked ingame. this is great.
edit: Ah I see from the next (1.67) release it will work.

Also if I understand correctly, what the code does is replacing a given texture file for the described shader version?
ie Giles mentioned the Thargorn looked pretty freaky, BECAUSE it used the standard in-game thargoid.png.
This could mean one could suffice with defining a shader once in a shipdata....(but also that it would be advisable to copy-rename textures if creating custom shayders based on standard textures)
Or just define a fictitious texture to be 'replaced'.

Don't forget the PPC25.oxp which utilises shayders coupled to engine-level.
PPC25:

Code: Select all

<key>shaders</key>
		<dict>
			<key>pccv25hull.png</key><!-- replace this texture -->
			<dict>
				<key>textures</key>
				<array>
					<string>pccv25hull.png</string><!-- passed as tex0 -->
					<string>pccv25-hullg.png</string><!-- passed as tex1 -->
					<string>pccv25-hulleg.png</string><!-- passed as tex2 -->
				</array>
				<key>glsl</key><!-- fragment shader code - adds tex1 as a glowmap and tex2 as an engine level glow -->
				<string>
				uniform sampler2D tex0;
				uniform sampler2D tex1;
				uniform sampler2D tex2;
								
				uniform float engine_level;
								
				void main()
				{
					vec4 base =		texture2D(tex0, gl_TexCoord[0].st);
					vec4 glow1 =	texture2D(tex1, gl_TexCoord[0].st);
					vec4 glow2 =	texture2D(tex2, gl_TexCoord[0].st);
					gl_FragColor = gl_Color * base + glow1 * glow1.a + glow2 * glow2.a * engine_level;
				}
				</string>
			</dict>
			<key>pccv25engine.png</key><!-- replace this texture -->
			<dict>
				<key>textures</key>
				<array>
					<string>pccv25engine.png</string><!-- passed as tex0 -->
					<string>pccv25-engineeg.png</string><!-- passed as tex1 -->
				</array>
				<key>glsl</key><!-- fragment shader code - adds tex1 as an engine level glow -->
				<string>
				uniform sampler2D tex0;
				uniform sampler2D tex1;
								
				uniform float engine_level;
								
				void main()
				{
					vec4 base =		texture2D(tex0, gl_TexCoord[0].st);
					vec4 glow2 =	texture2D(tex1, gl_TexCoord[0].st);
					gl_FragColor = gl_Color * base + glow2 * glow2.a * engine_level;
				}
				</string>
			</dict>

Posted: Thu Mar 22, 2007 8:46 pm
by JensAyton
I was mistaken. The modifications I needed to make have been completed without breaking backwards compatibility. Future versions of Oolite will be able to use shaders embedded in shipdata.plist or in an external file (which should be more efficient when using the same shader for multiple ships, although this is not yet the case).

I’ve updated freaky-thargoids to support lighting. (The previous one essentially had two glow maps mixed together, rather than a colour map + glow map.) This version also uses vertex shaders.
Arexack_Heretic wrote:
Don't forget the PPC25.oxp which utilises shayders coupled to engine-level.
Really? Where can I find that?

Posted: Thu Mar 22, 2007 8:51 pm
by JensAyton
Arexack_Heretic wrote:
Also if I understand correctly, what the code does is replacing a given texture file for the described shader version?
ie Giles mentioned the Thargorn looked pretty freaky, BECAUSE it used the standard in-game thargoid.png.
A shader replaces a texture for a specific ship. It doesn’t replace every use of a given texture. Oh, and there’s no “y” in “shader”. :-)

Posted: Thu Mar 22, 2007 8:52 pm
by Arexack_Heretic
ppc25.

not on oosat(2)?
I'll upload it from my HDD if it needs replacing.
uploading now...
hmm...no longer instantaneous.
Where did the wrex teaser v1.2 go BTW? There's only an old version posted by LB there. I'm sure I updated it not too long ago....:(



It is one of the last works of Giles.
(Famous last works) ;)

Shayders: yes, i know you pedantic...:p it is a personal joke. I misheard Giles the first time I saw his shader-movie.

If the shaders are entry specific, then he must have spliced the freaky-texture-code into my shipdata.

Posted: Thu Mar 22, 2007 9:41 pm
by JensAyton
Hmm… perhaps they’re not. They’re just specified on a per-ship basis to confuse people.

This is part of a complex set of issues that needs dealing with (I believe I’ve alluded to it before…) I reccomend not relying on this behaviour.

Posted: Thu Mar 22, 2007 10:23 pm
by Arexack_Heretic
Do uploads to OOsat2 now need special clearance from someone?
I uploaded PPC25 and wrex_teaser1.2, but cannot see them. (nor do the pictures work. strange)

edit:
I updated the wiki as well.

Posted: Thu Mar 22, 2007 10:33 pm
by Uncle Reno
Yes, Oosat2 uploads need to be approved by Winston. The idea is that we migrate over to the Wiki but I'm encountering a file size limit at the moment.