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

GGX Specular Model (and some attenuation tweaks) #769

Closed
adriansnetlis opened this issue Jul 29, 2018 · 4 comments
Closed

GGX Specular Model (and some attenuation tweaks) #769

adriansnetlis opened this issue Jul 29, 2018 · 4 comments

Comments

@adriansnetlis
Copy link

adriansnetlis commented Jul 29, 2018

Hey, since UPBGE is slowly progressing regarding rendering quality, it would be awesome if GGX specular model was implemented.
A nice source for shader maths: here and here.
Also, ever since #728 has been done, there is now a parameter called "radius" exposed to lights. This means that the attenuation method for speculars can be changed. Currently the attenuation of diffuse is used also for specular, but that is not accurate. As light source gets further from surface, the specular highlight does not become darker. Instead, it becomes smaller. Now this is how to do this:

  • if the reflection ray intersects with sphere (basic ray/sphere collision test required), then the specular highlights on that fragment must be at the peak intensity.
  • if the reflection ray does not intersect with the light sphere, then the closest point on the sphere must be found and that shall be interpreted as light source position. The rest of specular calculation follows as usual.
    Now if this is implemented, the speculars should no longer be affected by diffuse attenuation. They should be full brightness no matter what.

Lastly, for purposes of realism specular higlights should be combined this way:
color = diffuse * (1.0 - min(specular, 1.0)) + specular
instead of
color = diffuse + specular.
This is required for energy conservation - an important factor in shader realism.

@lordloki
Copy link
Member

@lordloki
Copy link
Member

image
Some tests

@adriansnetlis
Copy link
Author

adriansnetlis commented Aug 26, 2018

That's looking very promising. Not sure if geometric shadowing (G term) is completely right. Or is it shadows causing those extremely hard black shades?

Also, roughness parameter should be exposed at texture tab and nodes. That's essential for this to be usable in games with proper assets.

@lordloki
Copy link
Member

0.3 will include proper PBR support. I close this one. Thanks for reporting and feedback

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

No branches or pull requests

2 participants