×Video encoding is running slowly right now. You can keep uploading, but it may be awhile before it converts. We apologize for the inconvenience!
Lars Berg
Oakland, CA
thelablab.com
He has not updated the profile yet.

Recent activity

  • like
  • Video comment
    11 days ago
    Lars Berg commented on realtime depth of field 2

    No 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

  • add_tags
    12 days ago
    Lars Berg tagged eels study with:
  • upload
    12 days ago
    Lars Berg uploaded eels study
  • like

Advertisement

Contacts