Commit Graph

2083 Commits

Author SHA1 Message Date
Martijn Courteaux 078666d373
Allow to create a nvg texture from a BGFX texture. (#2548) 2021-06-25 13:29:51 -07:00
Бранимир Караџић e0d26507dc Added BGFX_CONFIG_ENCODER_API_ONLY configuration setting to enable/disable non-encoder API. 2021-06-11 08:05:58 -07:00
Branimir Karadžić f569fe32a6 Rebuilt all embedded shaders. 2021-06-06 14:51:46 -07:00
kingscallop 6440d669a8
Add missing examples in makefile (#2534) 2021-06-05 13:56:29 -07:00
kingscallop 1ab27e277b
Fix hardcoded bgfx dir from include paths in makefiles (#2532)
Only these four makefiles had these hardcoded paths.
All other makefiles don't specify the bgfx dir name.
2021-06-05 13:55:19 -07:00
Бранимир Караџић ed645ff01a Bounds: Moved pass-thru funcs into .inl header. 2021-06-05 10:29:59 -07:00
Бранимир Караџић b8dc216fa0 Cleanup. 2021-06-05 07:56:20 -07:00
simon chen 0b179e59e2
fixed GLES3 bug, when "EGL_KHR_create_context" doesn't exist. (#2529)
* fixed gles3 bug

* fixed sdl bug on android platform
2021-06-05 07:54:14 -07:00
Branimir Karadžić daa4f9d627 Updated shaders. 2021-05-18 20:36:03 -07:00
Бранимир Караџић 3214539bad Fixing WebGL + Android instancing. 2021-05-18 20:22:46 -07:00
Бранимир Караџић c42a3a5d4d Cleanup. 2021-05-08 07:29:50 -07:00
Daniel Collin c9bf791eaa
Fixed multiview issues with dear imgui (#2511)
When using the multview / docking feature of dear imgui (availible on the main repo in the docking branch) dear imgui will use desktop relative coordinates instead of window relative. This causing the rendering to get "offseted" if not handled correctly.
Before this change the rendering matrix wasn't used at all and this has now been changed in the vertex shader.

Notice this change is fully backwards compatible with the relative windows as well as the upper left corner will always be set to 0,0 in that case thus this change will work with both versions.

I also added some changes to skip rendering if not needed (based on the the other backend implementations for dear imgui such as the OpenGL one)
2021-05-08 07:26:06 -07:00
Бранимир Караџић 67e628d8e3 Cleanup. 2021-04-25 20:23:36 -07:00
pezcode e8d4b3dcce
Fixes for multiple windows and example 22 (#2483) 2021-04-19 15:30:03 -07:00
Бранимир Караџић 19fe73d00d Cleanup. 2021-04-18 21:16:56 -07:00
Hugo Amnov daad11fa0c
Fix 43-denoise when FB format invalid (#2480) 2021-04-18 21:14:57 -07:00
Hugo Amnov a176685a2c
Cleanup imgui shaders (#2479)
* Remove unused Imgui shaders

* Cleanup Imgui shaders position attribute
2021-04-18 12:58:00 -07:00
Бранимир Караџић c3b8ec0dd0 Revert "Cleanup imgui shaders (#2476)"
This reverts commit 01b7fc0105.
2021-04-18 11:43:51 -07:00
Hugo Amnov 01b7fc0105
Cleanup imgui shaders (#2476)
* Remove unused Imgui shaders

* Cleanup Imgui shaders position attribute
2021-04-18 11:39:42 -07:00
pezcode eec0fcd867
Remove unused attributes in debug draw shaders (#2468) 2021-04-11 18:26:23 -07:00
Бранимир Караџић 9ec2472763 Cleanup. 2021-04-07 20:07:28 -07:00
pezcode 870d14110b
Vulkan: allow writing to gl_FragColor without framebuffer color attachment (#2452) 2021-04-07 07:21:02 -07:00
pezcode 9a91bc3496
Fix example 31-rsm Vulkan shaders (#2453) 2021-04-06 19:46:26 -07:00
Бранимир Караџић 1fb245c581 Cleanup. 2021-04-02 12:51:59 -07:00
Бранимир Караџић 0df2e90edb Cleanup. 2021-04-01 20:09:16 -07:00
Branimir Karadžić 117b5ec4ee 05-instancing: Fixed update logic. 2021-04-01 19:16:13 -07:00
Vladimir Vukicevic cb77d3bb46
Fix crash when hitting max draw call limit (#2440)
* Expand instancing demo to have non-instanced path

* Fix count vs. index off by one error when hitting max draw calls
2021-04-01 19:03:01 -07:00
Бранимир Караџић 453adcf661 Replaced D24* with D32F depth format. 2021-02-25 19:44:13 -08:00
Branimir Karadžić 35b7bacfb9 Rebuilt embedded shaders. 2021-02-25 19:33:34 -08:00
Бранимир Караџић b5afc2c81c Updated ImGui. 2021-02-10 22:28:11 -08:00
Бранимир Караџић 45234794d9 Don't interact with camera when mouse is over ImGui. 2021-02-05 17:24:56 -08:00
Branimir Karadžić 3e30d7f42f Updated shaders. 2021-02-04 20:35:37 -08:00
Branimir Karadžić 820e0a0e03 Updated shaders. 2021-02-04 20:33:42 -08:00
elvencache 7f758a06a7
Improve Bokeh example (#2377)
* display bokeh sample pattern, add bokeh shape, improve look

draw sample pattern to texture and display in ui to see number of samples and their arrangment

add bokeh shape controls

remove adhoc 'sqrt' pattern since display makes existing pattern easier to understand and it looks nicer.

switch to floating point color texture and leave lighting results in linear space until after dof is performed. provides better results and bright spots can make more noticeable bokeh shapes.

change default values to use take more samples at reduced resolution so initial experience when loading the sample is better looking image

* update screenshot, minor change to ui

fix height of ui element so scrollbar not required by default layout
update screenshot

* fix typo in texturev

atleast, i'm pretty sure that's a typo don't see a reason to set width twice
2021-02-04 20:28:54 -08:00
Бранимир Караџић eee065c59f 45-bokeh: Fixed OSX build. 2021-02-02 19:05:14 -08:00
XxXSVVPXxXx e068453b53
Update entry_android.cpp (#2375)
- Fix Android Building
- "entry_android.cpp:157:29: error: no member named 'kErrorRederWriterEof' in namespace 'bx'; did you mean 'kErrorReaderWriterEof'?"
2021-02-01 09:08:19 -08:00
Бранимир Караџић b92860be23 45-bokeh: Added screenshot. 2021-01-31 15:47:11 -08:00
Бранимир Караџић 298ffe0968 45-bokeh: Fixed build. 2021-01-31 10:09:22 -08:00
Branimir Karadžić 1401a5333d 45-bokeh: Built shaders and added example. 2021-01-31 10:07:49 -08:00
elvencache 4d272f4104
bokeh depth of field (#2372)
* Implement bokeh depth of field

Implement bokeh depth of field as described in the blog post here:
https://blog.tuxedolabs.com/2018/05/04/bokeh-depth-of-field-in-single-pass.html

Additionally, implement the optimizations discussed in the closing paragraph. Apply the effect in multiple passes. Calculate the circle of confusion and store in the alpha channel while downsampling the image. Then compute depth of field at this lower res, storing sample size in alpha. Then composite the blurred image, based on the sample size. Compositing the lower res like this can lead to blocky edges where there's a depth discontinuity and the blur is just enough. May be an area to improve on.

Provide an alternate means of determining radius of current sample when blurring. I find the blog post's sample pattern to be difficult to directly reason about. It is not obvious, given the parameters, how many samples will be taken. And it can be very many samples. Though the results are good. The 'sqrt' pattern chosen here looks alright and allows for the number of samples to be set directly. If you are going to use this in a project, may be worth exploring additional sample patterns. And certainly update the shader to remove the pattern choice from inside the sample loop.

* fix typo in shader of denoise example

copy/paste error, applying y offset to x component instead
2021-01-31 09:59:55 -08:00
Бранимир Караџић af49c5d264 Happy New Year! 2021-01-14 15:53:49 -08:00
Бранимир Караџић 415d850b01 44-sss: Added screenshot. 2021-01-10 17:53:41 -08:00
Бранимир Караџић 7b8ff41954 44-sss: Fixed build. Use D32F instead D24. 2021-01-10 11:27:13 -08:00
Branimir Karadžić 4c18b80c9d 44-sss: Built shaders and added example to GENie script. 2021-01-10 11:24:28 -08:00
elvencache e5d6a5a22b
xx-sss - Screen Space Shadows (#2350)
* add denoise example

/*
* Implement SVGF style denoising as bgfx example. Goal is to explore various
* options and parameters, not produce an optimized, efficient denoiser.
*
* Starts with deferred rendering scene with very basic lighting. Lighting is
* masked out with a noise pattern to provide something to denoise. There are
* two options for the noise pattern. One is a fixed 2x2 dither pattern to
* stand-in for lighting at quarter resolution. The other is the common
* shadertoy random pattern as a stand-in for some fancier lighting without
* enough samples per pixel, like ray tracing.
*
* First a temporal denoising filter is applied. The temporal filter is only
* using normals to reject previous samples. The SVGF paper also describes using
* depth comparison to reject samples but that is not implemented here.
*
* Followed by some number of spatial filters. These are implemented like in the
* SVGF paper. As an alternative to the 5x5 Edge-Avoiding A-Trous filter, can
* select a 3x3 filter instead. The 3x3 filter takes fewer samples and covers a
* smaller area, but takes less time to compute. From a loosely eyeballed
* comparison, N 5x5 passes looks similar to N+1 3x3 passes. The wider spatial
* filters take a fair chunk of time to compute. I wonder if it would be a good
* idea to interleave the input texture before computing, after the first pass
* which skips zero pixels.
*
* I have not implemetened the variance guided part.
*
* There's also an optional TXAA pass to be applied after. I am not happy with
* its implementation yet, so it defaults to off here.
*/

/*
* References:
* Spatiotemporal Variance-Guided Filtering: Real-Time Reconstruction for
*	Path-Traced Global Illumination. by Christoph Schied and more.
*	- SVGF denoising algorithm
*
* Streaming G-Buffer Compression for Multi-Sample Anti-Aliasing.
*	by E. Kerzner and M. Salvi.
*	- details about history comparison for temporal denoising filter
*
* Edge-Avoiding À-Trous Wavelet Transform for Fast Global Illumination
*	Filtering. by Holger Dammertz and more.
*	- details about a-trous algorithm for spatial denoising filter
*/

* screen space shadows sample

implement screen space shadows. requires deferred rendering or a depth prepass. convert rendered depth to linear depth to skip reconstructing multiple times when doing shadow test.

project light into screen space to find direction from each pixel to the light. walk through screen space texture towards light. sample depth to reconstruct position represented by this sample pixel and compare to position along interpolated ray from pixel to light. if position represented by depth is closer to the eye than the light ray, an initial pixel is in shadow.

specify distance of shadow ray via world units or pixels in screen space.

optionally offset the initial sample position by noise to reduce banding.

demonstrate other ways to reduce hard edge of screen space shadow.

* clean out denoise sample for pull request...

* rename folder to 44- add missing file
2021-01-10 11:20:35 -08:00
Бранимир Караџић 3202330daa 43-denoise: Removed alpha from screenshot. 2021-01-02 11:35:21 -08:00
Бранимир Караџић fa3aed3b0b 43-denoise: Updated references. 2021-01-02 11:23:13 -08:00
Бранимир Караџић cbccb2386a 43-denoise: Style cleanup. Added screenshot. 2021-01-02 11:12:45 -08:00
Бранимир Караџић 27de3100b7 43-denoise: Switched depth to D32F format. 2021-01-02 10:52:19 -08:00
Branimir Karadžić 4760628bb1 43-denoise: Added shaders. 2021-01-02 10:46:43 -08:00