blender/tests/python/modules/gpu_info.py
Miguel Pozo a6b708c1f2 Workbench: Hardware raytraced shadows
Implement optional hardware raytraced shadows for the Workbench engine.

They can be enabled in the `Preferences > Viewport > Quality` settings.
The option will be shown as inactive if the current backend/GPU doesn't
support hardware ray queries (only Vulkan is supported ATM).
A new `gpu.capabilities.ray_query_support_get()` has been added to the
Python API to support this UI functionality.

The visual results are the same as the stencil shadows implementation,
but it provides a significant performance boost on modern hardware.

The raytracing functionality has been implemented in a fragment shader
that mimics the output of stencil-based implementation, so the render
pipeline stays mostly the same.

Co-authored by: Jeroen Bakker

Pull Request: https://projects.blender.org/blender/blender/pulls/161047
2026-07-21 16:57:31 +02:00

35 lines
1,001 B
Python

# SPDX-FileCopyrightText: 2022 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later
"""
Prints GPU back-end information to the console and exits.
Use this script as `blender --background --python gpu_info.py`.
"""
import bpy
import sys
import json
# Render with workbench to initialize the GPU backend otherwise it would fail when running in
# background mode as the GPU backend won't be initialized.
scene = bpy.context.scene
scene.render.resolution_x = 1
scene.render.resolution_y = 1
scene.render.engine = "BLENDER_WORKBENCH"
bpy.ops.render.render(animation=False, write_still=False)
# Import GPU module only after GPU backend has been initialized.
import gpu
print('<GPU_INFO>')
print(json.dumps({
"VENDOR": gpu.platform.vendor_get(),
"RENDERER": gpu.platform.renderer_get(),
"VERSION": gpu.platform.version_get(),
"DEVICE_TYPE": gpu.platform.device_type_get(),
"RAY_QUERY_SUPPORT": gpu.capabilities.ray_query_support_get(),
}))
print('</GPU_INFO>')
sys.exit(0)