Random shaders....

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
Post Reply
devsh
Competition winner
Posts: 2049
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK
Contact:

Random shaders....

Post by devsh »

I did them in 25mins when i was bored

Blood is cool (post process)

leaves 0.0 for sure
Image

leaves 0.001 guramteed
Image

It is still being worked on, the wishlist includes:

1) perspective (blood splats far away go down slower)
2) feed in decal data (position) so pixels too far away are not processed
3) take camera rotation into account when defining the Y/down vector

Code: Select all

// simple fragment shader

// 'time' contains seconds since the program was linked.
uniform sampler2D tex;
uniform sampler2D tex2;
uniform sampler2D normalm;
uniform int currentframe;
uniform vec4 color;

void main()
{
	float CF = 1.0/(currentframe*2.0-1.0);/*
	if (currentframe==2) CF = 0.5;
	else if (currentframe==3) CF = 0.33333;*/
	float thickness = texture2D(tex,gl_TexCoord[0].xy).r*CF;
	float temp_thick;
    int i;
	vec3 textureNM = texture2D(normalm,gl_TexCoord[0].xy).xyz;
	vec2 normal = (vec2(textureNM.x,abs(textureNM.z+textureNM.x))-0.5)/128.0;
	vec2 texcoord = gl_TexCoord[0].xy;
	for (i=0; i<currentframe; i++) {
		texcoord -= normal;
		temp_thick = texture2D(tex,texcoord).r;
		thickness += temp_thick*i*CF;
		//normal = (texture2D(normalm,texcoord).xz-0.5)/256.0;
		if (texcoord.y<0.0||(normal.x==0.0&&normal.y==0.0)) break;
	}
	gl_FragColor = mix(texture2D(tex2,gl_TexCoord[0].xy),color,min(1.0,thickness));
}
this is an expensive shader... the longer the animation the slower it is (sort of raytracing)

glass shader with faked reflections or a double refraction (simulate double glaze) as you might call it ++ lighting

Image

I SHALL POST THE CODE SOON
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

I wanna see that blood shader in action!

I'm curious about the Shader Maker program. Did you make that or...
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Sylence
Posts: 725
Joined: Sat Mar 03, 2007 9:01 pm
Location: Germany
Contact:

Post by Sylence »

Software documentation is like sex. If it's good you want more. If it's bad it's better than nothing.
devsh
Competition winner
Posts: 2049
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK
Contact:

Post by devsh »

the concept of blood was taken from an nvidia paper... the method is less memory hogging but more crude... also done inverse...
lulzfish
Posts: 34
Joined: Sat Aug 15, 2009 8:19 pm

Post by lulzfish »

AAAAAAAAAAAARGH
Resize your screenshots plz. I didn't buy a 1920 by 1200 monitor so I could take the whole thing up with Firefox.
Is the somber dream of the Grim Reaper a shade Darker Than Black?
Post Reply