uniform vec3 cullingEquationXYZ;
uniform float cullingEquationW;

vec3 portal_toNDC(vec3 pos){
     vec4 fragposition = gbufferProjectionInverse * (vec4(pos, 1.0) * 2.0 - 1.0);
	 return fragposition.xyz / fragposition.w;
}

vec3 portal_toWorld(vec3 pos){
	return (gbufferModelViewInverse * vec4(pos, 1.0)).xyz;
}

void main() {

vec3 portal_fragPos = portal_toNDC(vec3(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z));
vec3 portal_worldPos = portal_toWorld(portal_fragPos);
if(dot(portal_worldPos, cullingEquationXYZ) + cullingEquationW < 0) { discard; }