## News:

LWJGL 3.3.2 released

## Problem in the shader when rendering?

Started by gibson, April 14, 2018, 17:38:51

#### gibson

I moved on. I figured out how to determine if the point is inside the frustum or not. I did it this way: I just calculated the distance to each of the 6 planes, if it turns out to be negative, then the point does not lie inside the frustum. Implemented this all in a fragmented shader.

Below is the implementation of this shader. I transmit 6 square matrices of size 3 A B C D E F - each of them contains 3 vertices of the plane. In the shader, a method was written that finds the distance between the point and the plane of the . When the program is started, it independently selects a polygon or does not draw with color. With the transfer of the coordinates of vertices, problems should not exist. The problem at the level of computation in the shader. Help.

#### KaiHH

Your solution would become much more elegant, if you did not submit three points on the plane for each of those 6 planes, but instead used 6 vec4's each holding the factors a, b, c and d of the plane equation `a*x + b*y + c*z + d = 0`, making your `distancePointPlane(vec3 point,mat3 matr)` (which computes the plane equation from three points on the plane) completely superfluous.
And as I said in your previous post (which you should just have continued answering to), you can perfectly compute the distances IN THE VERTEX SHADER and only perform the `distance >= 0.0` test ON THE INTERPOLATED VARYING `distance` in the fragment shader. This will be correct, since OpenGL performs perspective-correct interpolation of that varying based on your camera projection. This will save you A LOT of computations in the fragment shader.