mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-01-16 10:19:18 -05:00
* Re-enable CreateBLAS in RenderDeviceVulkan * Update SPVRemapper to suppot raytracing opcode remapping * Null initialize BLAS on RenderMesh * Clean proper to generate BLAS on mesh data loading * SceneRaytracingSystem stub * Glue SceneRaytracing * Remove pipelines from SceneRaytracing for now, just do TLAS, tie it to SceneRaytracingSystem, updates only once per frame just like how we want in a clean way https://files.facepunch.com/sampavlovic/1b0611b1/ngfx-ui_Ck3ckzQQFT.png * Send Descriptor Set of Raytracing World to RenderAttribute * RTAO example using RayQuery * RayTracingShader API stub * Set SM6.0 and dxlevel 120 as default * Instead of making raytracing opt-in, add -nogpuraytracing to force disable it * Add IRenderDevice::IsRayTracingSupported() to easily query support for it * Fix IsRayTracingSupported() * RTAO Adjustments * Allow Rayquery through AS on Compute and Pixel shaders even if not optimal, avoids it crashing when acessing it on compute * Strip CRaytraceSceneWorld to just generating TLAS, dont need anything else for now and we need a better way to handle UGC than what's there * Bindless::RaytracingAccelerationStructure() * Simplify interface too * Stub for UpdateSkinnedForRaytracing * Dotnet format and fix documentation, make RTAO run at correct stage * Only support raytracing in tools mode for now * Move raytracing stuff to Raytracing.hlsl * Stub RTX shader * Internal Raytracingshader and remove useless stuff exposed from it * VfxProgramHasRenderShader should check for VFX_PROGRAM_RTX too, that's the source from everything else failing * Add arbitrary entry point support to shaders, needed as RTX shaders use [shader("XXX")] instead of MainXXX directly * RenderTools::TraceRays API, preliminary implementation, RTAO uses RaytracingShader * Make RT support internal, allow RT on game * Remove RaytracedAmbientOcclusion, will be on scenestaging when ready * Update engine/Sandbox.Engine/Systems/Render/RayTracingShader.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fix rebase * Update shaders --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
67 lines
2.2 KiB
C#
67 lines
2.2 KiB
C#
using NativeEngine;
|
|
|
|
namespace Sandbox;
|
|
|
|
/// <summary>
|
|
/// Represents a ray tracing acceleration structure that contains geometry for efficient ray intersection testing.
|
|
/// This is used to organize scene geometry in a hierarchical structure optimized for ray tracing performance.
|
|
/// </summary>
|
|
public class RayTracingAccelerationStructure
|
|
{
|
|
internal object native;
|
|
|
|
/// <summary>
|
|
/// Gets whether this acceleration structure is valid and can be used for ray tracing.
|
|
/// </summary>
|
|
public bool IsValid() => native != null;
|
|
|
|
/// <summary>
|
|
/// Create a ray tracing acceleration structure from native engine data.
|
|
/// </summary>
|
|
internal RayTracingAccelerationStructure( object nativeAccelerationStructure )
|
|
{
|
|
native = nativeAccelerationStructure;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Create a ray tracing acceleration structure from scene geometry.
|
|
/// </summary>
|
|
/// <param name="geometryData">The geometry data to build the acceleration structure from.</param>
|
|
/// <returns>A new acceleration structure, or null if creation failed.</returns>
|
|
public static RayTracingAccelerationStructure Create( object geometryData )
|
|
{
|
|
// This would typically interface with the native engine to build the acceleration structure
|
|
// For now, this is a placeholder implementation
|
|
if ( geometryData == null )
|
|
return null;
|
|
|
|
// In a real implementation, this would call into the native engine
|
|
// to build a DXR acceleration structure from the provided geometry
|
|
var nativeAS = geometryData; // Placeholder
|
|
|
|
return new RayTracingAccelerationStructure( nativeAS );
|
|
}
|
|
|
|
/// <summary>
|
|
/// Updates the acceleration structure with new geometry data.
|
|
/// This is more efficient than rebuilding from scratch for dynamic geometry.
|
|
/// </summary>
|
|
/// <param name="geometryData">The updated geometry data.</param>
|
|
public void Update( object geometryData )
|
|
{
|
|
if ( !IsValid() )
|
|
throw new InvalidOperationException( "Cannot update invalid acceleration structure" );
|
|
|
|
// This would call into the native engine to update the acceleration structure
|
|
// with new geometry positions while preserving the hierarchical structure
|
|
}
|
|
|
|
/// <summary>
|
|
/// Releases the native resources associated with this acceleration structure.
|
|
/// </summary>
|
|
public void Dispose()
|
|
{
|
|
native = null;
|
|
}
|
|
}
|