Jump to content

SSAO and GI maybe ?


franck22000
 Share

Recommended Posts

Hello everyone i found an interesting shader that handle, SSAO and Global Illumination, i tried with my very basic knowledge to get it working in LW Engine but no luck at the moment.

 

Maybe someone can help us with that, and maybe this shader can give some ideas to someone, so i post it here. I hope i will be usefull...

 

 

gssao3.jpg

 

 

Here is the post on the gamedev forums: http://www.gamedev.net/community/forums/topic.asp?topic_id=556187&PageSize=25&WhichPage=1

 

Here is the GLSL Source code:

 

uniform sampler2D gnormals;
uniform sampler2D gdepth;
uniform sampler2D gdiffuse;
uniform sampler2D grandom;

vec3 readNormal(in vec2 coord)  
{  
    return normalize(texture2D(gnormals, coord).xyz*2.0  - 1.0);  
}

vec3 posFromDepth(vec2 coord){
    float d = texture2D(gdepth, coord).r;
    vec3 tray = mat3x3(gl_ProjectionMatrixInverse)*vec3((coord.x-0.5)*2.0,(coord.y-0.5)*2.0,1.0);
    return tray*d;
}
   //Ambient Occlusion form factor:
   float aoFF(in vec3 ddiff,in vec3 cnorm, in float c1, in float c2){
         vec3 vv = normalize(ddiff);
         float rd = length(ddiff);
         return (1.0-clamp(dot(readNormal(gl_TexCoord[0]+vec2(c1,c2)),-vv),0.0,1.0)) *
          clamp(dot( cnorm,vv ),0.0,1.0)* 
                (1.0 - 1.0/sqrt(1.0/(rd*rd) + 1.0));
   }
   //GI form factor:
   float giFF(in vec3 ddiff,in vec3 cnorm, in float c1, in float c2){
         vec3 vv = normalize(ddiff);
         float rd = length(ddiff);
         return 1.0*clamp(dot(readNormal(gl_TexCoord[0]+vec2(c1,c2)),-vv),0.0,1.0)*
                    clamp(dot( cnorm,vv ),0.0,1.0)/
                    (rd*rd+1.0);  
   }

