mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-01-02 11:28:19 -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>
58 lines
1.4 KiB
C#
58 lines
1.4 KiB
C#
using NativeEngine;
|
|
|
|
namespace Sandbox;
|
|
|
|
internal class SceneRaytracingSystem : GameObjectSystem<SceneRaytracingSystem>
|
|
{
|
|
// This could all be done on C# side, all below does is to update the TLAS, todo
|
|
internal IRayTraceSceneWorld native;
|
|
|
|
bool Supported => g_pRenderDevice.IsRayTracingSupported();
|
|
|
|
public SceneRaytracingSystem( Sandbox.Scene scene ) : base( scene )
|
|
{
|
|
if ( !Supported )
|
|
return;
|
|
// Update TLAS after bones are updated
|
|
Listen( Stage.UpdateBones, Int32.MaxValue, UpdateSkinnedForRaytracing, "UpdateSkinnedForRaytracing" );
|
|
Listen( Stage.FinishUpdate, Int32.MaxValue, UpdateRaytracing, "UpdateRaytracing" );
|
|
|
|
var RAY_TYPE_COUNT = 2;
|
|
native = CSceneSystem.CreateRayTraceWorld( Scene.Name, RAY_TYPE_COUNT );
|
|
}
|
|
|
|
~SceneRaytracingSystem()
|
|
{
|
|
if ( !Supported )
|
|
return;
|
|
|
|
CSceneSystem.DestroyRayTraceWorld( native );
|
|
}
|
|
|
|
|
|
void UpdateSkinnedForRaytracing()
|
|
{
|
|
using var _ = PerformanceStats.Timings.Render.Scope();
|
|
|
|
var allSkinnedRenderers = Scene.GetAllComponents<SkinnedModelRenderer>()
|
|
.ToArray();
|
|
|
|
foreach ( var renderer in allSkinnedRenderers )
|
|
{
|
|
if ( !renderer.IsValid() )
|
|
continue;
|
|
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Top-level acceleration structure needs to be updated every frame
|
|
/// </summary>
|
|
internal void UpdateRaytracing()
|
|
{
|
|
using var _ = PerformanceStats.Timings.Render.Scope();
|
|
|
|
native.BuildTLASForWorld( Scene.SceneWorld, Scene.RenderAttributes.Get() );
|
|
}
|
|
}
|