-
Notifications
You must be signed in to change notification settings - Fork 69
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
Correct point light attributes #211
Conversation
sorry for being a little late here. See this for how light attenuation works in Ogre: however I cannot find anything on how light attenuation works in Blender mathematically.. |
In the end I found a formula in the Wiki and used that. Then I had to adjust 10x for some reason for it to look more closely to Blender. However Blenders shaders are of course different than OGREs |
light_range = ob.data.cutoff_distance * 10 | ||
if light_range == 0: | ||
light_range = 0.001 | ||
a.setAttribute('range', light_range) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be the same as cutoff_distance
a.setAttribute('range', light_range) | ||
a.setAttribute('constant', '1.0') | ||
a.setAttribute('linear', '%6f' % (4.5 / light_range)) | ||
a.setAttribute('quadratic', '%6f' % (75.0 / (light_range * light_range))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be 2/distance*distance
if I read the blender docs and this correctly: http://learnwebgl.brown37.net/09_lights/lights_attenuation.html
the linear parameter should be 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I'll look into it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
part of the issue is that powerScale
in ogre is not the same as ob.data.energy
:
forcing power scale to 1.0, instead of 1000 (energy) gives you:
the remaining issue is the ambient light setting, that ogre-meshviewer currently ignores (which is ok I think) and I guess blender does something special at the cutoff distance. some sort of fade-out whereas Ogre just does a hard cut.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seems to be some sort of ambient lighting in Blender.
In OGRE I got a hard cut at 5 "meters" which was the range or distance.
In my case I was using shaders from https://learnopengl.com/
But yes, your idea of using a plane is much better.
Based on the information here: https://wiki.ogre3d.org/-Point+Light+Attenuation
I changed the calculation for the Point Light parameters.
Had to introduce 10x factor because otherwise it does not look like in Blender.
This also solves the crash reported in #209