Shaders - Sepia, BLack & White

Previous topic - Next topic

kaotiklabs

Ive been playing a bit with shaders and 2D tints and managed to compile 2 of them.

I post it here in case it could be useful for anyone or even me in the future.

for sepia tint just use this

Code (glbasic) Select
uniform sampler2D image;

void main() {
vec3 texel = texture2D(image, gl_TexCoord[0].xy).rgb;
gl_FragColor = vec4(texel.x,texel.y,texel.z, 1.0);

gl_FragColor.r = dot(texel, vec3(.393, .769, .189));
gl_FragColor.g = dot(texel, vec3(.349, .686, .168));
gl_FragColor.b = dot(texel, vec3(.272, .534, .131));   
}


For a Black & white filter this one

Code (glbasic) Select
uniform sampler2D image;

void main() {
vec3 texel = texture2D(image, gl_TexCoord[0].xy).rgb;
gl_FragColor = vec4(texel.x,texel.y,texel.z, 1.0);

gl_FragColor = max(texel.r,max(texel.g,texel.b));
}
Vote Cthulhu! Because the stars are right!!!!
Ia Ia Cthulhu F' tang!

mentalthink

kaotics how use your code...

in 3d it´s whit X_Shader command but in 2D, how implement your code... I think it´s very interesting...

kaotiklabs

well, is the same.

loadshader
setshader

this shaders are aplied to the texture images.
Vote Cthulhu! Because the stars are right!!!!
Ia Ia Cthulhu F' tang!

mentalthink

Ok, thanks about your game in youtube... where I can take a look... I only watch the video whit hyper-Speed of the creation of the game... but i can´t found the gameplay video... :noggin:

kaotiklabs

Still not gameplay video, problems syncing the audio with fraps.

Eitherway, you can download it here!
http://www.ludumdare.com/compo/ludum-dare-23/?action=preview&uid=2883
Vote Cthulhu! Because the stars are right!!!!
Ia Ia Cthulhu F' tang!

r0ber7

Interesting. I've considered a day & night cycle for my game. Do you think this could be accomplished with a similar approach? Also, is this code cross-platform? (I think it is, since it looks like they're just GL functions, but just to be sure).

kaotiklabs

Im not a GL guru, so dont trust me too much but I believe is crossplatform because all the above layer is always opengl.

Theres a way to pass a variable to the shader so I believe that a day/night cycle kinda shader should be possible.

Let me know if any of you goes further as is a subject that really interest me too. :P
Vote Cthulhu! Because the stars are right!!!!
Ia Ia Cthulhu F' tang!

fuzzy70

From what I have read on the net & various OGL books I have Shaders where introduced as an extension to OGL 1.4 & built into the core from OGL 2.0 onwards. Obviously that relates to desktop machines like Windows/Mac/Linux & I have not found any solid info yet regarding mobile devices.

This site says http://www.ozone3d.net/tutorials/glsl_intro.php
QuoteAll the nVidia Geforce FX 5200 cards and higher or ATI Radeon 9600 cards and higher tolerate GLSL
, albeit it is a 2005 site but does give you a rough minimum of desktop hardware required. I have read & also witnessed some problems with Intel onboard gfx with regards to their OGL driver but cannot say which chipsets are effected or if they use a common driver like Nvidia or ATI.

I think it may just be a case of trying it on the devices that GLB supports & see what happens like all the different generation of iPhones/iPods, Cannoo, Palm etc. Android on the other hand may be a problem as unlike the former which has a known hardware base Android varies a lot.

Lee
"Why don't you just make ten louder and make ten be the top number and make that a little louder?"
- "These go to eleven."

This Is Spinal Tap (1984)

Kitty Hello

Won't work. Mobile GL is eithet 1.1 w/o shaders or 2.0 where everything is a shader.