Shader Modding for GSB

Welcome to the shipyards. Here you can discuss how to re-calibrate the positronic neutron flow to double power to the aft shields. Or you can discuss how to add new ships, new maps, new scenarios, new modules, etc. have fun!
User avatar
cliffski
Positech Staff
Positech Staff
Posts: 6994
Joined: Sat Feb 11, 2006 10:27 am
Location: UK
Contact:

Shader Modding for GSB

Postby cliffski » Sun Aug 22, 2010 3:28 pm

If you check this folder:

gratuitous space battles\data\shaders

you will find the fx files which are the games shaders. You can open them and save them using notepad. You can edit these, and they change the way the game looks. Some should be left alone, but some are scenario specific. Take a look at the 'redden.fx' one, which is used by the gravity well scenario: (check the bg9.txt scenario file to see where it is specified)

Code: Select all

sampler2D g_samSrcColor;
   
float4 Redden( float2 Tex : TEXCOORD0 ) : COLOR0
{
    float4 Color;   
    Color = tex2D( g_samSrcColor, Tex.xy);
    Color.r = (Color.r * 1.4);
    Color.g = (Color.g * 0.6);
    Color.b = (Color.b * 0.6);
    return Color;
}

technique PostProcess
{
    pass p1
    {
        VertexShader = null;
        PixelShader = compile ps_2_0 Redden();
    }
}


the bit that matters is this:

Code: Select all

    Color = tex2D( g_samSrcColor, Tex.xy);
    Color.r = (Color.r * 1.4);
    Color.g = (Color.g * 0.6);
    Color.b = (Color.b * 0.6);


That makes everything in the game world slightly redder, before the UI gets drawn on top. If you change any of those valeus and re-run the scenario, you can see the difference.
You might notice the 'greyscale' effect in there. Try substituting that into a modded scenario. You can have lots of fun with this stuff. This is worth reading:
http://www.facewound.com/tutorials/shader1/
If you come up with some cool effects, post them here for others to try :D
User avatar
Archduke Astro
Positech Staff
Positech Staff
Posts: 1652
Joined: Sun Aug 30, 2009 10:09 pm
Location: Building The Future.

Re: Shader Modding for GSB

Postby Archduke Astro » Sun Aug 22, 2010 5:41 pm

Thank you, Cliffski.
.
•• Positech GLOBAL MODERATOR & Forum Sheriff ••
GSB "Combined-Arms Combat" Advocate & Analyst
Enemy of Crap-posting | Defender of Faction Diversity

∞∆……CURATOR OF CREATIVE CONCEPTS for GSB's Friendly Community Mod Squad……∆∞
User avatar
Dantalion
Research Director
Research Director
Posts: 226
Joined: Thu Nov 26, 2009 7:57 pm

Re: Shader Modding for GSB

Postby Dantalion » Mon Aug 30, 2010 12:55 am

Nobody's tried this yet?
Well, here's a distortion shader I cobbled together:

Code: Select all

sampler2D g_samSrcColor;


float4 Distort( float2 Tex : TEXCOORD0 ) : COLOR0
{
    float4 Color;
    Tex.y = Tex.y + (sin(Tex.x*100)*0.001);
    Tex.x = Tex.x + (sin(Tex.y*100)*0.001);
    Color = tex2D( g_samSrcColor, Tex.xy);
    return Color;
}


technique PostProcess
{
    pass p1
    {
        VertexShader = null;
        PixelShader = compile ps_2_0 Distort();
    }

}


This creates a slight distortion effect when things move across the screen vertically and horizontally or while panning the camera.
User avatar
Hybrinoid
Research Director
Research Director
Posts: 968
Joined: Sat Oct 03, 2009 3:44 am
Contact:

Re: Shader Modding for GSB

Postby Hybrinoid » Mon Aug 30, 2010 3:31 pm

Great work! I can already see that effect being in use for a scenario with an alien gravity-bending generator of some sort on the planet surface :)
My Gratuitous Youtube Channel
http://www.youtube.com/user/hybrinoid

Return to “Gratuitous Modding”

Who is online

Users browsing this forum: No registered users and 2 guests