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

Add support for AxisAlignedBoxSceneQuery for Light #2355

Closed
karriszou opened this issue Jan 16, 2022 · 5 comments · Fixed by #2358
Closed

Add support for AxisAlignedBoxSceneQuery for Light #2355

karriszou opened this issue Jan 16, 2022 · 5 comments · Fixed by #2358

Comments

@karriszou
Copy link

System Information

  • Ogre Version: 13.3.0 (Tsathoggua)
  • Operating System / Platform: Ubuntu 20.04
  • RenderSystem: OpenGL Rendering Subsystem

Detailled description

I want to query the point light number in a AxisAlignedBox extent, but it not work, because the light.getWorldBoundingBox()(inherited from MovableObject) fuction returns AxisAlignedBox is NULL.

That lead to the query failed:

if (this->isNull() || b2.isNull())

It seems that never compute the extents for Light objects:
// Null, lights are not visible

This question post is in here:
https://forums.ogre3d.org/viewtopic.php?f=2&t=96558&sid=0607b0cdeee4a22ff89d85837926b3ea

Thanks a lot!

@paroj
Copy link
Member

paroj commented Jan 16, 2022

It seems that scene query make no sense for directional light, because directional light has no position, but point and spot light has position.
So maybe point and spot light could be regarded as a point when is involved scene query, otherwise they should have a little AxisAlignedBox extent,
so that to participate in the scene query.

that would be the easiest solution.

Another interpretation is the light size - i.e. a directional light is infinitely large, while a point light parametrizes a sphere and a spot-light parametrizes a cone.

That way the query would also include lights that intersect with the Box, but whose origin is otherwise not inside.

Which of these queries are you interested in?

@karriszou
Copy link
Author

It seems that scene query make no sense for directional light, because directional light has no position, but point and spot light has position.
So maybe point and spot light could be regarded as a point when is involved scene query, otherwise they should have a little AxisAlignedBox extent,
so that to participate in the scene query.

that would be the easiest solution.

Another interpretation is the light size - i.e. a directional light is infinitely large, while a point light parametrizes a sphere and a spot-light parametrizes a cone.

That way the query would also include lights that intersect with the Box, but whose origin is otherwise not inside.

Which of these queries are you interested in?

Currently the first query(position query) is enough for me, i haven't thought of the second case.

If you have time to implement second query(volume query), perhaps some cool effects can be achieved, such as querying whether the spot light hits an object, and then applying an effect to the object. But it can't be achieved with AxisAlignedBox, since their volume are spheres and cones, so they maybe could have a LightVolume property for volume query purposes, but it's a bit troublesome.

(whisper:I'm an adult, of course I choose both...haha)

Thanks!

@paroj
Copy link
Member

paroj commented Jan 17, 2022

this will take more time, as some internal code relies of Lights never being visible. Meanwhile, you could try to use the approach outlined here:
https://forums.ogre3d.org/viewtopic.php?t=60664

@karriszou
Copy link
Author

this will take more time, as some internal code relies of Lights never being visible. Meanwhile, you could try to use the approach outlined here: https://forums.ogre3d.org/viewtopic.php?t=60664

Yes, the approach of the post is feasible, in addition i can make a small modification in the source code for the purpose, since only the position query is required.

Thanks for your help!

@paroj
Copy link
Member

paroj commented Jan 18, 2022

the thing to consider is, when you give lights a bbox, they are included in the scene bbox too. This is then used to e.g. compute the required shadow-map size.
If one was to give the directional light the correct bbox (infinite), it would break shadows. Thats why I am hesitant.

However, the bounding sphere of the scene already includes lights (as points), so it is probably safe to do the same with bboxes.

@paroj paroj mentioned this issue Jan 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants