TylerH Posted January 2, 2010 Share Posted January 2, 2010 Who can deny it? The current saturation, brightness, and contrast post effects just are lacking. They seem to basically play with the brightness, period. So I searched online, and found an existing S.B.C. function written in GLSL. I went ahead and replaced the setup in postfilter.frag to utilize this function, and I now get much better results when using the Saturation, Brightness, and Contrast sliders. They just seem to give me the right "feel" of appearance for the values. Brightness of 2.0 looks twice as bright, not twice as gray/washed out, etc. Below is a drop in replacement for postfilter.frag: varying vec4 fragcolor; varying vec4 fragcoord; //========================================== //Textures //========================================== uniform sampler2D texture0; //color uniform sampler2D texture1; //depth uniform sampler2D texture2; //normal uniform sampler2D texture3; //blurred bloom buffer uniform sampler2D texture4; //unblurred bloom buffer uniform sampler2D texture5; //caustics frame 1 uniform sampler2D texture6; //blurred DOF texture uniform sampler2D texture7; //wobble texture / caustics frame 2 uniform sampler2D texture10; //noise texture for effects uniform sampler2D texture11; //ssao texture uniform float contrast = 1.0; uniform float brightness = 1.0; uniform float saturation = 1.0; //========================================== //Automatic uniforms //========================================== uniform float apptime; uniform vec2 buffersize; uniform vec2 camerarange; uniform float camerazoom; include "depthtozposition.frag" //========================================== //HDR uniforms //========================================== uniform float hdrexposure; //========================================== // Fog variables //========================================== uniform vec4 fogcolor = vec4(1.0); uniform vec2 fogrange = vec2(0.1,1000.0); //========================================== // DOF variables //========================================== uniform vec2 dofnearrange; uniform vec2 doffarrange; uniform float dofstrength=1.0; //========================================== // Caustics variables //========================================== uniform vec4 causticsmappingaxes[4]; uniform float causticsframeinterpolation; uniform vec4 causticscolor; //========================================== // Volumetric light scattering variables //========================================== #ifdef LW_GODRAYS uniform vec3 screenlightpos; uniform vec3 lightvector; uniform vec4 raycolor = vec4(1.0); //uniform float exposure = 0.35; #define exposure 1.0 #define RAYSAMPLES 64 #define MAXRAYLENGTH 1.0 #endif //========================================== // Motion blur variables //========================================== uniform vec2 motionblurvector; uniform float motionblurstrength = 1.0; uniform float motionblurdistance; //========================================== // SSAO Functions //========================================== #ifdef LW_SSAO float ao=0; #define aointensitybias -0.55 #define ssaostrength 1.0 float readDepth( in vec2 coord ) { //#ifndef __GLSL_CG_DATA_TYPES // coord.y = 1.0 - coord.y; //#endif return (2.0 * camerarange.x) / (camerarange.y + camerarange.x - texture2D( texture1, coord ).x * (camerarange.y - camerarange.x)) * camerarange.y; } float compareDepths( in float depth1, in float depth2 ) { float aoCap = 1.0; float aoMultiplier=10.0; float depthTolerance=0.000; float aorange = 100.0;///(camerarange.y-camerarange.x);// units in space the AO effect extends to (this gets divided by the camera far range float diff = ( clamp(1.0-(depth1-depth2) / aorange,0.0,1.0) ); float ao = min(aoCap,max(0.0,depth1-depth2-depthTolerance)) * diff; ao *= aoMultiplier; ao=clamp(ao,0.0,1.0); return ao; } #endif vec3 ContrastSaturationBrightness(vec3 color, float brt, float sat, float con) { // Increase or decrease theese values to adjust r, g and b color channels seperately const float AvgLumR = 0.5; const float AvgLumG = 0.5; const float AvgLumB = 0.5; const vec3 LumCoeff = vec3(0.2125, 0.7154, 0.0721); vec3 AvgLumin = vec3(AvgLumR, AvgLumG, AvgLumB); vec3 brtColor = color * brt; vec3 intensity = vec3(dot(brtColor, LumCoeff)); vec3 satColor = mix(intensity, brtColor, sat); vec3 conColor = mix(AvgLumin, satColor, con); return conColor; } //========================================== // Main //========================================== void main( void ) { //========================================== //General variables //========================================== vec2 texcoord = gl_FragCoord.xy/buffersize; vec4 color; float depth; float lineardepth; vec3 normal; vec4 cnormal; vec4 outputcolor; vec2 pixelsize = 1.0/buffersize; float irisadjustment=1.0; float bloomstrength = 1.0; float bloomirisadjustment=2.0; #ifdef LW_WOBBLE Include "wobble.frag" #endif color = texture2D( texture0, texcoord ) * fragcolor; depth = texture2D( texture1, texcoord ).x; cnormal=texture2D( texture2, texcoord ); normal = cnormal.xyz * 2.0 - 1.0; lineardepth = DepthToZPosition( depth ); outputcolor = color; float pixelbrightness = outputcolor.r * 0.3 + outputcolor.g * 0.59 + outputcolor.b * 0.11; //========================================== // Now include the effects we want //========================================== #ifdef LW_HDR include "hdr.frag" #endif #ifdef LW_CAUSTICS include "caustics.frag" #endif #ifdef LW_MOTIONBLUR include "MotionBlur.frag" #endif #ifdef LW_BRIGHTEN outputcolor = max( outputcolor, texture2D(texture4,texcoord).w * texture2D(texture5,texcoord) ); #endif #ifdef LW_NEARDOF Include "neardof.frag" #endif #ifdef LW_FARDOF Include "fardof.frag" #endif #ifdef LW_GODRAYS Include "godrays.frag" #endif #ifdef LW_SSAO float gray = outputcolor.r * 0.3 + outputcolor.g * 0.59 + outputcolor.b * 0.11; vec4 ssaocolor = texture2D(texture11,texcoord); ao = ssaocolor.x; outputcolor.rgb = mix(outputcolor.rgb*ao,outputcolor.rgb,gray+aointensitybias); //outputcolor.x = outputcolor.rgb*0.5; //outputcolor.x += ssaocolor.x * 0.75; //outputcolor.y += ssaocolor.y * 0.75; //outputcolor.z += ssaocolor.z * 0.75; //outputcolor = vec4(ao); //outputcolor=ssaocolor; #endif #ifdef LW_DISTANCEFOG Include "fog.frag" #endif #ifdef LW_BLOOM Include "bloom.frag" #endif #ifdef LW_GAUSSIAN Include "gaussian.frag" #endif //#ifdef LW_BRIGHTNESS //Include "brightness.frag" //#endif //#ifdef LW_CONTRAST //Include "contrast.frag" //#endif //#ifdef LW_SATURATION //Include "saturation.frag" //#endif outputcolor.rgb = ContrastSaturationBrightness(outputcolor.rgb,brightness,saturation,contrast); //========================================== // Set the fragment color to the output variable //========================================== gl_FragColor = outputcolor; gl_FragDepth = depth; } 1 Quote nVidia 530M Intel Core i7 - 2.3Ghz 8GB DDR3 RAM Windows 7 Ultimate (64x)----- Visual Studio 2010 Ultimate Google Chrome Creative Suite 5 FL Studio 10 Office 15 ----- Expert Professional Expert BMX Programmer ----- Link to comment Share on other sites More sharing options...
Pixel Perfect Posted January 2, 2010 Share Posted January 2, 2010 Sounds great. Can't wait to try this Tyler. Thanks Quote Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++ Link to comment Share on other sites More sharing options...
L B Posted January 4, 2010 Share Posted January 4, 2010 Screenshots? Comparison? I'm too lazy to change it without knowing there will be a noticeable difference. 2 2 Quote Link to comment Share on other sites More sharing options...
L B Posted January 4, 2010 Share Posted January 4, 2010 People seem to love downrating my comments and profile. 2 1 Quote Link to comment Share on other sites More sharing options...
wailingmonkey Posted January 4, 2010 Share Posted January 4, 2010 I didn't 'down-rate' you (don't ever really check those things nor think they mean much), but come on: Below is a drop in replacement for postfilter.frag you can't take the time to do that, why should he?...or move on and save your comments for yourself. (doing the above quote would have taken less time than me commenting now ) 1 Quote Vista Ultimate SP1 64bit | Q6600 2.40 GHZ | 8GB RAM | 320MB Nvidia 8800GTS Link to comment Share on other sites More sharing options...
L B Posted January 4, 2010 Share Posted January 4, 2010 Did it, tested, saw no difference at all (I took 2 screenshots). Hence why I asked for a preview. 1 1 Quote Link to comment Share on other sites More sharing options...
wailingmonkey Posted January 4, 2010 Share Posted January 4, 2010 ergo, not exactly what you said at first, is it? anyhow, not trying to demonize you....just get tired of seeing people put stuff up for free and of their own sweat and then have those that reap the rewards barely manage to either put forth some of their own effort to try it, or at the very least say a bit of 'thanks'... apologies for derailing, TylerH. 1 Quote Vista Ultimate SP1 64bit | Q6600 2.40 GHZ | 8GB RAM | 320MB Nvidia 8800GTS Link to comment Share on other sites More sharing options...
Josh Posted January 4, 2010 Share Posted January 4, 2010 Why do people not like you? I like you. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
L B Posted January 4, 2010 Share Posted January 4, 2010 Why do people not like you? I like you. Heh thanks. Should sig it, although I already have 2 good ones. It'll be the next one ergo, not exactly what you said at first, is it?anyhow, not trying to demonize you....just get tired of seeing people put stuff up for free and of their own sweat and then have those that reap the rewards barely manage to either put forth some of their own effort to try it, or at the very least say a bit of 'thanks'... apologies for derailing, TylerH. You're right, sorry. Thanks for taking some of your time Tyler, although I see no difference at all. 1 Quote Link to comment Share on other sites More sharing options...
TylerH Posted January 5, 2010 Author Share Posted January 5, 2010 I will do some comparison shots in a moment here, assuming I don't get sidetracked. Quote nVidia 530M Intel Core i7 - 2.3Ghz 8GB DDR3 RAM Windows 7 Ultimate (64x)----- Visual Studio 2010 Ultimate Google Chrome Creative Suite 5 FL Studio 10 Office 15 ----- Expert Professional Expert BMX Programmer ----- Link to comment Share on other sites More sharing options...
Michael Betke Posted January 6, 2010 Share Posted January 6, 2010 I tested it yesterday and don't see a difference too. Maybe it depends on which TFT you look at the scene. Quote Pure3d Visualizations Germany - digital essences AAA 3D Model Shop specialized on nature and environments Link to comment Share on other sites More sharing options...
Marleys Ghost Posted January 9, 2010 Share Posted January 9, 2010 I will do some comparison shots in a moment here, assuming I don't get sidetracked. Did you get sidetracked? Quote AMD Bulldozer FX-4 Quad Core 4100 Black Edition 2 x 4GB DDR3 1333Mhz Memory Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5 Windows 7 Home 64 bit BlitzMax 1.50 • Lua 5.1 • MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro 3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET LE 2.5/3.4 • Skyline • UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0 Marleys Ghost's YouTube Channel • Marleys Ghost's Blog "I used to be alive like you .... then I took an arrow to the head" Link to comment Share on other sites More sharing options...
TylerH Posted February 13, 2010 Author Share Posted February 13, 2010 Yeah, I got sidetracked by life, for approximately 2-3 months. Quote nVidia 530M Intel Core i7 - 2.3Ghz 8GB DDR3 RAM Windows 7 Ultimate (64x)----- Visual Studio 2010 Ultimate Google Chrome Creative Suite 5 FL Studio 10 Office 15 ----- Expert Professional Expert BMX Programmer ----- Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.