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
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
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));
}
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...
well, is the same.
loadshader
setshader
this shaders are aplied to the texture images.
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:
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 (http://www.ludumdare.com/compo/ludum-dare-23/?action=preview&uid=2883)
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).
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
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 (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
Won't work. Mobile GL is eithet 1.1 w/o shaders or 2.0 where everything is a shader.