Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The far member of PerspectiveProjection is irrelevant #4596

Open
HackerFoo opened this issue Apr 25, 2022 · 8 comments
Open

The far member of PerspectiveProjection is irrelevant #4596

HackerFoo opened this issue Apr 25, 2022 · 8 comments
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior C-Code-Quality A section of code that is hard to understand or change D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it!

Comments

@HackerFoo
Copy link
Contributor

The far member of PerspectiveProjection is irrelevant, because the far plane is at negative infinite Z

Mat4::perspective_infinite_reverse_rh(self.fov, self.aspect_ratio, self.near)

@HackerFoo HackerFoo added the A-Rendering Drawing game state to the screen label Apr 25, 2022
@mockersf
Copy link
Member

maybe related to #4457

@alice-i-cecile alice-i-cecile added C-Code-Quality A section of code that is hard to understand or change C-Bug An unexpected or incorrect behavior labels Apr 26, 2022
@superdump
Copy link
Contributor

We could still cull meshes to a fake far plane. I just chose not to to preserve behaviour at the time I think. I’m not sure whether we should or shouldn’t cull to a fake far plane. We do for point lights but not for meshes. We could make it optional but then I don’t know what the default should be. I kind of feel like we could make it an Option and if present then we cull to it, if not, we don’t.

@superdump
Copy link
Contributor

I meant to @cart and ask what you think about that ^ ?

@cart
Copy link
Member

cart commented Jul 9, 2022

Yeah I think providing optional configuration for people to cull at a given distance makes a lot of sense.

@superdump
Copy link
Contributor

superdump commented Jul 11, 2022

(The above is a bullet point because that's the only way I know to force github markdown to show the linked PR title.)

@Neopallium
Copy link
Contributor

I have been thinking of culling smaller objects faster than large objects. This way large buildings would still be visible, but smaller objects inside or around it wouldn't be rendered.

Would it be difficult to do that in the far-plane culling logic?

@superdump
Copy link
Contributor

What do you mean by faster? All meshes are chilled against the visible volume every frame.

@Neopallium
Copy link
Contributor

Sorry, by "faster" I mean at a closer distance. A small object (scale dimensions < 1.0) will not be as visible (size on screen) at a distance of 50.0 from the camera vs a larger object (scale dim. > 1.0).

I have a 3d scene that has +40,000 objects (over 100,000 ECS entities). The object meshes are generated from primitive profile/path parameters and can have different textures on different faces. So right now one object could have multiple meshes.

I had tried enabling the far plane culling like in your PR to see if it would help with FPS. It does, but there is a hard cut-off, where even large objects go invisible.

I am now using an adaptive culling based on distance and the Transform.scale of the mesh. For the scene that I have tested with (large buildings with many smaller objects inside), it allows the buildings that are far away to still be visible while hiding the smaller objects that are not as noticable (even when the build has lots of windows).

@BenjaminBrienen BenjaminBrienen added S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it! D-Straightforward Simple bug fixes and API improvements, docs, test and examples labels Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior C-Code-Quality A section of code that is hard to understand or change D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants