Author Topic: Post-processing  (Read 60156 times)

0 Members and 1 Guest are viewing this topic.

Offline Aardwolf

  • 211
  • Posts: 16,384
    • Minecraft
Might this be useful for the Diaspora guys?

 

Offline pecenipicek

  • Roast Chicken
  • 211
  • Powered by copious amounts of coffee and nicotine
    • Minecraft
    • Skype
    • Steam
    • Twitter
    • PeceniPicek's own deviantart page



Down here is the code for the post-f.sdr
I took it from here and modified it a bit to work with the stuff that Hery put in. Also, note that it will be applied in every mission regardless of settings, if you dont use hery's mission. If you do use it, the effect dissappears when the other shaders kick in.

I know i'm a hack, however, i'm not pretending to know how to code, so i do the best i can and the best i know (in this case not much)...

Unfortunately, without a nice bright background, you're not gonna get it all that bright. it basically darkens the dark areas and brightens the bright ones.

Enjoy the hackBloom² shader :p
Code: [Select]
uniform sampler2D bgl_RenderedTexture;

#define FLAG_DISTORT_NOISE
#define FLAG_SATURATION
#define FLAG_CONTRAST

uniform sampler2D tex;

#ifdef FLAG_DISTORT_NOISE
uniform float timer;
uniform float noise_amount;
#endif

#ifdef FLAG_SATURATION
uniform float saturation;
#endif

#ifdef FLAG_CONTRAST
uniform float contrast;
#endif

void main()
{
vec4 sum = vec4(0);
   vec2 texcoord = vec2(gl_TexCoord[0]);
   int j;
   int i;
   vec4 color_glo;
for( i= -12 ;i < 8; i++)
   {
        for (j = -2; j < 5; j++)
        {
            sum += texture2D(bgl_RenderedTexture, texcoord + vec2(j, i)*0.004) * 0.25;
        }
   }
       if (texture2D(bgl_RenderedTexture, texcoord).r < 0.3)
    {
       color_glo = sum*sum*0.012 + texture2D(bgl_RenderedTexture, texcoord);
    }
    else
    {
        if (texture2D(bgl_RenderedTexture, texcoord).r < 0.5)
        {
            color_glo = sum*sum*0.012 + texture2D(bgl_RenderedTexture, texcoord);
        }
        else
        {
            color_glo = sum*sum*0.0125 + texture2D(bgl_RenderedTexture, texcoord);
        }
    }

#ifdef FLAG_DISTORT_NOISE
// Distort noise
float distort_factor = timer * sin(gl_TexCoord[0].x * gl_TexCoord[0].y * 100 + timer);
distort_factor = fmod(distort_factor, 8.0) * fmod(distort_factor, 4.0);

vec2 distort;
if (noise_amount > 0.0)
distort = vec2(fmod(distort_factor, noise_amount), fmod(distort_factor, noise_amount + 0.002));
else
distort = vec2(0, 0);
#else
vec2 distort = vec2(0, 0);
#endif

vec4 color_in = texture2D(tex, gl_TexCoord[0].xy + distort);

#ifdef FLAG_SATURATION
// Saturation
vec4 color_grayscale = dot(color_in, vec4(0.299, 0.587, 0.184, 0));
vec4 color_out = lerp(color_in, color_grayscale,  1 - saturation);
#else
vec4 color_out = color_in;
#endif

#ifdef FLAG_CONTRAST
// Contrast and brightness
vec3 Afactor = vec3(contrast, contrast, contrast);
vec3 Bfactor = vec3(0.5 - 0.5 * contrast, 0.5 - 0.5 * contrast, 0.5 - 0.5 * contrast);
color_out.rgb = color_out.rgb * Afactor + Bfactor;
#endif


// Dithering
//float downsampling_factor = 4;
//float bias = 0.5;
//color_out.rgb = floor(color_out.rgb * downsampling_factor + bias) / downsampling_factor;

gl_FragColor = color_out * color_glo;
}

Also a version without Hery's effects, pure bloom.
Code: [Select]
uniform sampler2D bgl_RenderedTexture;

void main()
{
vec4 sum = vec4(0);
   vec2 texcoord = vec2(gl_TexCoord[0]);
   int j;
   int i;
   vec4 color_glo;
for( i= -4 ;i < 4; i++)
   {
        for (j = -3; j < 3; j++)
        {
            sum += texture2D(bgl_RenderedTexture, texcoord + vec2(j, i)*0.004) * 0.25;
        }
   }
       if (texture2D(bgl_RenderedTexture, texcoord).r < 0.3)
    {
       color_glo = sum*sum*0.012 + texture2D(bgl_RenderedTexture, texcoord);
    }
    else
    {
        if (texture2D(bgl_RenderedTexture, texcoord).r < 0.5)
        {
            color_glo = sum*sum*0.012 + texture2D(bgl_RenderedTexture, texcoord);
        }
        else
        {
            color_glo = sum*sum*0.0125 + texture2D(bgl_RenderedTexture, texcoord);
        }
    }

gl_FragColor = color_glo;
}