void main()
{
   //read current normal,position and color.
   vec3 n = readNormal(gl_TexCoord[0].st);
   vec3 p = posFromDepth(gl_TexCoord[0].st);
   vec3 col = texture2D(gdiffuse, gl_TexCoord[0]).rgb;

   //randomization texture
   vec2 fres = vec2(800.0/128.0*5,600.0/128.0*5);
   vec3 random = texture2D(grandom, gl_TexCoord[0].st*fres.xy);
   random = random*2.0-vec3(1.0);

   //initialize variables:
   float ao = 0.0;
   vec3 gi = vec3(0.0,0.0,0.0);
   float incx = 1.0/800.0*0.1;
   float incy = 1.0/600.0*0.1;
   float pw = incx;
   float ph = incy;
   float cdepth = texture2D(gdepth, gl_TexCoord[0]).r;

   //3 rounds of 8 samples each. 
   for(float i=0.0; i<3.0; ++i) 
   {
      float npw = (pw+0.0007*random.x)/cdepth;
      float nph = (ph+0.0007*random.y)/cdepth;

      vec3 ddiff = posFromDepth(gl_TexCoord[0].st+vec2(npw,nph))-p;
      vec3 ddiff2 = posFromDepth(gl_TexCoord[0].st+vec2(npw,-nph))-p;
      vec3 ddiff3 = posFromDepth(gl_TexCoord[0].st+vec2(-npw,nph))-p;
      vec3 ddiff4 = posFromDepth(gl_TexCoord[0].st+vec2(-npw,-nph))-p;
      vec3 ddiff5 = posFromDepth(gl_TexCoord[0].st+vec2(0,nph))-p;
      vec3 ddiff6 = posFromDepth(gl_TexCoord[0].st+vec2(0,-nph))-p;
      vec3 ddiff7 = posFromDepth(gl_TexCoord[0].st+vec2(npw,0))-p;
      vec3 ddiff8 = posFromDepth(gl_TexCoord[0].st+vec2(-npw,0))-p;

      ao+=  aoFF(ddiff,n,npw,nph);
      ao+=  aoFF(ddiff2,n,npw,-nph);
      ao+=  aoFF(ddiff3,n,-npw,nph);
      ao+=  aoFF(ddiff4,n,-npw,-nph);
      ao+=  aoFF(ddiff5,n,0,nph);
      ao+=  aoFF(ddiff6,n,0,-nph);
      ao+=  aoFF(ddiff7,n,npw,0);
      ao+=  aoFF(ddiff8,n,-npw,0);

      gi+=  giFF(ddiff,n,npw,nph)*texture2D(gdiffuse, gl_TexCoord[0]+vec2(npw,nph)).rgb;
      gi+=  giFF(ddiff2,n,npw,-nph)*texture2D(gdiffuse, gl_TexCoord[0]+vec2(npw,-nph)).rgb;
      gi+=  giFF(ddiff3,n,-npw,nph)*texture2D(gdiffuse, gl_TexCoord[0]+vec2(-npw,nph)).rgb;
      gi+=  giFF(ddiff4,n,-npw,-nph)*texture2D(gdiffuse, gl_TexCoord[0]+vec2(-npw,-nph)).rgb;
      gi+=  giFF(ddiff5,n,0,nph)*texture2D(gdiffuse, gl_TexCoord[0]+vec2(0,nph)).rgb;
      gi+=  giFF(ddiff6,n,0,-nph)*texture2D(gdiffuse, gl_TexCoord[0]+vec2(0,-nph)).rgb;
      gi+=  giFF(ddiff7,n,npw,0)*texture2D(gdiffuse, gl_TexCoord[0]+vec2(npw,0)).rgb;
      gi+=  giFF(ddiff8,n,-npw,0)*texture2D(gdiffuse, gl_TexCoord[0]+vec2(-npw,0)).rgb;

      //increase sampling area:
      pw += incx;  
      ph += incy;    
   } 
   ao/=24.0;
   gi/=24.0;


   gl_FragColor = vec4(col-vec3(ao)+gi*5.0,1.0);
}

 

 

 

Have fun, or not....

You guys are going to be the death of me. Josh
Link to comment
Share on other sites

Won't compile for me:

Error: Failed to compile fragment shader object.
0(24) : error C7011: implicit cast from "vec4" to "vec2"
0(32) : error C7011: implicit cast from "vec4" to "vec2"
0(42) : error C7011: implicit cast from "vec4" to "vec2"
0(46) : error C7011: implicit cast from "vec4" to "vec3"
0(56) : error C7011: implicit cast from "vec4" to "vec2"
0(82) : error C7011: implicit cast from "vec4" to "vec2"
0(83) : error C7011: implicit cast from "vec4" to "vec2"
0(84) : error C7011: implicit cast from "vec4" to "vec2"
0(85) : error C7011: implicit cast from "vec4" to "vec2"
0(86) : error C7011: implicit cast from "vec4" to "vec2"
0(87) : error C7011: implicit cast from "vec4" to "vec2"
0(88) : error C7011: implicit cast from "vec4" to "vec2"
0(89) : error C7011: implicit cast from "vec4" to "vec2"
Source:
#version 120
#define LW_MAX_PASS_SIZE 1024
#define LW_INSTANCED
#define LW_SM4 
uniform sampler2D texture2;
uniform sampler2D texture1;
uniform sampler2D texture0;
uniform sampler2D texture10;
vec3 readNormal(in vec2 coord)  
{  
    return normalize(texture2D(texture2, coord).xyz*2.0  - 1.0);  
}
vec3 posFromDepth(vec2 coord){
    float d = texture2D(texture1, coord).r;
    vec3 tray = mat3x3(gl_ProjectionMatrixInverse)*vec3((coord.x-0.5)*2.0,(coord.y-0.5)*2.0,1.0);
    return tray*d;
}
   //Ambient Occlusion form factor:
   float aoFF(in vec3 ddiff,in vec3 cnorm, in float c1, in float c2){
         vec3 vv = normalize(ddiff);
         float rd = length(ddiff);
         return (1.0-clamp(dot(readNormal(gl_TexCoord[0]+vec2(c1,c2)),-vv),0.0,1.0)) *
          clamp(dot( cnorm,vv ),0.0,1.0)* 
                (1.0 - 1.0/sqrt(1.0/(rd*rd) + 1.0));
   }
   //GI form factor:
   float giFF(in vec3 ddiff,in vec3 cnorm, in float c1, in float c2){
         vec3 vv = normalize(ddiff);
         float rd = length(ddiff);
         return 1.0*clamp(dot(readNormal(gl_TexCoord[0]+vec2(c1,c2)),-vv),0.0,1.0)*
                    clamp(dot( cnorm,vv ),0.0,1.0)/
                    (rd*rd+1.0);  
   }
void main()
{
   //read current normal,position and color.
   vec3 n = readNormal(gl_TexCoord[0].st);
   vec3 p = posFromDepth(gl_TexCoord[0].st);
   vec3 col = texture2D(texture0, gl_TexCoord[0]).rgb;
   //randomization texture
   vec2 fres = vec2(800.0/128.0*5,600.0/128.0*5);
   vec3 random = texture2D(texture10, gl_TexCoord[0].st*fres.xy);
   random = random*2.0-vec3(1.0);
   //initialize variables:
   float ao = 0.0;
   vec3 gi = vec3(0.0,0.0,0.0);
   float incx = 1.0/800.0*0.1;
   float incy = 1.0/600.0*0.1;
   float pw = incx;
   float ph = incy;
   float cdepth = texture2D(texture1, gl_TexCoord[0]).r;
   //3 rounds of 8 samples each. 
   for(float i=0.0; i<3.0; ++i) 
   {
      float npw = (pw+0.0007*random.x)/cdepth;
      float nph = (ph+0.0007*random.y)/cdepth;
      vec3 ddiff = posFromDepth(gl_TexCoord[0].st+vec2(npw,nph))-p;
      vec3 ddiff2 = posFromDepth(gl_TexCoord[0].st+vec2(npw,-nph))-p;
      vec3 ddiff3 = posFromDepth(gl_TexCoord[0].st+vec2(-npw,nph))-p;
      vec3 ddiff4 = posFromDepth(gl_TexCoord[0].st+vec2(-npw,-nph))-p;
      vec3 ddiff5 = posFromDepth(gl_TexCoord[0].st+vec2(0,nph))-p;
      vec3 ddiff6 = posFromDepth(gl_TexCoord[0].st+vec2(0,-nph))-p;
      vec3 ddiff7 = posFromDepth(gl_TexCoord[0].st+vec2(npw,0))-p;
      vec3 ddiff8 = posFromDepth(gl_TexCoord[0].st+vec2(-npw,0))-p;
      ao+=  aoFF(ddiff,n,npw,nph);
      ao+=  aoFF(ddiff2,n,npw,-nph);
      ao+=  aoFF(ddiff3,n,-npw,nph);
      ao+=  aoFF(ddiff4,n,-npw,-nph);
      ao+=  aoFF(ddiff5,n,0,nph);
      ao+=  aoFF(ddiff6,n,0,-nph);
      ao+=  aoFF(ddiff7,n,npw,0);
      ao+=  aoFF(ddiff8,n,-npw,0);
      gi+=  giFF(ddiff,n,npw,nph)*texture2D(texture0, gl_TexCoord[0]+vec2(npw,nph)).rgb;
      gi+=  giFF(ddiff2,n,npw,-nph)*texture2D(texture0, gl_TexCoord[0]+vec2(npw,-nph)).rgb;
      gi+=  giFF(ddiff3,n,-npw,nph)*texture2D(texture0, gl_TexCoord[0]+vec2(-npw,nph)).rgb;
      gi+=  giFF(ddiff4,n,-npw,-nph)*texture2D(texture0, gl_TexCoord[0]+vec2(-npw,-nph)).rgb;
exture2D(texture0, gl_TexCoord[0]+vec2(-npw,-nph)).rgb;
      gi+=  giFF(ddiff5,n,0,nph)*texture2D(texture0, gl_TexCoord[0]+vec2(0,nph)).rgb;
      gi+=  giFF(ddiff6,n,0,-nph)*texture2D(texture0, gl_TexCoord[0]+vec2(0,-nph)).rgb;
      gi+=  giFF(ddiff7,n,npw,0)*texture2D(texture0, gl_TexCoord[0]+vec2(npw,0)).rgb;
      gi+=  giFF(ddiff8,n,-npw,0)*texture2D(texture0, gl_TexCoord[0]+vec2(-npw,0)).rgb;

      //increase sampling area:
      pw += incx;  
      ph += incy;    
   } 
   ao/=24.0;
   gi/=24.0;


   gl_FragColor = vec4(col-vec3(ao)+gi*5.0,1.0);
}

      gi+=  giFF(ddiff5,n,0,nph)*texture2D(texture0, gl_TexCoord[0]+vec2(0,nph)).rgb;
      gi+=  giFF(ddiff6,n,0,-nph)*texture2D(texture0, gl_TexCoord[0]+vec2(0,-nph)).rgb;
      gi+=  giFF(ddiff7,n,npw,0)*texture2D(texture0, gl_TexCoord[0]+vec2(npw,0)).rgb;
      gi+=  giFF(ddiff8,n,-npw,0)*texture2D(texture0, gl_TexCoord[0]+vec2(-npw,0)).rgb;
      //increase sampling area:
      pw += incx;  
      ph += incy;    
   } 
   ao/=24.0;
   gi/=24.0;
   gl_FragColor = vec4(col-vec3(ao)+gi*5.0,1.0);
}

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Why those compile errors ?

