Commit Graph

7640 Commits

Author SHA1 Message Date
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
Бранимир Караџић
c8311f1a55 Merge branch 'master' of github.com:bkaradzic/bgfx 2021-01-31 15:47:21 -08:00
Бранимир Караџић
b92860be23 45-bokeh: Added screenshot. 2021-01-31 15:47:11 -08:00
Kartoffelsaft
c3c3f869f5
add newline at end of error (#2374) 2021-01-31 11:27:25 -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
Бранимир Караџић
7410288405 Updated spirv-cross. 2021-01-27 15:15:56 -08:00
Бранимир Караџић
59858de278 Updated spirv-tools. 2021-01-27 15:15:47 -08:00
Бранимир Караџић
e14a070c29 Updated spirv-headers. 2021-01-27 15:15:31 -08:00
Бранимир Караџић
93efa0c36b Updated glslang. 2021-01-27 14:56:11 -08:00
Бранимир Караџић
fc99801806 Removed glslang build files. 2021-01-27 14:45:28 -08:00
Бранимир Караџић
16f441758f Fixed #2368. 2021-01-25 12:24:12 -08:00
Бранимир Караџић
d8cfb8f64d Fixed issue #2368. 2021-01-22 07:33:59 -08:00
Бранимир Караџић
e769cd7e9f Updated ImGui. 2021-01-21 12:23:03 -08:00
Бранимир Караџић
7783eb8169 Updated ImGui. 2021-01-20 19:02:16 -08:00
Бранимир Караџић
3773e66dda Fixed build. 2021-01-19 16:26:47 -08:00
Hugo Amnov
a515dd3c3d
WebGPU update (#2364)
* Update WebGPU renderer to match new state of API

* Update WebGPU files
2021-01-19 15:18:30 -08:00
kingscallop
5a6c1361ce
Fix compute on Vulkan when there is only one buffer but no uniforms (#2359)
When using this compute shader, the following validation errors appear.
This patch fixes the issue.

BUFFER_WR(cBuffer, uint, 1);

NUM_THREADS(1u, 1u, 1u)
void main()
{
	cBuffer[0] = 0u;
}

../../../src/renderer_vk.cpp (628): BGFX ---E-       CommandBuffer,
Validation, 0: Validation Error: [
VUID-vkCmdBindDescriptorSets-dynamicOffsetCount-00359 ] Object 0: handle =
0x7fffe453ec88, type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageID =
0x82756c54 | vkCmdBindDescriptorSets(): Attempting to bind 1 descriptorSets
with 0 dynamic descriptors, but dynamicOffsetCount is 1. It should exactly
match the number of dynamic descriptors. The Vulkan spec states:
dynamicOffsetCount must be equal to the total number of dynamic descriptors
in pDescriptorSets
(https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/
vkspec.html#VUID-vkCmdBindDescriptorSets-dynamicOffsetCount-00359)

../../../src/renderer_vk.cpp (628): BGFX ---E-            Pipeline,
Validation, 0: Validation Error: [ VUID-vkCmdDispatch-None-02697 ] Object 0:
handle = 0xcd00000000cd, type = VK_OBJECT_TYPE_PIPELINE; Object 1: handle =
0x630000000063, type = VK_OBJECT_TYPE_PIPELINE_LAYOUT; Object 2:
VK_NULL_HANDLE, type = VK_OBJECT_TYPE_PIPELINE_LAYOUT; | MessageID =
0xfd9e3152 | vkCmdDispatch(): VkPipeline 0xcd00000000cd[] defined with
VkPipelineLayout 0x630000000063[] is not compatible for maximum set
statically used 0 with bound descriptor sets, last bound with
VkPipelineLayout 0x0[] The Vulkan spec states: For each set n that is
statically used by the VkPipeline bound to the pipeline bind point used by
this command, a descriptor set must have been bound to n at the same
pipeline bind point, with a VkPipelineLayout that is compatible for set n,
with the VkPipelineLayout used to create the current VkPipeline, as
described in Pipeline Layout Compatibility
(https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/
vkspec.html#VUID-vkCmdDispatch-None-02697)

../../../src/renderer_vk.cpp (628): BGFX ---E-       CommandBuffer,
Validation, 0: Validation Error: [
UNASSIGNED-CoreValidation-DrawState-DescriptorSetNotBound ] Object 0: handle
= 0x7fffe453ec88, type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageID =
0xcde11083 | VkPipeline 0xcd00000000cd[] uses set #0 but that set is not
bound.
2021-01-16 14:00:40 -08:00
kingscallop
758566b3af
Make the provoking vertex consistent across OpenGL, D3D and Vulkan (#2360)
The default provoking vertex on OpenGL is the last of a triangle, but
on D3D and Vulkan it is the first.

This patch sets the provoking vertex to the first vertex on OpenGL.
2021-01-16 13:59:28 -08:00
kingscallop
26c3768cac
Fix typo in bgfx_shader.sh (#2361) 2021-01-16 13:58:32 -08:00
Бранимир Караџић
eab0833b82 Updated spirv-cross. 2021-01-15 20:33:57 -08:00
Бранимир Караџић
a867d872f4 Updated spirv-tools. 2021-01-15 20:33:45 -08:00
Бранимир Караџић
630263d1cb Updated ImGui. 2021-01-15 20:30:58 -08:00
Бранимир Караџић
9e7273506a Updated meshoptimizer. 2021-01-15 20:30:24 -08:00
Бранимир Караџић
af49c5d264 Happy New Year! 2021-01-14 15:53:49 -08:00
MooZ
465c13ad37
Set profile id for metal and pssl to avoid d3d9 codepath. (#2355) 2021-01-13 07:10:23 -08:00
Бранимир Караџић
6b061ffd4e Updated README. 2021-01-11 23:02:06 -08:00
Бранимир Караџић
415d850b01 44-sss: Added screenshot. 2021-01-10 17:53:41 -08:00
Бранимир Караџић
b6ae2d2709 Cleanup. 2021-01-10 14:44:30 -08:00
Бранимир Караџић
7b8ff41954 44-sss: Fixed build. Use D32F instead D24. 2021-01-10 11:27:13 -08:00
Бранимир Караџић
743682db67 Updated meshoptimizer. 2021-01-10 11:25:34 -08:00
Бранимир Караџић
9f5ebeefa4 Updated spirv-cross. 2021-01-10 11:25:26 -08:00
Бранимир Караџић
3c4d81c3b8 Updated spirv-tools. 2021-01-10 11:25:12 -08:00
Бранимир Караџић
b21fdb3718 Updated glslang. 2021-01-10 11:24:56 -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
Бранимир Караџић
d4fbcb113c Updated ImGui. 2021-01-09 13:52:11 -08:00
Alex-MSFT
68f79970e1
Don't skip reset if platform data has changed. (#2347)
(cherry picked from commit 8c4cc84c62)
2021-01-07 16:56:57 -08:00
Бранимир Караџић
e1c2834fc0 travisci: Build OSX debug only to avoid timeout. 2021-01-05 10:56:02 -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
Бранимир Караџић
0170399cf6 Merge branch 'master' of github.com:bkaradzic/bgfx 2021-01-02 10:47:37 -08:00
Branimir Karadžić
4760628bb1 43-denoise: Added shaders. 2021-01-02 10:46:43 -08:00
elvencache
a33ca71bcf
add denoise example (#2344)
/*
* 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
*/
2021-01-02 10:42:02 -08:00
Бранимир Караџић
39424491df TravisCI: OSX build name is osx-x64. 2020-12-31 18:26:30 -08:00