-
8 hours agoLars Berg likes Prototyping Processes for Industrial Designers -
11 days agoLars Berg commented on realtime depth of field 2No problem, here is the fragment shader. This is still pretty rough and i'm sure it can be optimized.
I'd like to explore QC a bit more i really like the node based interface.
uniform sampler2D sampler0;
const int NUM_SAMPLES = 10 ;
const int NUM_ROT = 9 ;
uniform sampler2D tex, depthTex;
void main(){
vec4 color, sampCol, d;
d = texture2D(depthTex, gl_TexCoord[1].st);
color = texture2D(tex, gl_TexCoord[0].st);
float step = 360.0/float(NUM_ROT);
float sampCount = 1.0;
float blurDist = float(NUM_SAMPLES) * 1.85 * d.z/float(NUM_SAMPLES);
for(int i=0; i < NUM_ROT; i++){
vec2 offset = vec2( sin(step * float(i))/1280.0, cos(step * float(i))/720.0);
for ( int j=1; j< int(float(NUM_SAMPLES + 1) * d.z); j++)
{
vec2 texCoord = gl_TexCoord[0].st + offset*float(j) * blurDist;
vec4 depthSamp = texture2D(depthTex, texCoord);
sampCol = texture2D(sampler0, texCoord);
float tempVal = min(d.z, depthSamp.z);
tempVal *= 1.0 - pow(float(j)/float(NUM_SAMPLES), 4.0);
color += sampCol * tempVal;
sampCount += tempVal;
}
}
color /= sampCount;
gl_FragColor = vec4(vec3(color), 1.0);
}
let me know if you have any suggestions/questions.
LB -
12 days agoLars Berg tagged eels study with: -
12 days agoLars Berg uploaded eels study -
14 days agoLars Berg likes Graffiti Analysis 2.0 (Digital Blackbook) - BLK River (Vienna)
See all 51 videos His recent videos
-
eels study
12 days ago -
realtime depth of field 2
17 days ago -
candy particles
20 days ago
-
Vimeo: About / Blog / Developers / Jobs / Community Guidelines / Community Forums / Help Center / Site Map / Merchandise
/ Get Vimeo
