RTSDF Real-time Signed Distance Fields for Soft Shadow Approximation in Games Yu Wei Tan

2025-04-26 0 0 5.46MB 8 页 10玖币
侵权投诉
RTSDF: Real-time Signed Distance Fields for Soft Shadow
Approximation in Games
Yu Wei Tan a, Nicholas Chua, Clarence Koh and Anand Bhojan b
School of Computing, National University of Singapore, Singapore
{yuwei, nicholaschuayunzhi, clarence.koh}@u.nus.edu, banand@comp.nus.edu.sg
Keywords: Real-time, Signed Distance Field, Jump Flooding, Ray Tracing, Soft Shadow, Rendering, Games.
Abstract: Signed distance fields (SDFs) are a form of surface representation widely used in computer graphics, hav-
ing applications in rendering, collision detection and modelling. In interactive media such as games, high-
resolution SDFs are commonly produced offline and subsequently loaded into the application, representing
rigid meshes only. This work develops a novel technique that combines jump flooding and ray tracing to gen-
erate approximate SDFs in real-time. Our approach can produce relatively accurate scene representation for
rendering soft shadows while maintaining interactive frame rates. We extend our previous work with details
on the design and implementation as well as visual quality and performance evaluation of the technique.
1 INTRODUCTION
Signed distance fields (SDFs) are scalar fields that
store the shortest distance between a point in space to
a model. Their sign indicates if that point is inside or
outside the bounds of said model. In interactive me-
dia, models are most commonly represented by tri-
angle meshes. SDFs are typically generated offline
through ray tracing and scan conversion etc., limiting
their use to rigid meshes. While existing real-time
GPU-based methods can update SDFs per frame, they
are unable to handle high resolutions efficiently.
We present a novel SDF method that integrates
jump flooding and ray tracing to generate an approx-
imate real-time SDF (RTSDF) of reasonably high
quality for a fixed small scene. Additionally, we eval-
uate the technique by applying it to raymarched soft
shadow approximation, offering trade-offs between
speed and quality for real-time application require-
ments. This paper extends our previous work (Tan
et al., 2020) with a detailed analysis of the design,
implementation and evaluation of the technique.
2 DESIGN
As shown in Figure 1, jump flooding produces a
fast approximation of the SDF which allows for real-
ahttps://orcid.org/0000-0002-7972-2828
bhttps://orcid.org/0000-0001-8105-1739
time calculation. Conversely, ray tracing gives a
more accurate scene representation as it queries the
hardware-generated triangle mesh and slowly con-
verges. Hence, we propose a real-time SDF that com-
bines the speed of jump flooding with the precision of
ray tracing. We first perform an initial jump flooding
which creates an SDF of the voxelized scene. Next,
we use the voxelized SDF as a mask to decide where
to attempt ray tracing on the triangle mesh for more
accurate scene representation. Naturally, we choose
locations closer to surfaces to ray trace and fall back
on the distances generated by jump flooding in empty
regions. Our technique is built on NVIDIAs Falcor
library (Benty et al., 2020) which provides an abstrac-
tion over the graphics API for our implementation.
(a) Jump flooded SDF (b) Ray-traced SDF
Figure 1: Soft shadows from SDF raymarching.
2.1 Ray Tracing
The basic implementation of an SDF is a uniform grid
where the discrete points in the scalar field are stored
as a 3D texture (Wright, 2015). Uniform grids are
arXiv:2210.06160v1 [cs.GR] 11 Oct 2022
easy to implement and allow us to perform hardware
interpolation of neighbouring points, making sam-
pling efficient. A brute force approach to generate
uniform SDF is ray sampling (Wright, 2015).
For each discrete point in the distance field, we
shoot rays in random directions to query the distance
to the closest mesh. To calculate the direction, we ran-
domly generate a point on the surface of a sphere with
a uniform distribution (Weisstein, 2019). The mini-
mum distance traced for each point is stored in the
red channel of a 400 ×200 ×400 3D texture. Rays
traced in future frames will overwrite the value if the
newer value is smaller. To determine the sign, we first
check if it is a front or back face hit via the dot prod-
uct of the ray direction and normal of the primitive
intersected. We then accumulate the number of front
and back face hits in the green and blue channels of
the texture. Finally, we set the sign to negative if the
majority of hits are back face hits (Wright, 2015).
2.2 Jump Flooding
The jump flooding algorithm (JFA) (Rong and Tan,
2006) which can be run on parallel on the GPU al-
lows us to generate an approximate SDF in real-time.
We first initialize a 3D SDF texture where each texel
represents a 3D point or a grid point. JFA gives us in-
formation about the closest seed at any point in space.
Setting every point on each triangle in the mesh as a
seed, we can obtain the closest distance to a surface
for our distance field. To determine if a grid point
contains a triangle efficiently, we voxelize the scene
with voxel resolution equal to our final distance field.
After voxelization, we simply check if a grid point
contains a model voxel to determine if it is a seed.
We now have a 3D texture containing grid points
that are either empty or are seeds. Without loss of
generality, we assume that the dimensions of the 3D
texture are equal (i.e. 3D cube) and that its length n
is a power of 2. For each grid point, we query a con-
stant number of neighbouring grid points a predefined
offset away. For each query, if the queried grid point
is a seed or contains seed information, we check if
that seed is closer to its currently stored seed and up-
date its seed information if so. We start with an offset
of length n
2and halve it for each subsequent iteration
until it reaches 1 for our final iteration.
With current GPUs that can write to 3D textures,
we adapt the 2D JFA algorithm (Rong and Tan, 2006)
for 3D space. During a single iteration, we run the
querying in parallel, allowing us to use the GPU to
accelerate the calculations. However, the algorithm
produces an unsigned distance field. To determine the
sign, we subtract a small βfrom the distance field,
causing surface points to be of negative value and ef-
fectively thickening the surface. The surfaces gener-
ated are also hollow as they contain positive values in
their interior. With jump flooding, we can generate
an approximate SDF in real-time for a decently large
resolution of 2563at 30ms and 1283at 2.34ms.
2.3 Ray Mask
We obtain a rough approximation of the SDF or
coarse SDF via jump flooding to locate regions in the
scene to apply ray tracing. In raymarching, regions
far from the surface act as a way to accelerate the pro-
cess but closer regions require a more accurate surface
representation. Hence, we can detect regions closer to
surfaces based on a distance dfrom the coarse SDF
and only ray trace in these regions at a higher resolu-
tion for better surface representation. Essentially, the
coarse SDF is a ray mask that determines which ar-
eas in the SDF should be ray-traced to generate a fine
SDF as shown in Figure 2. dcan be used to trade-off
performance for accuracy where a larger dresults in
more rays traced as texels further from surfaces would
be within ddistance from a surface point.
(a) Coarse SDF (b) Fine SDF
Figure 2: Slice of SDF.
Unlike adaptively sampled fields which increase
the resolution at regions with finer details, we limit
the number of levels of detail to two as generation
of hierarchical SDF is difficult to parallelize (Liu and
Kim, 2014). Additionally, real-time traversal of the
SDF may require multiple texture lookups to sample
until the leaf node despite saving space with a sparse
voxel texture (Aaltonen, 2018).
With the combination of the techniques, we turn
a blocky representation of the scene into a more re-
fined triangle mesh representation without ray tracing
every texel in the SDF as shown in Figure 3. Addi-
tionally, we can resolve issues identified in the jump
flooding of voxelization of thin surfaces. As seen in
Figure 4, while the coarse SDF gets a disconnected
representation of the plant, we fill in the holes through
refinement with the ray trace pass.
2.4 Raymarching
While SDFs are surface representations, they only
provide proximity information without a direction. To
摘要:

RTSDF:Real-timeSignedDistanceFieldsforSoftShadowApproximationinGamesYuWeiTana,NicholasChua,ClarenceKohandAnandBhojanbSchoolofComputing,NationalUniversityofSingapore,Singaporefyuwei,nicholaschuayunzhi,clarence.kohg@u.nus.edu,banand@comp.nus.edu.sgKeywords:Real-time,SignedDistanceField,JumpFlooding,Ra...

展开>> 收起<<
RTSDF Real-time Signed Distance Fields for Soft Shadow Approximation in Games Yu Wei Tan.pdf

共8页,预览2页

还剩页未读, 继续阅读

声明:本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。玖贝云文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知玖贝云文库,我们立即给予删除!
分类:图书资源 价格:10玖币 属性:8 页 大小:5.46MB 格式:PDF 时间:2025-04-26

开通VIP享超值会员特权

  • 多端同步记录
  • 高速下载文档
  • 免费文档工具
  • 分享文档赚钱
  • 每日登录抽奖
  • 优质衍生服务
/ 8
客服
关注