I tried to implement the algorithm you suggested, but I’m not quite sure about it, is this what you meant?
// screen size
vec4 eye= view * vec4(sphereCenter.xyz, 1.0);
vec4 clipCoords_radius=proj * vec4(sphereRadius, 0.0, eye.z, 1.0);
sphereSize = clipCoords_radius.x/clipCoords_radius.w;
Does it make sense to use the result to make a rough frustum culling like this?
vec4 clipCoords_center = proj * eye;
float max=max(clipCoords_center.x, max(clipCoords_center.y, clipCoords_center.z)) /
float min=min(clipCoords_center.x, min(clipCoords_center.y, clipCoords_center.z)) /
if(max - sphereSize > 1.0)
else if(min + sphereSize < -1.0)
Thanks in advance for you help, your answer are always really helpful.
I’d also like to ask one more thing: I can’t use compute shaders in my application (for compatibility reasons) but I’m facing a problem like the one described by @devdept (hundreds of thousands of objects that cannot be easily grouped together, need to sort them by screen size). Currently I’m using the couple vertex-fragment to perform my calculations in parallel and retrieving the results as values from a bitmap. The performances are really promising but I know it’s a dirty hack so I’m asking you (and all the other experienced graphics programmers in the forum) to know if this approach makes any sense, what could be possibly go wrong and the alternatives that come to your mind.