In a GLSL shader I need to omit a few tessellation patches to drastically increase performance. These patches are triangles with given world coordinates for each vertex. However, when I convert these coordinates into view space for frustum culling, there is a margin of error.
This is the original terrain.
This is how the error affects it on the top.
This is a closeup of a section with dirt.
These errors happen namly around the top of the screen but also the sides and the bottom. Here is the code I use to determine if I should exclude the triangle (in GLSL).
bool inFrustum( vec3 p,vec3 q,vec3 r) {
vec4 Pclip = camera * vec4(p, 1.0f);
vec4 Qclip = camera * vec4(q, 1.0f);
vec4 Rclip = camera * vec4(r, 1.0f);
if(((-Pclip.w>Pclip.x&&-Qclip.w>Qclip.x&&-Rclip.w>Rclip.x)|| (Pclip.x>Pclip.w&&Qclip.x>Qclip.w&&Rclip.x>Rclip.w))||
((-Pclip.w>Pclip.y&&-Qclip.w>Qclip.y&&-Rclip.w>Rclip.y)||(Pclip.y>Pclip.w&&Qclip.y>Qclip.w&&Rclip.y>Rclip.w))||
((-Pclip.w>Pclip.z&&-Qclip.w>Qclip.z&&-Rclip.w>Rclip.z)||(Pclip.z>Pclip.w&&Qclip.z>Qclip.w&&Rclip.z>Rclip.w))){
return false;
}
else{
return true;
}
}
I would greatly appreciate any help given! Behemyth