Light Ghosting
uniform sampler2D bgl_RenderedTexture;
int samples = 8;
float gain = 0.5;
float spread = 0.03;
float threshold = 1.0;
int volumes = 4;
void main(void) {
vec3 screen = texture2D(bgl_RenderedTexture, gl_TexCoord[0].st).rgb;
vec2 deltacoord = (gl_TexCoord[0].st - vec2(0.5))*0.5;
vec2 texcoord = -gl_TexCoord[0].st+1.0;
float lum = 0.0;
for (int i = 0; i < volumes; ++i) {
texcoord += deltacoord;
for (int j = -samples; j < samples; ++j) {
vec2 newcoord = vec2(texcoord.x+(j*0.005), texcoord.y);
float col = texture2D(bgl_RenderedTexture, newcoord).r;
if (col >= threshold) {
lum += spread/samples;
} else {
lum += 0.0;
};
};
};
float white = dot(screen, vec3(0.299, 0.587, 0.114)).r;
float cval = ((0.5 - gl_TexCoord[0].x)*(0.5 - gl_TexCoord[0].x)) + ((0.5 - gl_TexCoord[0].y)*(0.5 - gl_TexCoord[0].y));
float root = sqrt(cval);
float stencil = max(lum , root/6);
stencil = stencil-(root/6);
gl_FragColor = vec4(screen+vec3(stencil*gain, stencil*gain, stencil*(gain*2)), 1.0);
}
Subscribe to:
Posts (Atom)
Hmm this script does not work on Blender 2.64a :/
ReplyDeleteIt works for me... Could you send me a screenshot of what the console says when you try running the script? Knowing your pc's specs would be useful as well, I can try and get it running for you then.
ReplyDeletesorry for the late reply :( My pc specs are: Intel Core 2 Quad q8400, 4gb ddr2 and 9800GT
ReplyDeleteHere is a screen shot
http://img12.imageshack.us/img12/4633/blender2012121112263361.png
sorry, here is a better image:
ReplyDeletehttp://img803.imageshack.us/img803/4633/blender2012121112263361.png
Are you trying to run the code as a python script? or perhaps just from the text editor?, it needs to be run through a 2D filter actuator. I can't think why the first line would return an error otherwise.
Deleteyes, that is what im doing, but it still doesnt work :/
DeleteCould you try checking the script in an empty .blend, if it's only happening in the 1 file then it's a problem with the file, otherwise all I can suggest is updating your graphics drivers, because to be honest I have no clue why the first line is throwing out an error for you.
ReplyDelete:D i got it working!!! thanks man!
ReplyDeletecan upload the script for motion blur?
ReplyDeleteI had a link from when someone asked before!! https://dl.dropbox.com/u/23307723/Motion_Blur.blend
DeleteHi. Could you include a finished .blend of the 2d filters together? They don't work for me, and I would like to check to see if I'm just doing it wrong.
ReplyDelete