Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifdef WATER_REFRACT
- if (iswater > 0.9) {
- vec3 posxz = worldposition.xyz + cameraPosition.xyz;
- posxz.x += sin(posxz.z+frameTimeCounter)*0.25;
- posxz.z += cos(posxz.x+frameTimeCounter*0.5)*0.25;
- float deltaPos = 0.2;
- float h0 = waterH(posxz.xz);
- float h1 = waterH(posxz.xz + vec2(deltaPos,0.0));
- float h2 = waterH(posxz.xz + vec2(-deltaPos,0.0));
- float h3 = waterH(posxz.xz + vec2(0.0,deltaPos));
- float h4 = waterH(posxz.xz + vec2(0.0,-deltaPos));
- float xDelta = (h1-h0)+(h0-h2);
- float yDelta = (h3-h0)+(h0-h4);
- float depth = getDepth(pixeldepth);
- float depth2 = getDepth(pixeldepth2);
- float wDepth = depth - depth2;
- float rMult = 5.0;
- rMult = clamp(wDepth,0.0,1.0);
- rMult /= (depth2);
- float refMult = REFRACT_MULT-dot(normal,normalize(fragposition).xyz)*0.003;
- //refMult = rMult + refractMult;
- vec3 refract = normalize(vec3(xDelta,yDelta,1.0-pow(abs(xDelta+yDelta),2.0)));
- vec4 rA = texture2D(gcolor, newtc.st + refract.xy* refMult* rMult);
- rA.rgb = pow(rA.rgb,vec3(2.2));
- vec4 rB = texture2D(gcolor, newtc.st);
- rB.rgb = pow(rB.rgb,vec3(2.2));
- float mask = texture2D(gaux1, newtc.st + refract.xy* refMult* rMult).g;
- mask = float(mask > 0.04 && mask < 0.07);
- newtc = (newtc.st + refract.xy* refMult* rMult)*mask + texcoord.xy*(1-mask);
- color.rgb = pow(texture2D(gcolor,newtc.xy).rgb,vec3(2.2));
- float uDepth = texture2D(depthtex1,newtc.xy).x;
- uPos = nvec3(gbufferProjectionInverse * nvec4(vec3(newtc.xy,uDepth) * 2.0 - 1.0));
- }
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement