Hello everyone. So I have just started working on shaders and I had this idea that I want to check what vertices is in the frustrum of the camera. My knowledge of shaders, matrixes etc comes from watching videos and reading posts so bear with me please haha (This is also my first post on any forum like this)

Outside of my shader I set the matrix of the camera. In the shader I then set the verex to the clip position, then I use a function to see if the vertice is in the frustrum and if it is I assign it to 1 or 0 that I later use to show the color;

The results i get is this:

Only covering the multiple vertices that are directly in the centre of the camera.

Tried working around with the CheckIfFrustrum function and change the return to:

```
return vertexCheck.y > 1 && vertexCheck.x > 1 && vertexCheck.z > 0;
```

Which makes it take up a quarter of the frustrum instead.

If i only check the x or the y it covers half of the camera vertically or horizontally.

```
return vertexCheck.x > 1 && vertexCheck.z > 0;
```

Now if I only use the x values for the check I get a weird effect of a line with some of the white color inbetween:

```
return vertexCheck.x < 1 && vertexCheck.x > -1 && vertexCheck.z > 0;
```

Any tips on what I can do to make it so that all the vertices in the camera frustrum creates one color?

Code for outside the shader for updating the camera:

```
void LateUpdate()
{
Matrix4x4 M = transform.GetComponent<Renderer>().localToWorldMatrix;
Matrix4x4 V = theCamera.worldToCameraMatrix;
Matrix4x4 P = theCamera.projectionMatrix;
Matrix4x4 MVP = P * V * M;
Shader.SetGlobalMatrix("MvpCamera", MVP);
}
```

Function in Shader that checks if the vertice is in the cameras view:

```
bool CheckIfFrustrum(float4x4 matr, float4 point)
{
float4 VertexCheck = mul(matr, float4(point.x, point.y, point.z, 1));
return VertexCheck.x > -1 && VertexCheck.x < 1 && VertexCheck.y > -1 && VertexCheck.y < 1;
}
```

The vert shader:

```
Interpolators vert (MeshData v)
{
Interpolators o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.color = CheckIfFrustrum(MvpCamera, o.vertex) ? 1 : 0;
return o;
}
```

Thanks in advance for any help!!