samdauwe / webgpu-native-examples

Collection of C-language examples that demonstrate basic rendering and computation in WebGPU native.
Apache License 2.0
373 stars 21 forks source link

Feature name fix: use WGPUFeatureName_DepthClipControl #5

Closed shrekshao closed 1 year ago

shrekshao commented 1 year ago

Feature Depth Clamp is removed in dawn. Require Depth Clip Control instead. https://dawn.googlesource.com/dawn/+/8d73198aca5f1a83283068298c9bfd79640ca36b

This unblocks the build failure on my local linux machine. (with dawn header at f8c07d4753a32b62b52ba86e8ae0dba4830063b3)

Update Readme.md for the running examples cmd line as well (with -s now)

samdauwe commented 1 year ago

Hi shrekshao,

thanks for the build failure fix and update in the Readme.md :)

With best regards, Sam

samdauwe commented 1 year ago

Hi shrekshao,

when testing the examples you will probably notice I ported your deferred rendering example to native:

./wgpu_sample_launcher -s deferred_rendering

The result does not completely match the JavaScript version from the WebGPU Samples: de gray background hides the ground plane.

afbeelding

the gBuffer view looks fine:

afbeelding

I could not find the reason of the difference with the JavaScript version. Do you have any ideas or suggestions to try out to resolve the issue ?

Thanks and best regards, Sam

shrekshao commented 1 year ago

I believe the reason is at https://github.com/samdauwe/webgpu-native-examples/blob/master/src/examples/deferred_rendering.c#L770-L772

The clearValue for position GBuffer should be something like

.r = FLT_MAX,
.g = FLT_MAX,
.b = FLT_MAX,
.a = 1.0f,

cuz for areas with no rasterized fragments, we should have a way to differentiate them in the Gbuffers. In the fragmentDeferredRendering.wgsl there's

if (position.z > 10000.0) {
    discard;
  }

to early return.

But I just tried locally that still didn't fix the issue. Maybe I should find another time to further look at it.