was mixing real geometry normal, smoothed geometry normal and
bump-mapped normal.
Use `(sd->type & PRIMITIVE_CURVE) ? sc->N : sd->Ng` consistently instead.
We already have two other functions doing very much the same thing.
`bsdf_microfacet_sample()` seems to be the only place where this
function was used; there we always sample visible normals, so the extra
`inside` check is not needed.
1. move early-out logic even earlier
2. reduced the scope of some variables
3. return `label` at the end of `bsdf_microfacet_sample()`. Return
`LABEL_NONE` in the invalid case. The previous distinction was
unnecessary because samples with zero contribution are assigned with
`LABEL_NONE` in `integrate_surface_bsdf_bssrdf_bounce()` anyway.
the motivation was to give closures with low weight a higher pdf to pick
at the first bounce, in case the next interaction has high contribution.
However, there are several issues:
1. this is too much fine-tuned for a specific case, and only works well
when there is a strong contribution after reflection and very little
contribution after the transmission;
2. the logic in `bsdf_microfacet.h` was added when merging reflection
and refraction into a glass closure, since then it doesn't even work
well in the above case when mixed with other closures;
3. The behavior is inconsistent in `bsdf_microfacet_eval()` and
`bsdf_microfacet_sample()`;
4. such cases should be handled by more modern and more general methods
such as path guiding and denoiser;
5. it makes the code flow harder to follow
Delete this trick for now to pick the closures solely based on their
`sample_weight`. Can be added back (with proper fix in
`bsdf_microfacet`) if indeed necessary.
Recent versions of DPC++ dropped using the environment variable
SYCL_PI_LEVEL_ZERO_USE_COPY_ENGINE_FOR_IN_ORDER_QUEUE=0 we were setting.
We're now also setting SYCL_PI_LEVEL_ZERO_USE_COPY_ENGINE=0 by default
to keep a consistent behavior.
The API for the kernels library is defined, there is no need to
export more than that. This change only affects linux since hidden
visiblity is the default on Windows.
The recursive building has an early output, which could leave the node
without the requested child initialized, causing the access to the left
child to crash later on in the builder function.
Simply add an extra is-canceled check to avoid access of possibly
non-initialized tree structure.
Pull Request: https://projects.blender.org/blender/blender/pulls/112132
by doing the subtraction first and then take the dot product. This
offers higher precision than taking the dot product first and then
subtract the result, especially in the cases where the ray origin is
very far away from the sphere center.
Curve normal is not available in legacy particle hair system. Construct
a local coordinate system instead of using a fixed normal direction [1,
0, 0] to avoid black appearance.
Problem caused by [0], resolve by only printing error messages
when none of the GHOST back-ends are able to start.
[0]: f58d596c36c81245ed8c5723e5fa8369106a7a80
There are a couple of functions that create rna pointers. For example
`RNA_main_pointer_create` and `RNA_pointer_create`. Currently, those
take an output parameter `r_ptr` as last argument. This patch changes
it so that the functions actually return a` PointerRNA` instead of using
the output parameters.
This has a few benefits:
* Output parameters should only be used when there is an actual benefit.
Otherwise, one should default to returning the value.
* It's simpler to use the API in the large majority of cases (note that this
patch reduces the number of lines of code).
* It allows the `PointerRNA` to be const on the call-site, if that is desired.
No performance regression has been measured in production files.
If one of these functions happened to be called in a hot loop where
there is a regression, the solution should be to use an inline function
there which allows the compiler to optimize it even better.
Pull Request: https://projects.blender.org/blender/blender/pulls/111976
Use the common BVH utilities header for this.
Added a special type qualifier ccl_ray_data which is defined to ccl_private
for all platforms but Metal. On Metal it is defined to ray_data.
The tricky part is that the BVH utilities are wrapped into the Metal context
class. In some of the BVH functions the context has been already constructed,
but it wasn't done in all the callbacks.
From a quick render tests of the Junkshop benchmark scene there is no render
time difference,
No functional changes are expected.
Pull Request: https://projects.blender.org/blender/blender/pulls/111967
The Metal backend combines all kernel sources into a single string
and passes it to the compiler. Doing so natively has a disadvantage
of making it hard to find sources of mistakes in code when working
on the kernel source as the source file name and line number info
is lost. For example, the error would look like:
```
program_source:187004:3: error: use of undeclared identifier 'metalrt_intersection_point_shadow_force_error'
metalrt_intersection_point_shadow_force_error(launch_params_metal,
^
```
This patch makes it so the #line pragmas are inserted into the
combined source source code, so that the compiler errors are easier
to find immediately. For example the error from above becomes
```
source/kernel/device/metal/kernel.metal:809:3: error: use of undeclared identifier 'metalrt_intersection_point_shadow_force_error'
metalrt_intersection_point_shadow_force_error(launch_params_metal,
^
```
The code is a slightly modified functionality from the source
processing used for OpenCL in Blender 2.80.
Pull Request: https://projects.blender.org/blender/blender/pulls/111959
As __FAST_MATH__ isn't defined anymore since
09df1f4cafb996802af4c89ab8af0630f750d599, sycl::cos uses the precise
implementation, no need to call __spirv_ocl_cos anymore.
Cycles oneAPI kernel library was compiled using -ffast-math. The current
version of Clang makes it link to crtfastmath.o in that case, bringing a
static constructor that does set the FTZ/DAZ bits in MXCSR for the whole
program, leading to unwanted behavior with other components.
Instead of -ffast-math, we switch to a safer subset of compile flags.
Pull Request: https://projects.blender.org/blender/blender/pulls/111708
This is a rewrite of GHOST_ContextVK to align with Metal backend as described
in #111389 - solution 3 with the adaptation that GHOST is still responsible
for presenting the swap chain image and a post callback is still needed in
case the swapchain is recreated.
This PR also includes some smaller improvements in stability.
Technical documentation: https://developer.blender.org/docs/eevee_and_viewport/gpu/vulkan/swap_chain/
* Renderpasses and framebuffers are not owned anymore by GHOST_ContextVK
* VKFramebuffer doesn't contain a swap chain image.
* Swapchain images can only be used as a blit destination or present source.
Not as an attachment.
* GHOST_ContextVK::swapBuffers would call a callback with the image the
GPU module needs to blit the results to.
* Clearing of depth/stencil attachments when no depth write state is set.
* Enable VK_KHR_maintenance4 to relax the stage interface mapping.
* Removes most vulkan validation warnings/errors.
* Detection of frame buffer changes that needs to be applied before
performing a command requiring render pass (draw/clear attachment)
**Benefits**
* Late retrieval of a swap chain image results in better overall performance as
Blender doesn't need to wait until the image is presented on the screen.
* Easier API and clearer state (transitions)
* More control over Image layouts and command buffer states. (Better alignment with
Vulkan API)
Pull Request: https://projects.blender.org/blender/blender/pulls/111473
Implements the GHOST_GetPixelAtCursor for the X11 backend, allowing
the user to sample any color displayed on the screen.
Noted some limitations in the code-comments.
Ref !111493.
When GLSL sources were first included in Blender they were treated as
data (like blend files) and had no license header.
Since then GLSL has been used for more sophisticated features
(EEVEE & real-time compositing)
where it makes sense to include licensing information.
Add SPDX copyright headers to *.glsl files, matching headers used for
C/C++, also include GLSL files in the license checking script.
As leading C-comments are now stripped,
added binary size of comments is no longer a concern.
Ref !111247