Because he wrote it wrong.

 

Here's the closest I can get to working. It clearly is not outputting anything useful yet:

uniform sampler2D texture0;//color
uniform sampler2D texture1;//depth
uniform sampler2D texture2;//normal
uniform sampler2D texture10;//noise

uniform vec2 camerarange;
uniform vec2 buffersize;

include "abstract::depthtozposition.frag"

vec3 readNormal(in vec2 coord)  
{  
    return normalize(texture2D(texture2, coord).xyz*2.0  - 1.0);  
}

vec3 posFromDepth(vec2 coord){
    float d = texture2D(texture1, coord.xy).r;
 d=DepthToZPosition(d);
    vec3 tray = mat3x3(gl_ProjectionMatrixInverse)*vec3((coord.x-0.5)*2.0,(coord.y-0.5)*2.0,1.0);
    return tray*d;
}
   //Ambient Occlusion form factor:
   float aoFF(in vec3 ddiff,in vec3 cnorm, in float c1, in float c2, in vec2 coord){
         vec3 vv = normalize(ddiff);
         float rd = length(ddiff);
         return (1.0-clamp(dot(readNormal(coord.xy+vec2(c1,c2)),-vv),0.0,1.0)) *
          clamp(dot( cnorm,vv ),0.0,1.0)* 
                (1.0 - 1.0/sqrt(1.0/(rd*rd) + 1.0));
   }
   //GI form factor:
   float giFF(in vec3 ddiff,in vec3 cnorm, in float c1, in float c2, in vec2 coord){
         vec3 vv = normalize(ddiff);
         float rd = length(ddiff);
         return 1.0*clamp(dot(readNormal(coord.xy+vec2(c1,c2)),-vv),0.0,1.0)*
                    clamp(dot( cnorm,vv ),0.0,1.0)/
                    (rd*rd+1.0);  
   }

