Page 1 of 4

griff SpecGloss ships

Posted: Sun Jan 23, 2022 1:38 pm
by Griff
I'm hoping to try and make ships that use Oolite's new Spec/Gloss Material workflow, it's not gone that well so far but starting to make a little bit of progress getting my head around it all, as i complete ships i'll post them in this thread :)

A Description of the Improved Lighting and Materials System: https://bb.oolite.space/viewtopic.php?f=2&t=19881

Materials in Oolite: http://wiki.alioth.net/index.php/Materials_in_Oolite

Download
This link opens to a Google Drive folder (at the moment - Nov '23 - containing 7 different sub folders/ships)
https://drive.google.com/drive/folders/ ... sp=sharing

Ships in the folder:
Sidewinder - has a 'shader' version, see notes below as it's a bit different to the others
Mamba
Cobra Mk1
Gecko
Viper
Adder
Cobra Mk3

Getting the ships in game
For each ship you just need the zip with 'Materials' in the filename for gameplay, the sidewinder has an experimental custom shaders version, you only need that one or the materials version, not both.
Installing the ships: Unzip the download, put the folder with the name ending with .oxp in your Oolite AddOns folder

Modding
The Resources files in the folder with each ship aren't needed for gameplay, they're just for anyone who wants to pick apart and reuse the models (obj format) and textures from the ships in their own projects.

Brief guide to the Sidewinder subfolder as it's slightly different to the others:
griff_HP_Sidewinder_NPC_Materials.oxp.zip
Get this just for gameplay - NPC only ship. Uses Oolite's Materials system for shading. Unzip the download and place the oxp folder in Oolite's AddOns folder to install

griff_SpecGloss_Sidewinder_with_shaders_WIP.oxp.zip
Same ship as above, uses shaders to add some additional effects:animated engine glows, a set of different hull paint schemes, wear and tear effects linked to ship maintenance level

HP_Sidewinder_Modding_Resources
Optional downloads for any users interested in modifying the ship. This Download contains model files in obj format, clean versions of the texture maps etc. please mod and edit anything you like, I forgot to put the CC licencing in the uploads, hope it's OK to just post it here?

This work is licensed under the Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.

Sidewinder:
Image

Mamba
Image

Cobra Mk1:
Image
Image

Gecko
Image

Viper:
Image

Adder:
Image

Cobra Mk3:
Image

Re: griff SpecGloss ships

Posted: Sun Jan 23, 2022 1:49 pm
by Cody
You'll be wanting a new section added to your [EliteWiki] Griff Industries page, methinks.

Re: griff SpecGloss ships

Posted: Sun Jan 23, 2022 2:52 pm
by cbr
Image

Image

Can someone code an HP sidewinder raceleague
examples;
Racing around the stations planet
Racing a circuit near station / planet
Racing Witchpoint, Planet, Witchpoint

I pledge 16 raceteams :wink: :lol: 8)

Re: griff SpecGloss ships

Posted: Sun Jan 23, 2022 2:58 pm
by Griff
Awesome stuff cbr, you might want to grab the new modding resources download from the folder above, it's got some alternative texture maps for scuffed and clean versions as a jumping off point for further modding :D

Re: griff SpecGloss ships

Posted: Thu Jan 27, 2022 6:01 pm
by cbr
Image

One can make really clean highlights with the textures from the resource folder :D

Re: griff SpecGloss ships

Posted: Sun Sep 11, 2022 6:37 pm
by Griff
Had a go at making a shader version of this sidewinder with parts based on the shaders in the Oolite dev build

https://drive.google.com/file/d/1J3uzOu ... sp=sharing

I think most of it is working, I took the "diffuseOrenNayar", "FresnelSchlick" amd "CalcSpecularGGX" functions from the default shader and all the bits that call them in the main part of the shader, i hope i grabbed all the bits that were needed, was a bit complicated to spot the parts i needed :lol:

still got some stuff to do, might try and bring some of the weathering stuff for the player ship over from my old shaders so it starts getting chipped paint when it needs servicing.

the ship is a bit texture heavy too, will have a look at what can be downscaled then make an OXP manager version, but pleasd this is working, can be a good base for making some more of these

Re: griff SpecGloss ships

Posted: Sun Sep 11, 2022 7:43 pm
by Cholmondely
Links added into Sidewinder (Oolite) & Guide to Unlisted Oxp's (under Named Collections: Griff) wiki pages

Re: griff SpecGloss ships

Posted: Sun Sep 11, 2022 8:08 pm
by another_commander
Very nice use of materials. You totally got this Griff.

There is one small problem in the shaders with the effects map, though. The problem is that you are gamma correcting at the wrong place.

When a texture containing color information (e.g. diffuse, effects, specular etc.) is used, you want to gamma correct it immediately, before you use any of its values in any further calculation and the reason you want to do that is because the gamma correction will transfer its color values from the sRGB to the linear colorspace, which is where all shader calculations are meant to happen. So, in our case, right here where you first get the effects map

Code: Select all

// Get effects map
    vec4 effectsMap = texture2D(uEffectsMap, texCoord);
you must get it immediately to linear colorspace by adding this line just below:

Code: Select all

if (uGammaCorrect)  effectsMap.rgb = pow(effectsMap.rgb, vec3(OOSRGB_TO_LINEAR));
Once this has been done, you can use the effectsMap rgb values in your calculations knowing that everything will be handled correctly. For example, if you multiply the red value by 0.5, you can rest assured that the red component will be halved. Doing this calculation before the gamma correction, as you currently have it, will result in a red value component which is NOT half of the initial one. Not applying the gamma correction at the right place is why the blue tint of the engine glow looks so dark. Try applying my proposal and you will find that the result is probably closer to what you would expect.

Of course, you will have to completely remove these lines further down:

Code: Select all

/ apply colour correction to the glow
   if (uGammaCorrect) TotalGlow.rgb = pow(TotalGlow.rgb, vec3(OOSRGB_TO_LINEAR));   
We do correction only once and, in any case, applying the correction here is already too late - calculations have been made using the effectsMap colors already and the result is already wrong.

Visualisation: First pic is with the shader as it stands now. Second is with the effects correction applied at the right place.
Image
Image

Re: griff SpecGloss ships

Posted: Sun Sep 11, 2022 9:18 pm
by Griff
Thanks for checking the shader for bugs A_C, it's very much appreciated, i can't grasp a lot of the new code but i can clearly see from your example that i've got that color correction line wrong :lol: i'm using the alpha channel as well in the effects map to place the hull lights, will that channel need color correcting too? i'm not at my PC at the moment but i hope i can just push that through the same bit of code with the rgb channels :D

Hadn't noticed the front view had the gun so visible in it, i'll fix that too when i fix the shaders

Thanks for sorting out the Wiki links Cholmondely :D

Re: griff SpecGloss ships

Posted: Mon Sep 12, 2022 4:59 am
by another_commander
Griff wrote: Sun Sep 11, 2022 9:18 pm
i'm using the alpha channel as well in the effects map to place the hull lights, will that channel need color correcting too? i'm not at my PC at the moment but i hope i can just push that through the same bit of code with the rgb channels :D
Typically the alpha channel is not gamma corrected, but this is because it normally carries non-color related information (e.g. the gloss information is not color related, therefore not gamma corrected). Now, it could maybe be gamma corrected if you treat it strictly as a color channel, but the rule of thumb is that we leave it alone.

Edit: I noticed by the way that the diffuse map texture has the same issue (although I have to admit that the result looks good regardless). You get it in the shader, apply math with its rgb values and then correct it when it is already too late. You should gamma correct the texture color immediately after you import it in the shader for the first time and before you use it for any calculation.

Re: griff SpecGloss ships

Posted: Mon Sep 12, 2022 2:01 pm
by Cody
HP Cobra, HP Sidewinder - what's next, Griff? The Adder? Or perhaps the Python?

Re: griff SpecGloss ships

Posted: Tue Sep 13, 2022 7:36 am
by Griff
@cody - ha,i'm not sure what to try next, the sidewinder was supposed to be a quick project to try and work out how a texturing app called 'Substance painter' works, I tried it again quickly on the weekend to see about painting in the 'hull lights' and realised i'd totally forgotten everything about it :lol: so i think i'll try a smaller ship again, maybe a mamba or a shuttle if i can come up with a decent idea

@another_commander - if i immediately colour correct the diffuse texture as soon as i get it to do i need to colour correct the decal texture and the two paint colour vec3's before i mix them into the diffuse texture, or because the diffuse texture is now colour corrected then mixing in other non-colour corrected colours is fine as the base is colour corrected - or should they all be colour corrected first before mixing them together? had a bit of a tinker with it yesterday evening but got somethign wrong as the ship turned pure white!, think it was the hull light texture or something covering the whole ship made it easy to spot in game,was brighter than the system star :lol:

Re: griff SpecGloss ships

Posted: Tue Sep 13, 2022 8:18 am
by another_commander
Griff wrote: Tue Sep 13, 2022 7:36 am
@another_commander - if i immediately colour correct the diffuse texture as soon as i get it to do i need to colour correct the decal texture and the two paint colour vec3's before i mix them into the diffuse texture, or because the diffuse texture is now colour corrected then mixing in other non-colour corrected colours is fine as the base is colour corrected - or should they all be colour corrected first before mixing them together?
The decal texture should also be gamma corrected upon its introduction to the shader in the_decaliser function, indeed. With the diffuse, decal, specular and effects textures gamma corrected you are good to go. The vector arrays specifying the paintjob colors must not be gamma corrected.

The rule of thumb is: color textures should have their rgb channels gamma corrected. This includes diffuse, specular and effect textures. Alpha channels and normal maps (and textures containing data in general) are not gamma corrected. Normal maps in particular contain the information of the normals' angles, so it is critical that they do not get gamma corrected, because if you do that, then the data changes and all normals will end up appearing as pointing at irrelevant directions and your entire lighting will be destroyed.

Vectors and rgb triplets defined in your shaders, such as the paintjob data, are by definition already in linear color space so you do not need to do anything with them and your shader can go ahead and use them in calculations.

The even higher level rule of thumb is: all your shader calculations must be done in linear colorspace. Any vector or color values that you initialize in your shader are already in linear space and sRGB textures that are utilized must be converted to linear colorspace by means of gamma correction (raise them to the 2.2 power) first. This is the coder's responsibility. The end result is converted back to sRGB colorspace just before displaying to the monitor by reverting the process (i.e. raising the result to the 1.0/2.2 power) and that happens at the entire scene level and is the job of the oolite-final shader.

I hope this clears things up a bit, let me know if there are any more specific clarifications required. You can also have a look at the description of the new lighting system sticky in the discussion subforum and specifically this post: https://bb.oolite.space/viewtopic.ph ... 14#p264914

Re: griff SpecGloss ships

Posted: Thu Sep 15, 2022 12:31 pm
by Griff
I've updated the shaders to colour correct the diffuse & efects map textures and re-uploaded the test oxp (same link), i got the same washed out colour effect A_C has just posted to the screenshots thread when the shader got to the lines where it mixed in new paint colors - think this might have been because when i was choosing those colours the shader was not in linear colour space? , not sure of the proper fix so have hacked it for now by getting the calculator out and colour correcting those paint array vec3's then copying them back to the shader code :)

Re: griff SpecGloss ships

Posted: Fri Sep 16, 2022 12:41 am
by Commander_X
Great looking Sidewinder, but not for milk runners :mrgreen:

Some observations before getting it out of WIP status:
- in Config/shipdata.plist:

Code: Select all

                fragment_shader = "griff_HP_Sidewinder_Player.fragment";
- in the Shaders folder:
(filename is)

Code: Select all

griff_HP_Sidewinder_PLAYER.fragment
The two strings are not "portable" for macOS and Linux filesystems (that is, the shader file won't be found due to a different file name)