vec4 RoughReflection(vec3 viewPos,vec3 normal,float dither,float smoothness,sampler2D colortex){
	vec4 color=vec4(0.);
	
	vec4 pos=Raytrace(depthtex0,viewPos,normal,dither,4,1.,.1,2.);
	float border=clamp(1.-pow(cdist(pos.st),50.*sqrt(smoothness)),0.,1.);
	
	if(pos.z<1.-1e-5){
		#ifdef REFLECTION_ROUGH
		float dist=1.-exp(-.125*(1.-smoothness)*pos.a);
		float lod=log2(viewHeight/8.*(1.-smoothness)*dist);
		#else
		float lod=0.;
		#endif
		
		if(lod<1.){
			color.a=texture2DLod(colortex6,pos.st,1.).b;
			if(color.a>.001)color.rgb=texture2DLod(colortex,pos.st,1.).rgb;
		}else{
			for(int i=-2;i<=2;i++){
				for(int j=-2;j<=2;j++){
					vec2 refOffset=vec2(i,j)*exp2(lod-1.)/vec2(viewWidth,viewHeight);
					vec2 refCoord=pos.st+refOffset;
					float alpha=texture2DLod(colortex6,refCoord,lod).b;
					if(alpha>.001){
						color.rgb+=texture2DLod(colortex,refCoord,max(lod-1.,0.)).rgb;
						color.a+=alpha;
					}
				}
			}
			color/=25.;
		}
		
		Fog(color.rgb,(gbufferProjectionInverse*pos).xyz);
		
		color*=color.a;
		color.a*=border;
	}
	
	return color;
}