void main()
{

vec2 texcoord = gl_FragCoord.xy/buffersize;

   //read current normal,position and color.
   vec3 n = readNormal(texcoord.st);
   vec3 p = posFromDepth(texcoord.st);
   vec3 col = vec3(1);//texture2D(texture0, texcoord.xy).rgb;

   //randomization texture
   vec2 fres = vec2(800.0/128.0*5,600.0/128.0*5);
   vec3 random = texture2D(texture10, texcoord.st*fres.xy).xyz;
   random = random*2.0-vec3(1.0);

   //initialize variables:
   float ao = 0.0;
   vec3 gi = vec3(0.0,0.0,0.0);
   float incx = 1.0/buffersize.x*0.1;
   float incy = 1.0/buffersize.y*0.1;
   float pw = incx;
   float ph = incy;
   float cdepth = DepthToZPosition(texture2D(texture1, texcoord.xy).r);

   //3 rounds of 8 samples each. 
   for(float i=0.0; i<3.0; ++i) 
   {
      float npw = (pw+0.0007*random.x)/cdepth;
      float nph = (ph+0.0007*random.y)/cdepth;

      vec3 ddiff = posFromDepth(texcoord.st+vec2(npw,nph))-p;
      vec3 ddiff2 = posFromDepth(texcoord.st+vec2(npw,-nph))-p;
      vec3 ddiff3 = posFromDepth(texcoord.st+vec2(-npw,nph))-p;
      vec3 ddiff4 = posFromDepth(texcoord.st+vec2(-npw,-nph))-p;
      vec3 ddiff5 = posFromDepth(texcoord.st+vec2(0,nph))-p;
      vec3 ddiff6 = posFromDepth(texcoord.st+vec2(0,-nph))-p;
      vec3 ddiff7 = posFromDepth(texcoord.st+vec2(npw,0))-p;
      vec3 ddiff8 = posFromDepth(texcoord.st+vec2(-npw,0))-p;

      ao+=  aoFF(ddiff,n,npw,nph,texcoord);
      ao+=  aoFF(ddiff2,n,npw,-nph,texcoord);
      ao+=  aoFF(ddiff3,n,-npw,nph,texcoord);
      ao+=  aoFF(ddiff4,n,-npw,-nph,texcoord);
      ao+=  aoFF(ddiff5,n,0,nph,texcoord);
      ao+=  aoFF(ddiff6,n,0,-nph,texcoord);
      ao+=  aoFF(ddiff7,n,npw,0,texcoord);
      ao+=  aoFF(ddiff8,n,-npw,0,texcoord);
/*
      gi+=  giFF(ddiff,n,npw,nph,texcoord)*texture2D(texture0, texcoord.xy+vec2(npw,nph)).rgb;
      gi+=  giFF(ddiff2,n,npw,-nph,texcoord)*texture2D(texture0, texcoord.xy+vec2(npw,-nph)).rgb;
      gi+=  giFF(ddiff3,n,-npw,nph,texcoord)*texture2D(texture0, texcoord.xy+vec2(-npw,nph)).rgb;
      gi+=  giFF(ddiff4,n,-npw,-nph,texcoord)*texture2D(texture0, texcoord.xy+vec2(-npw,-nph)).rgb;
      gi+=  giFF(ddiff5,n,0,nph,texcoord)*texture2D(texture0, texcoord.xy+vec2(0,nph)).rgb;
      gi+=  giFF(ddiff6,n,0,-nph,texcoord)*texture2D(texture0, texcoord.xy+vec2(0,-nph)).rgb;
      gi+=  giFF(ddiff7,n,npw,0,texcoord)*texture2D(texture0, texcoord.xy+vec2(npw,0)).rgb;
      gi+=  giFF(ddiff8,n,-npw,0,texcoord)*texture2D(texture0, texcoord.xy+vec2(-npw,0)).rgb;
*/

      gi+=  giFF(ddiff,n,npw,nph,texcoord);
      gi+=  giFF(ddiff2,n,npw,-nph,texcoord);
      gi+=  giFF(ddiff3,n,-npw,nph,texcoord);
      gi+=  giFF(ddiff4,n,-npw,-nph,texcoord);
      gi+=  giFF(ddiff5,n,0,nph,texcoord);
      gi+=  giFF(ddiff6,n,0,-nph,texcoord);
      gi+=  giFF(ddiff7,n,npw,0,texcoord);
      gi+=  giFF(ddiff8,n,-npw,0,texcoord);

      //increase sampling area:
      pw += incx;  
      ph += incy;    
   } 
   ao/=24.0;
   gi/=24.0;

   gl_FragColor = vec4(col-vec3(ao)+gi*5.0,1.0);
}

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

There is more shader code that fixe some problems in the next pages of this post: http://www.gamedev.n...=25&WhichPage=1

 

But it's some HLSL shader code... if it can help you .... Good luck with that :)

 

Also, the creator of this shader give two important informations if you havent read it yet:

 

- View space position is reconstructed from depth using texture coordinates of the fullscreen quad, no frustum corners required.

- Depth buffer is expected to be linear. So do not use the opengl one, create your own depth shader.

You guys are going to be the death of me. Josh
Link to comment
Share on other sites

This sort of works. I can't tell if this is what it is supposed to look like, or if it has an error.

 

I'd like to see a demo of his technique before continuing. I don't see any color bounce in any of the shots after the first page.

 

uniform sampler2D texture0;//color
uniform sampler2D texture1;//depth
uniform sampler2D texture2;//normal
uniform sampler2D texture10;//noise

uniform vec2 camerarange;
uniform vec2 buffersize;

float DepthToLinearDepth(in float depth) {
return (camerarange.x / (camerarange.y - depth * (camerarange.y - camerarange.x)) * camerarange.y)/(camerarange.y-camerarange.x);
}

vec3 readNormal(in vec2 coord)  
{  
    return normalize(texture2D(texture2, coord).xyz*2.0  - 1.0);  
}

vec3 posFromDepth(vec2 coord){
    float d = texture2D(texture1, coord.xy).r;
 d=DepthToLinearDepth(d);
    vec3 tray = mat3x3(gl_ProjectionMatrixInverse)*vec3((coord.x-0.5)*2.0,(coord.y-0.5)*2.0,1.0);
    return tray*d;
}
   //Ambient Occlusion form factor:
   float aoFF(in vec3 ddiff,in vec3 cnorm, in float c1, in float c2, in vec2 coord){
         vec3 vv = normalize(ddiff);
         float rd = length(ddiff);
         return (1.0-clamp(dot(readNormal(coord.xy+vec2(c1,c2)),-vv),0.0,1.0)) *
          clamp(dot( cnorm,vv ),0.0,1.0)* 
                (1.0 - 1.0/sqrt(1.0/(rd*rd) + 1.0));
   }
   //GI form factor:
   float giFF(in vec3 ddiff,in vec3 cnorm, in float c1, in float c2, in vec2 coord){
         vec3 vv = normalize(ddiff);
         float rd = length(ddiff);
         return 1.0*clamp(dot(readNormal(coord.xy+vec2(c1,c2)),-vv),0.0,1.0)*
                    clamp(dot( cnorm,vv ),0.0,1.0)/
                    (rd*rd+1.0);  
   }

