bkaradzic / bgfx

Cross-platform, graphics API agnostic, "Bring Your Own Engine/Framework" style rendering library.
https://bkaradzic.github.io/bgfx/overview.html
BSD 2-Clause "Simplified" License
15.08k stars 1.95k forks source link

Example proposal. Procedural sky as a post process. #1041

Closed volcoma closed 6 years ago

volcoma commented 7 years ago

Would you be interested in a procedural sky as an example. I can supply the shaders which are pretty simple and require almost no setup on the cpu only clip quad rendered at the far plane with the camera's view and proj matrices and with a less equal depth test and pretty much thats it, results in something like this: https://cloud.githubusercontent.com/assets/1499411/22755670/d6cf794e-ee4c-11e6-92cd-e29ae30eefc8.png https://cloud.githubusercontent.com/assets/1499411/22755669/d6cd60fa-ee4c-11e6-9ff2-ebf0e3535e39.png

shader code: https://github.com/volcoma/EtherealEngine/blob/master/engine_data/shaders/vs_atmospherics.sc https://github.com/volcoma/EtherealEngine/blob/master/engine_data/shaders/fs_atmospherics.sc

bkaradzic commented 7 years ago

:+1: Yes, examples are always welcome.

volcoma commented 7 years ago

My proposal is that someone else write it since I have a lot on my plate right now. I am providing the shader code and explaning the steps. Step 1. Render your scene to a fbo with a depth buffer(may be the window one or a seperate) and then light it. A deferred way or forward. Step 2. Bind the fbo and depth buffer and view, projection matrices from your camera and draw a fullscreen clip quad at the far plane, z = 1 with depth test = less equal, and the shaders i provided.

And thats basicly it.

jarrettchisholm commented 7 years ago

Your link to vs_atmospherics.sc seems to be broken.

volcoma commented 7 years ago

https://github.com/volcoma/EtherealEngine/blob/master/engine_data/shaders/vs_clip_quad_ex.sc Sorry i renamed it

bkaradzic commented 7 years ago

You can link it at specific commit, like: https://github.com/volcoma/EtherealEngine/blob/df979db5536ad2518ab2de8e77a579505a31f1be/engine_data/shaders/vs_atmospherics.sc

bkaradzic commented 7 years ago

@volcoma Why do you have those .io files everywhere? Technically you should have one varying.def.sc for all shaders to define your varying semantics. Having multiple means you're changing varyings names. While there are no performance side effects, you might want to consolidate those to be easier to maintain it.

volcoma commented 7 years ago

@bkaradzic In my case they are easier to maintain this way. This way it is a seperate entity not connected wtih anything so one can import a shader to his project without having to go and modify the varying.def.sc residing there. Its just internal reasons, no big deal :). I would even prefer it if they are defined in the shader file itself but... I really don't see the benefit from having every input output in the same blob file. For me it is definately not easier to maintain having multiple directories with shaders in it.

bkaradzic commented 7 years ago

https://ebruneton.github.io/precomputed_atmospheric_scattering/

https://github.com/ebruneton/clear-sky-models

bkaradzic commented 6 years ago

36-sky: https://bkaradzic.github.io/bgfx/examples.html#sky