« Last Edit: August 09, 2009, 09:38:03 pm by pecenipicek »
Skype: vrganjko
Ho, ho, ho, to the bottle I go
to heal my heart and drown my woe!
Rain may fall and wind may blow,
and many miles be still to go,
but under a tall tree I will lie!

The Apocalypse Project needs YOU! - recruiting info thread.

 

Offline Commander Zane

  • 212
  • Spoot Knight of Anvils
Well last time I remember looking at "bloomed" screenshots everything including the HUD was effected, this looks pretty good.

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Might this be useful for the Diaspora guys?

Why pick on us? As far as I can see this would be useful for everyone. :D
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline Zacam

  • Magnificent Bastard
  • Administrator
  • 211
  • I go Sledge-O-Matic on Spammers
    • Minecraft
    • Steam
    • Twitter
    • ModDB Feature
Could you imagine what, oh, Ransom could do with scripting or sexp triggering different shaders?

Hot damn.
Report MediaVP issues, now on the MediaVP Mantis! Read all about it Here!
Talk with the community on Discord
"If you can keep a level head in all this confusion, you just don't understand the situation"

¤[D+¬>

[08/01 16:53:11] <sigtau> EveningTea: I have decided that I am a 32-bit registerkin.  Pronouns are eax, ebx, ecx, edx.
[08/01 16:53:31] <EveningTea> dhauidahh
[08/01 16:53:32] <EveningTea> sak
[08/01 16:53:40] * EveningTea froths at the mouth
[08/01 16:53:40] <sigtau> i broke him, boys

 

Offline pecenipicek

  • Roast Chicken
  • 211
  • Powered by copious amounts of coffee and nicotine
    • Minecraft
    • Skype
    • Steam
    • Twitter
    • PeceniPicek's own deviantart page
Could you imagine what, oh, Ransom could do with scripting or sexp triggering different shaders?

Hot damn.
Hery did use events for his transitions. Its refreshing to see a new member appear with such shinies xD

[edit] modified my post before with the shader just for bloom.

Well last time I remember looking at "bloomed" screenshots everything including the HUD was effected, this looks pretty good.
if i remember correctly, that was an ati driver-based shader called HDR-ish, not comparable to this, since this is rendered directly in-engine.
« Last Edit: August 09, 2009, 10:03:45 pm by pecenipicek »
Skype: vrganjko
Ho, ho, ho, to the bottle I go
to heal my heart and drown my woe!
Rain may fall and wind may blow,
and many miles be still to go,
but under a tall tree I will lie!

The Apocalypse Project needs YOU! - recruiting info thread.

 

Offline Lt.Cannonfodder

  • 210
  • Digitalous Grunteous
Might this be useful for the Diaspora guys?
Give me slight desaturation, a bit of grain and just a touch of bloom and I'll be a happy dev.

 

Offline pecenipicek

  • Roast Chicken
  • 211
  • Powered by copious amounts of coffee and nicotine
    • Minecraft
    • Skype
    • Steam
    • Twitter
    • PeceniPicek's own deviantart page
by using the shader i have up there you could get just that. tweak the options a bit and you're set.
Skype: vrganjko
Ho, ho, ho, to the bottle I go
to heal my heart and drown my woe!
Rain may fall and wind may blow,
and many miles be still to go,
but under a tall tree I will lie!

The Apocalypse Project needs YOU! - recruiting info thread.

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Whoa. Could the masses get some screenshots of this?

 

Offline pecenipicek

  • Roast Chicken
  • 211
  • Powered by copious amounts of coffee and nicotine
    • Minecraft
    • Skype
    • Steam
    • Twitter
    • PeceniPicek's own deviantart page
as soon as i fix a showstopper bug... if there are enough bright things on screen, it simply blacks out. i'd wager that a buffer somewhere at a point decides to scream and says **** you.

also, disabling the hud while using the bloomy shader, results in the same effect. (this applies to all three postprocessing codes, Hery's, the mix of hery's and the bloomer, and the bloomer only)



also, hery's code seems ok, so its probably the additional framebuffer that kills the hud disableage. not 100% sure on this one, someone more experienced with OGL might want to check.
« Last Edit: August 10, 2009, 12:45:40 am by pecenipicek »
Skype: vrganjko
Ho, ho, ho, to the bottle I go
to heal my heart and drown my woe!
Rain may fall and wind may blow,
and many miles be still to go,
but under a tall tree I will lie!

The Apocalypse Project needs YOU! - recruiting info thread.

 

Offline Tolwyn

  • The Admiral
  • Administrator
  • 214
  • Ridiculously Old Fraud
    • Wing Commander Saga
For projects like SoL and Diaspora, a new rendering engine will probably be ready too late to be used in the release.

Probably?  :nervous:
Wing Commander Saga: A Legend Is Reborn | WingCenter
 
Tolwyn’s reputation for risk taking with other people’s lives was considered  to understate the facts. The admiral’s willingness to sacrifice anyone or anything to achieve his objectives had long been lauded in the popular press. He was “the man who got things done”.- Colonel Blair

No errors, no random CTDs, just pure fun and proof of why getting hit with missiles is a bad thing.
-WC Saga's beta tester


Report Wing Commander Saga bugs with Mantis

 

Offline pecenipicek

  • Roast Chicken
  • 211
  • Powered by copious amounts of coffee and nicotine
    • Minecraft
    • Skype
    • Steam
    • Twitter
    • PeceniPicek's own deviantart page
after extensive tracking and such, the bug is related to the additions enabling the post-processing switch and probably the extra code pertaining to the switch. i am currently looking for a way to implement the bloom into Hery's main shader "repack" :p



hacknslashhacknslashblaaargh..
Skype: vrganjko
Ho, ho, ho, to the bottle I go
to heal my heart and drown my woe!
Rain may fall and wind may blow,
and many miles be still to go,
but under a tall tree I will lie!

The Apocalypse Project needs YOU! - recruiting info thread.

 

Offline Hery

  • 26
@pecenipicek: I modified your code, so now it works even when "my" effects are on. Unfortunately, current shaders system is not prepared to configure post-processing shaders using GLSL preprocessor.

Code: [Select]
#define FLAG_BLOOM
#define FLAG_DISTORT_NOISE
#define FLAG_SATURATION
#define FLAG_CONTRAST

uniform sampler2D tex;

#ifdef FLAG_DISTORT_NOISE
uniform float timer;
uniform float noise_amount;
#endif

#ifdef FLAG_SATURATION
uniform float saturation;
#endif

#ifdef FLAG_CONTRAST
uniform float contrast;
#endif

void main()
{

#ifdef FLAG_DISTORT_NOISE
// Distort noise
float distort_factor = timer * sin(gl_TexCoord[0].x * gl_TexCoord[0].y * 100 + timer);
distort_factor = fmod(distort_factor, 8.0) * fmod(distort_factor, 4.0);

vec2 distort;
if (noise_amount > 0.0)
distort = vec2(fmod(distort_factor, noise_amount), fmod(distort_factor, noise_amount + 0.002));
else
distort = vec2(0, 0);
#else
vec2 distort = vec2(0, 0);
#endif

#ifdef FLAG_BLOOM
vec4 sum = vec4(0);
   vec2 texcoord = vec2(gl_TexCoord[0]) + distort;
   int j;
   int i;
   vec4 color_glo;
for( i= -12 ;i < 8; i++)
   {
        for (j = -2; j < 5; j++)
        {
            sum += texture2D(tex, texcoord + vec2(j, i)*0.004) * 0.25;
        }
   }
       if (texture2D(tex, texcoord).r < 0.3)
    {
       color_glo = sum*sum*0.012 + texture2D(tex, texcoord);
    }
    else
    {
        if (texture2D(tex, texcoord).r < 0.5)
        {
            color_glo = sum*sum*0.012 + texture2D(tex, texcoord);
        }
        else
        {
            color_glo = sum*sum*0.0125 + texture2D(tex, texcoord);
        }
    }
vec4 color_in = color_glo;

#else
vec4 color_in = texture2D(tex, gl_TexCoord[0].xy + distort);
#endif

#ifdef FLAG_SATURATION
// Saturation
vec4 color_grayscale = dot(color_in, vec4(0.299, 0.587, 0.184, 0));
vec4 color_out = lerp(color_in, color_grayscale,  1 - saturation);
#else
vec4 color_out = color_in;
#endif

#ifdef FLAG_CONTRAST
// Contrast and brightness
vec3 Afactor = vec3(contrast, contrast, contrast);
vec3 Bfactor = vec3(0.5 - 0.5 * contrast, 0.5 - 0.5 * contrast, 0.5 - 0.5 * contrast);
color_out.rgb = color_out.rgb * Afactor + Bfactor;
#endif

// Dithering
//float downsampling_factor = 4;
//float bias = 0.5;
//color_out.rgb = floor(color_out.rgb * downsampling_factor + bias) / downsampling_factor;

gl_FragColor = color_out;
}

I've also noticed that when for some reasons (file not found, compilation error) shaders are not enabled, post-processing uses fixed-pipeline and some problems appears (and in that case rendering to texture is pointless since there is no way to apply any effects to it). Despite the fact that behaviour is quite obvious, I forgot about it. Updated patch will be available soon :D

Update:
Problems when hud is disabled: solved. Keeping post processing enabled when impossible to use shaders: solved.
click
« Last Edit: August 10, 2009, 06:32:47 am by Hery »

 

Offline Nighteyes

  • 211
This looks excellent! great work! :D
cant wait to link it with capships explosions and the white "flash", turning up the contrast as well as the bloom effect for a few seconds :D
is there a way to implement this only when looking at something?

 

Offline Colonol Dekker

  • HLP is my mistress
  • 213
  • Aken Tigh Dekker- you've probably heard me
    • My old squad sub-domain
I'll test it on my notebook tomorrow. It has a slightly less powerful gfx chip (GF 9600M GT).

I think that should be around the lower mainstream class of gfx cards today. So pretty much the minimum for FS2 to run on decent quality settings.


I'm running on 2 8 series cards. Don't price me out of the upgrades yet. . .
Campaigns I've added my distinctiveness to-
- Blue Planet: Battle Captains
-Battle of Neptune
-Between the Ashes 2
-Blue planet: Age of Aquarius
-FOTG?
-Inferno R1
-Ribos: The aftermath / -Retreat from Deneb
-Sol: A History
-TBP EACW teaser
-Earth Brakiri war
-TBP Fortune Hunters (I think?)
-TBP Relic
-Trancsend (Possibly?)
-Uncharted Territory
-Vassagos Dirge
-War Machine
(Others lost to the mists of time and no discernible audit trail)

Your friendly Orestes tactical controller.

Secret bomb God.
That one time I got permabanned and got to read who was being bitxhy about me :p....
GO GO DEKKER RANGERSSSS!!!!!!!!!!!!!!!!!
President of the Scooby Doo Model Appreciation Society
The only good Zod is a dead Zod
NEWGROUNDS COMEDY GOLD, UPDATED DAILY
http://badges.steamprofile.com/profile/default/steam/76561198011784807.png

 

Offline chief1983

  • Still lacks a custom title
  • Moderator
  • 212
  • ⬇️⬆️⬅️⬅️🅰➡️⬇️
    • Minecraft
    • Skype
    • Steam
    • Twitter
    • Fate of the Galaxy
Has everyone doing any development related to this played HL2:  Lost Coast with the commentary on?  If not, do it MEOW.
Fate of the Galaxy - Now Hiring!  Apply within | Diaspora | SCP Home | Collada Importer for PCS2
Karajorma's 'How to report bugs' | Mantis
#freespace | #scp-swc | #diaspora | #SCP | #hard-light on EsperNet

"You may not sell or otherwise commercially exploit the source or things you created based on the source." -- Excerpt from FSO license, for reference

Nuclear1:  Jesus Christ zack you're a little too hamyurger for HLP right now...
iamzack:  i dont have hamynerge i just want ptatoc hips D:
redsniper:  Platonic hips?!
iamzack:  lays

 

Offline Hery

  • 26
Problem with cutscenes: solved.
click

@Nighteyes: since saturation, contrast and distort noise are enabled by sexps, and bloom will be enabled by sexps, I don't think there will be any problem to do that :D

 

Offline pecenipicek

  • Roast Chicken
  • 211
  • Powered by copious amounts of coffee and nicotine
    • Minecraft
    • Skype
    • Steam
    • Twitter
    • PeceniPicek's own deviantart page
ah, yes, hery, in your shaders, it'd be better to use mix() instead of lerp() since lerp is a CG command, not GLSL... same goes for fmod.


also, nice work :D
« Last Edit: August 10, 2009, 11:31:22 am by pecenipicek »
Skype: vrganjko
Ho, ho, ho, to the bottle I go
to heal my heart and drown my woe!
Rain may fall and wind may blow,
and many miles be still to go,
but under a tall tree I will lie!

The Apocalypse Project needs YOU! - recruiting info thread.

 

Offline Hery

  • 26
I started programming in GLSL a few days ago and Cg/HLSL habits still remain :P

 

Offline Ace

  • Truth of Babel
  • 212
    • http://www.lordofrigel.com
Might this be useful for the Diaspora guys?
Give me slight desaturation, a bit of grain and just a touch of bloom and I'll be a happy dev.

Contrast increase, not bloom, seems to be used more in the show. Anyway bloom is overused.
Ace
Self-plagiarism is style.
-Alfred Hitchcock