void main()
{

vec2 texcoord = gl_FragCoord.xy/buffersize;

   //read current normal,position and color.
   vec3 n = readNormal(texcoord.st);
   vec3 p = posFromDepth(texcoord.st);
   vec3 col = texture2D(texture0, texcoord.xy).rgb;

   //randomization texture
   vec2 fres = vec2(800.0/128.0*5,600.0/128.0*5);
   vec3 random = texture2D(texture10, texcoord.st*fres.xy).xyz;
   random = random*2.0-vec3(1.0);

   //initialize variables:
   float ao = 0.0;
   vec3 gi = vec3(0.0,0.0,0.0);
   float incx = 1.0/800.0*0.1;
   float incy = 1.0/600.0*0.1;
   float pw = incx;
   float ph = incy;
   float cdepth = DepthToLinearDepth(texture2D(texture1, texcoord.xy).r);

   //3 rounds of 8 samples each. 
   for(float i=0.0; i<3.0; ++i) 
   {
      float npw = (pw+0.0007*random.x)/cdepth;
      float nph = (ph+0.0007*random.y)/cdepth;

      vec3 ddiff = posFromDepth(texcoord.st+vec2(npw,nph))-p;
      vec3 ddiff2 = posFromDepth(texcoord.st+vec2(npw,-nph))-p;
      vec3 ddiff3 = posFromDepth(texcoord.st+vec2(-npw,nph))-p;
      vec3 ddiff4 = posFromDepth(texcoord.st+vec2(-npw,-nph))-p;
      vec3 ddiff5 = posFromDepth(texcoord.st+vec2(0,nph))-p;
      vec3 ddiff6 = posFromDepth(texcoord.st+vec2(0,-nph))-p;
      vec3 ddiff7 = posFromDepth(texcoord.st+vec2(npw,0))-p;
      vec3 ddiff8 = posFromDepth(texcoord.st+vec2(-npw,0))-p;

      ao+=  aoFF(ddiff,n,npw,nph,texcoord);
      ao+=  aoFF(ddiff2,n,npw,-nph,texcoord);
      ao+=  aoFF(ddiff3,n,-npw,nph,texcoord);
      ao+=  aoFF(ddiff4,n,-npw,-nph,texcoord);
      ao+=  aoFF(ddiff5,n,0,nph,texcoord);
      ao+=  aoFF(ddiff6,n,0,-nph,texcoord);
      ao+=  aoFF(ddiff7,n,npw,0,texcoord);
      ao+=  aoFF(ddiff8,n,-npw,0,texcoord);

      gi+=  giFF(ddiff,n,npw,nph,texcoord)*texture2D(texture0, texcoord.xy+vec2(npw,nph)).rgb;
      gi+=  giFF(ddiff2,n,npw,-nph,texcoord)*texture2D(texture0, texcoord.xy+vec2(npw,-nph)).rgb;
      gi+=  giFF(ddiff3,n,-npw,nph,texcoord)*texture2D(texture0, texcoord.xy+vec2(-npw,nph)).rgb;
      gi+=  giFF(ddiff4,n,-npw,-nph,texcoord)*texture2D(texture0, texcoord.xy+vec2(-npw,-nph)).rgb;
      gi+=  giFF(ddiff5,n,0,nph,texcoord)*texture2D(texture0, texcoord.xy+vec2(0,nph)).rgb;
      gi+=  giFF(ddiff6,n,0,-nph,texcoord)*texture2D(texture0, texcoord.xy+vec2(0,-nph)).rgb;
      gi+=  giFF(ddiff7,n,npw,0,texcoord)*texture2D(texture0, texcoord.xy+vec2(npw,0)).rgb;
      gi+=  giFF(ddiff8,n,-npw,0,texcoord)*texture2D(texture0, texcoord.xy+vec2(-npw,0)).rgb;

      //increase sampling area:
      pw += incx;  
      ph += incy;    
   } 
   ao/=24.0;
   gi/=24.0;

   gl_FragColor = vec4(col-vec3(ao)+gi*5.0,1.0);
}

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

I'd like to see a demo of his technique before continuing. I don't see any color bounce in any of the shots after the first page.

 

nope, everythings real dark .. fps is slain and no colour bounce.

AMD Bulldozer FX-4 Quad Core 4100 Black Edition

2 x 4GB DDR3 1333Mhz Memory

Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5

Windows 7 Home 64 bit

 

BlitzMax 1.50 • Lua 5.1 MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro

3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET

 

LE 2.5/3.4 • Skyline UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0

 

Marleys Ghost's YouTube Channel Marleys Ghost's Blog

 

"I used to be alive like you .... then I took an arrow to the head"

Link to comment
Share on other sites

You aren't mixing the SSAO results in correctly, but it doesn't matter much because the results are much worse than even my first SSAO attempt. I'd like to see his demo, because no one who used his shader got results that looked anything like the images he posted.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...