Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (577)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  GLSL 'dirty' blur effect  (Read 2869 times)
0 Members and 1 Guest are viewing this topic.
Offline roland
« Posted 2012-08-17 07:48:19 »

Hi, I would like to make a GLSL shader effect that changes this:

http://gyazo.com/48566da88d4c7afa139815a1e025d39d
to this:
http://gyazo.com/6ad524a32c200fa2a46ef1b9d1c19164

this was done using a very very strong motion blur which makes the game unplayable (moving the mouse distorts everything)

I have followed some GLSL shader tutorials and I understand the basics of using textures etc. I just can't figure out how to make this cool dirty, contrasted effect. I can make a blur effect, but it just makes you dizzy and doesn't look good at all. What I am aiming for is something that is still "sharp" but at the same time has this contrast and blur effect.

Can anyone give me some ideas?

Thanks,
roland
Offline princec

JGO Kernel


Medals: 404
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #1 - Posted 2012-08-17 09:06:01 »

Well, unless you know precisely what the effect is, no one's going to be able to come up with GLSL code that does it Smiley

Cas Smiley

Offline roland
« Reply #2 - Posted 2012-08-17 10:55:01 »

Thanks for the reply.

I have no idea what the effect is Grin I was hoping the 2 images helped. I'm not looking for code, just ideas on how I might solve the problem.

Roland
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #3 - Posted 2012-08-17 11:05:28 »

I'll be honest - I can't see any difference between those two pictures since they appear to be two different parts of a level. Perhaps you could come up with some better images or describe what you're after a little more?

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline roland
« Reply #4 - Posted 2012-08-17 11:55:23 »

Sorry, heres a better set:


http://gyazo.com/b68cfb0e86d77d2b5b5fe822800ac9d3


http://gyazo.com/6ad524a32c200fa2a46ef1b9d1c19164


I want to make a post processing effect (I have rendered the scene to a texture) that converts the first to the second.
Thanks,

roland
Offline davedes
« Reply #5 - Posted 2012-08-17 12:01:39 »

The still images look like adjustments to brightness/contrast/saturation. I posted some GLSL code on that recently, do a search.

Quote
this was done using a very very strong motion blur which makes the game unplayable (moving the mouse distorts everything)
I don't see how you expect us to know what the distortion effect looks like based on this description...

I'd say you should learn GLSL and how to achieve motion blurs. Then you can figure out the problem on your own... Smiley

Offline roland
« Reply #6 - Posted 2012-08-17 12:04:40 »

I know how to do motion blur. Its not the effect I want.

Heres what I mean by "distortion" that wrecks everything by using a very strong motion blur.
http://www.youtube.com/watch?v=7Fhs_SELfHc&list=UUyN3SzAPKMhGcip_Pt_jwFw&index=2&feature=plcp (only need to see the first 10 seconds)

I'm trying to get the effect without motion blur. Its not just contrast, pixels are also affected by neighbour pixel
Offline roland
« Reply #7 - Posted 2012-08-17 12:34:32 »

Thanks for the contrast sample davedes!  Smiley

I'm most of the way there now.

Heres what the contrast looks like at the moment: http://gyazo.com/a2931bac77bae3d8f083ec1a85739e59

Now I just need to put "glow" around the edges of objects  http://gyazo.com/6ad524a32c200fa2a46ef1b9d1c19164

Thanks again  Grin
Offline theagentd
« Reply #8 - Posted 2012-08-17 12:57:00 »

Isn't this just a blur along the direction of the mouse movement or something.

Myomyomyo.
Offline roland
« Reply #9 - Posted 2012-08-17 13:02:22 »

Isn't this just a blur along the direction of the mouse movement or something.
Yeah. Maybe I should just forget about trying to get the blur bit, even though it makes the edges look cool the rest doesn't look so good. I quite like just the contrast effect at the moment.


If anyone wants to use the contrast GLSL shader code, here it is:

vertex shader
1  
2  
3  
4  
void main(){
   gl_TexCoord[0] = gl_MultiTexCoord0;
   gl_Position = ftransform();
}


fragment shader
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
uniform sampler2D tex;

const float contrast = 1.6;
const float brightness = -0.2;

float contrastValue(float value)
{
   value = (value - 0.5) * contrast + 0.5;
   value += brightness;
   value = min(max(value, 0), 1);
   return value;
}


void main(){
   vec4 c = texture2D(tex,gl_TexCoord[0].st);
   
   c.r = contrastValue(c.r);
   c.g = contrastValue(c.g);
   c.b = contrastValue(c.b);
   gl_FragColor = c;
}



Thanks again everyone
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Danny02
« Reply #10 - Posted 2012-08-17 14:55:17 »

shortened that for you
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
uniform sampler2D tex;

const float contrast = 1.6;
const float brightness = 0.3;
const float factor = -0.5 * contrast + brightness;

void main(){
   vec4 c = texture2D(tex,gl_TexCoord[0].st);
   gl_FragColor = clamp(c * contrast + factor, 0., 1.);;
}
Offline roland
« Reply #11 - Posted 2012-08-18 03:55:08 »

shortened that for you
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
uniform sampler2D tex;

const float contrast = 1.6;
const float brightness = 0.3;
const float factor = -0.5 * contrast + brightness;

void main(){
   vec4 c = texture2D(tex,gl_TexCoord[0].st);
   gl_FragColor = clamp(c * contrast + factor, 0., 1.);;
}


Thanks Smiley
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (49 views)
2014-10-17 03:59:02

Norakomi (38 views)
2014-10-16 15:22:06

Norakomi (31 views)
2014-10-16 15:20:20

lcass (34 views)
2014-10-15 16:18:58

TehJavaDev (65 views)
2014-10-14 00:39:48

TehJavaDev (65 views)
2014-10-14 00:35:47

TehJavaDev (55 views)
2014-10-14 00:32:37

BurntPizza (72 views)
2014-10-11 23:24:42

BurntPizza (43 views)
2014-10-11 23:10:45

BurntPizza (84 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!