need a simple shader

Post your questions, suggestions and experiences regarding game design, integration of external libraries here. For irrEdit, irrXML and irrKlang, see the
ambiera forums
Post Reply
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

need a simple shader

Post by Acki »

hi,
I need a simple shader, but I have no experiences with shaders... :'(
I found many tutorials on the web, but I have no time (and pacience) to dig through tons od tutorial just for a single shader...

what I need is a shader that darkens/lightens the scene depending on a value...
maybe a value from 0 to 100 (0 = dark and 100 = bright)...
I want to create a day/night/dusk/dawn effect...

I guess this would be a post process shader, right ???
mainly I need it for dx, but one for ogl in addition would be great, too !!! ;)

also I'm not sure how to use post process shaders with Irrlicht, the shader tutorial only shows the use with scene nodes...
or do I simply have to set the shader to the camera node for this ???

I hope someone is so kind... :)

thx, Acki
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Lonesome Ducky
Competition winner
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Post by Lonesome Ducky »

With post processing, you would usually render the scene to a texture, then render to a screen aligned quad. This would allows the shader to change colors of the screen and so on.
Bate
Posts: 364
Joined: Sun Nov 01, 2009 11:39 pm
Location: Germany

Post by Bate »

That's how you could brighten a texture in GLSL. uniform float adjust is your callback var 1.0 means no change, a higher value brightens the texture up. Not exactly what you want, but maybe it helps. I'm still learning myself :)

// Vertex Shader

Code: Select all

varying vec2 tex_coord;

void main()
{
  gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
  tex_coord = vec2(gl_MultiTexCoord0);
}
// Frag Shader

Code: Select all

varying vec2 tex_coord;
uniform sampler2D tex_color;
uniform float adjust;

void main()
{
  gl_FragColor = texture2D(tex_color, tex_coord) * adjust;
}
Never take advice from someone who likes to give advice, so take my advice and don't take it.
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Lonesome Ducky wrote:With post processing, you would usually render the scene to a texture, then render to a screen aligned quad. This would allows the shader to change colors of the screen and so on.
ahh, I saw a tutorial of game studio shaders and they used the camera for the post processing directly... :lol:
well, in this case I'll have to overthink my strategy though... ;)
Bate wrote:1.0 means no change, a higher value brightens the texture up. Not exactly what you want, but maybe it helps.
that look pretty promissing !!! :)

now I have basics I can work/test with !!!
I guess I'll get the implementation to work now, at least for ogl (maybe I get it converted to dx on myself)... :lol:

thank you both, very much !!! :)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Post Reply