{'fraction_non_alphanumeric': 0.026851260772422596, 'fraction_numerical': 0.00965528247685924, 'mean_word_length': 4.744900297960119, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
NeReF: Neural Refractive Field for Fluid Surface Reconstruction and Implicit Representation

Existing neural reconstruction schemes such as Neural Radiance Field (NeRF) are largely focused on modeling opaque objects. We present a novel neural refractive field(NeReF) to recover wavefront of transparent fluids by simultaneously estimating the surface position and normal of the fluid front. Unlike prior arts that treat the reconstruction target as a single layer of the surface, NeReF is specifically formulated to recover a volumetric normal field with its corresponding density field. A query ray will be refracted by NeReF according to its accumulated refractive point and normal, and we employ the correspondences and uniqueness of refracted ray for NeReF optimization. We show NeReF, as a global optimization scheme, can more robustly tackle refraction distortions detrimental to traditional methods for correspondence matching. Furthermore, the continuous NeReF representation of wavefront enables view synthesis as well as normal integration. We validate our approach on both synthetic and real data and show it is particularly suitable for sparse multi-view acquisition. We hence build a small light field array and experiment on various surface shapes to demonstrate high fidelity NeReF reconstruction.


Introduction
Existing neural reconstruction schemes such as Neural Radiance Field (NeRF) have shown its great power for scene representation and reconstruction. However, NeRF and its successors largely focus on modeling opaque objects. In contrast, modeling and reconstruction of refractive surfaces from photographs have great importance for applications ranging from fluid physics analysis, environmental monitoring to computer graphics. Refractive surfaces poses exceptional challenges for NeRF representation as a light ray only diverts from its straight path when traversing the air-fluid interface and hence makes the sampling and radi- Figure 1. Our Neural Refractive Field (NeReF) is formuated to recover a volumetric normal field with its corresponding density field. Despite the explicit depth and normal representation can be derived from NeReF, we can render refraction effect and synthesize novel views directly from NeReF. ance representation of rays no longer applicable.
A common non-intrusive approach for estimating the shape of fluids is to analyze the distortions of a reference pattern placed under the fluid [23]. In particular, many approaches rely on imposing additional assumptions, such as pattern appearance, water height [22,25,27] and optics [14,16,38], while others create dedicated imaging/optics systems (e.g., camera array [10], Bokode [38] and light field probe [34]) for acquiring fluid structures. Morris et al. [22] introduce a novel refractive disparity for water surface recovery using "stereo matching". Qian et al. [25] use a camera array to estimate both water surface and the underwater scene through exploiting the surface normal consistence. Xiong and Heidrich [37] propose a novel differentiable framework to reconstruct the 3D shape of underwater environments from a single, stationary cam-era placed above the water. Notably, Thapa et al. [31] proposes learning-based single-image approach with recurrent layers modeling spatio-temporally consistence to recover dynamic fluid surfaces. Existing approaches unanimously model the air-fluid interface as one layer of geometry surface, which usually is explicitly represented by depth and normal maps. Rerendering of the refraction effect from depth and normal requires ray tracing with hit point testing and two-bounce recursion. In this paper, we propose a Neural Refractive Field (NeReF) to implicitly represent a fluid surface, by taking the advantage of the recent success in neural implicit scene representation. Our work is inspired by the Neural Radiance Field (NeRF). More specifically, we use a fully-connected deep network to represent the fluid surface, whose input is a 3D coordinate and outputs the volume density and normal at the coordinate. We can perform re-rendering of refraction effects directly from the implicit representation by integrating normal along a target ray and deflecting it according to Snell's law. Explicit representations, such as depth and normal, can still be recovered effectively via volume integration ( Fig. 1). In contrast to supervised approaches [38], NeReF optimization is performed in a per-scene manner and hence avoids the lack of real dataset problem. Moreover, NeReF models a continuous function and generates results at resolutions on demand. And NeReF model is relatively smaller (about 4MB), the advantage expands as the desired resolution increases. View synthesis from NeReF is easier compared to ray tracing. To evaluate our proposition, we construct a multi-camera system similar to [26] and capture a known pattern under dynamic fluid surface. We use the optical flow [23] technique to obtain the groundtruth point-ray correspondences for NeReF optimization. Experiment results show our training free approach can recover the fluid surface with high fidelity. Our system setup is shown in Fig. 4.
Compared to the original NeRF which models radiance along rays, we demonstrate that the geometric information (normal of refractive surface) of the ray can also be implicitly encoded in a neural field.

Related Work
Our work is closely related to researches in fluid surface reconstruction and neural scene representation.
Image based Fluid Surface Reconstruction Shape from distortion analyzes the distortions in images of patterns placed under water, and it is the most common technique used for image based fluid reconstruction initiated by Murase's pioneering work [23]. The following shapefrom-distortion methods can be categorized into singleview based methods or multi-view based methods. Approaches that adopt a single viewpoint setup usually assume additional surface constraints, such as planarity [1,5,12] and integrability [34,38], to tackle the depth normal ambiguity. Notably, Tian and Narasimhan [32] develop a data-driven iterative algorithm to rectify the water distortion and recover water surface through spatial integration. Shan et al. [27] estimate the surface height map from refraction images with global optimization. Xiong and Heidrich [37] propose a novel differentiable framework to reconstruct the 3D shape of underwater environments from a single, stationary camera placed above the water in the wild environment. In contrast, multi-view based approaches rely on dedicately designed imaging/optic systems. Ye [38] exploit Bokode -a computational optical device that emulates a pinhole projector -to capture ray-ray correspondences, which can be used to directly recover the surface normals. Morris et al. [22] extend the traditional multi-view triangulation to be appropriate for refractive scenes, and build up a stereo setup for water surface recovery. More recently, a learning-based single-image approach has recently been presented for recovering dynamic fluid surfaces [38]. Our capturing system setup is mainly similar to that of Qian et al. [25], which creates a 3x3 camera array and use optical flow technique to recover under water object (Fig. 2). However, like other approaches, it models the air-fluid interface as depth and normal maps. In contrast, We propose to implicitly encode the fluid surface into a fully connected neural network.
There is another line of works which aim to recover transparent objects, such as gas flow [2], which we recommend to read for extra information.
Neural Radiance Field The remarkable work of Neural Radiance Field is a milestone in novel view synthesis area. Before Mildenhall et at [21] raise the idea of NeRF, several methods are proposed to predict photo-realistic novel views of scenes base on dense sampling views. Theses methods can be divided into two classes. One class of methods use mesh-based representations of scenes with diffuse [33] or view-dependent [4,9,35] appearance, optimized by differentiable rasetizers [7,13,18,19] or pathtracers [17,24]. Another class of methods use volumetric representations to address this task. NeRF combines the implict representation with volumetric rendering to achieve compelling novel view synthesis with rich view-dependent effects. As the headstone of many following works, including ours, NeRF uses the weights of a multilayer perceptron(MLP) to represent a scene as a continuous volumetric field of particles that block and emit light. It takes single continuous 5D coordinates (spatial location (x, y, z) and view direction (θ, φ)) as input and outputs the volume density σ and view-dependent color c.
Based on the pipeline of NeRF, several extended works have been proposed. Ricardo et al [20] present an approach to enable the NeRF capable of modeling uncontrolled images from unstructured photo collections with learning a per-image latent embedding apperance variations and de-composing scenes into image-dependent components. In Chen et al's [6] work, the MVSNeRF is a deep neural network that is able of utilizing three nearby input views via fast network inference to reconstruct radiance fields. Jonathan et al [3] combine the mip-map approach and NeRF together, simultaneously improve the original positional encoding into an integrated positional encoding, which represent the volume covered by each conical frustum, ending up with mip-NeRF which reduces aliasing and improves NeRF's ability to represent fine details. In Alex Yu et al [39]'s PlenOctreees for real-time rendering of Neural radiance fields, spherical harmonics are applied as the base of a representation of view-dependent colors. Besides, PlenOctree is applied to store density and SH coefficients modelling view-dependent appearance at each leaf. With these two measures, this method can render images at more than 150FPS, which is thousands times faster than the conventional method.
Neural Scene Representation Scene representation is a process that interprets the visual data into a feature representation. By providing the aimed pose and latent code [28] or alternatively transform views directly in the latent space [36], novel view images can be rendered. Generative Query Network(GQN) [11] provides framework within which machine learning scenes using their own sensors. However, this framework has the limitation of being oblivious to the 3D structure. Voxel grid representations and graph neural networks are the method that capture 3D structures. Vincent Sitzmann et al [29] propose a continuous 3D-structureaware neural scene representation network, which trained from 2D images and their camera poses and encodes both geometry and appearance. Following their previous work, Sitzmann propose the light field network. This neural network represents the light field of a 3D scene implicitly, which can be used to extract depth maps from 360-degree light fields.

Neural Refractive Field
The core at our fluid surface reconstruction approach is as a neural refraction field (NeReF), which retains the continuous scene representation ability of NeRF. Before proceeding, let's briefly review NeRF for easier explanation. NeRF represents a scene using a fully-connected deep network, whose input is a spatial location and viewing direction and output is the volume density and view-dependent emitted radiance. A novel image view is synthesized by sampling coordinates along camera rays and use volume rendering techniques to project the output colors and densities into an image. In this paper, we use the same scheme but adapt the NeRF for generating a normal value at each spatial location.
Specifically, we represent the continuous fluid surface as an implicit function F, which is approximated by a Multi- Layer Perception (MLP). It takes a 3D location (x, y, z) as input, and outputs the surface normal n along with the volume density σ.
Note that although this modification is relatively small, the underlying hypothesis is very different. Our NeReF encodes the refractive surface normals which deflect the rays spatially, in contrast NeRF models rays' radiance which is in another dimension of spatial domain.

Depth and Normal from Volume Accumulation
From NeReF, depth and normal are accumulated along the camera ray. Specifically, given k sample points along a camera ray r = o + λd where o is the origin of the ray and d is the ray direction, with each sample point determined by parameter λ i , i ∈ {1, ..., k}. We query the sampling point's volume density σ i and normal n i . Then, we calculate the surface normal N(r k ) and depth D(r k ) of the last sampling point λ k as: where τ i = exp − i−1 j=1 σ j δ j , and δ i = λ i+1 − λ i denotes the distance between two adjacent samples along the

Refraction Execution
The implicit fluid representation should also obey the Snell's Law when a ray traverse the refractive surface. The refraction process follows Snell's law, i.e., n 1 sin θ 1 = n 2 sin θ 2 , where n 1 , n 2 and θ 1 , θ 2 are the refraction indexes and incident and refracted ray angles respectively.
For each camera ray r, we calculate the refracted ray r = p s + λd using the Snell's law in vector form, as: where In our case, n 1 and n 2 are the refractive indexes of air and water, respectively.

Fluid Surface Reconstruction with NeReF
We represent the fluid surface implicitly with NeReF. One remaining problem is how to train the network. Previous section describes how to refract a ray using NeReF, in our implementation, we assume the camera ray refracts once when it hits the fluid surface, i.e., N(r) = N(r k ) for k → ∞, but remember this assumption is not required for our NeReF but only for the easy analysis of the fluid surface reconstruction problem.
We can use the consistency between the refracted rays to optimize the network, but need the ground truth refracted rays. Hence we follow the scheme of previous approaches and place a reference pattern under the water. We first capture images of the pattern without water and then pour the water in. Then we can use the positional differences of corresponding intersection points on pattern between the refracted rays and un-refracted rays and use it a loss for NeReF optimization. The process is visualized in Fig. 3.

Problem Formation
We set the x−y plane of coordinate system to be aligned with the reference pattern, and z direction is up and perpendicular to the pattern plane. Then normal of the reference plane is n π = [0, 0, 1]. For a refracted ray r (λ) = p s +λd , we can obtain the intersection point q with the reference plane from ray-plane intersection: where · denotes the dot product. Similarly, we can obtain the intersection point q of the ray without refraction from λ q . Then our aim is to optimize the NeReF network from q and q . However, there is still one remaining problem that we don't know how to correspond q and q . Notice p and p are projection points on the image plane of rays r and r . So the ray r that before refraction can be directly obtained from camera parameters and pixel location q. Then we use the optical flow [30] technique to obtain a dense warp field W from the distorted frame I to reference frame I, presumably we obtain the shift of q as: We set q gt as our ground truth point for the refracted ray r of r. Then we refract r using NeReF network during training and produce a q F . We define our correspondence loss as the L1 smoothed difference between q gt and q F as: where S 1 denotes the L1 smooth operatoer.

Depth Smoothness
In practice, we notice depth tends to contain more noise compared to normal. While according to fluid dynamics, depth should be very smooth due to physic constraints. Hence we use a depth smoothness loss: Finally, our total loss then is the weighted combination of previous losses as: Specifically, we set λ ds = 0.15 in our implementation.

Implementation Details
In our implementation, the NeReF consists of 8 fully connected layers and each layer has 256 channels. The network takes location as input and generates density σ. Then we use another 3 layers to regress normal from σ. Hence the total size of our NeReF is about 4MB. Training Details. We train our models using Adam optimizer with a learning rate 4E-4 which decays 5E-5 per 1000 iterations during training. Besides, we sample 2048 camera rays for each mini-batch and sample 96 and 192 points from near to far following the hierarchical sampling strategy. We optimize all our networks on a PC with a single Nvidia GeForce RTX3090 GPU for 10 epochs. The training time is about 2 hours. System Setup. To validate the proposition of our NeReF, we construct a fluid capture system consists of a water tank, a pattern underwater and a 10 camera array. The water tank is with size 12 inches for wave simulation. The industrial cameras we use is Z Cam E2 and we place all cameras on on top to record videos of the water. We calibrate the intrinsics and extrinsics of the cameras, and remove lens distortion using OpenCV [15]. We use 9 cameras for NeReF training and the remaining one for evaluation and testing.

Pattern
Examples of Captured Images Figure 4. The real fluid surface capture system which consists of 10 Z Cam E2, a water tank and a pattern under the water. We reserve one camera specifically for the evaluation purpose. On the right shows example real images captured.

Experiment
We first evaluate the fluid surface reconstruction approach based on our NeReF, for synthetic fluid data generated by Blender [8]. We exploit the fluid physics simulation ability of Blender and set up a scene that contains 25 cameras and water with size 2 x 1 x 4. We place a binary planar pattern beneath the water, and then use wave modifier to simulate the shallow water equation, Grestner's equation, and Gaussian equation effects. We generate 4 sequences and each sequence contains 90 images. We place 25 pinhole cameras on top of the fluid to observe the pattern distortions under various wave functions.
We obtain a dense warp field using the optical flow [30] technique. Then, we train our NeReF using 9 cameras as describe above and render the depth, normal from NeReF using volumetric integration approach. We compute the relative error, i.e., the error to ground truth ratio, for the depth error and use the L2 norm of the difference between recovered and ground truth normal as the depth and normal error respectively. The recovered normal is smooth and the recovered point cloud is very accurate. We can see errors at most parts of the normal and depth are small, only normal at the peaks of ripple waves show relatively large errors. This is reasonable as the normal changes dramatically in that region. Notice in Fig. 5, the scale of the error map is very small, i.e., 0.1, and some normal error in row 3 is just relatively larger. The synthetic experiments demonstrate that our proposed NeReF works accurately for fluid surface reconstruction.

Quantitative Evaluation.
To quantitatively evaluate our method, we compute the PSNR, LPIPS and SSIM metrics on real data. Recall that we mounted 10 cameras on top of the water tank for capturing the fluid dynamics. However, only 9 of them are used for NeReF training and we use the remaining one for testing. Specifically, after the NeReF is optimized, we synthesize a new view image by setting the sampling camera to be exactly the same with the testing camera location. We compare the synthesized image with the camera image in terms of PSNR, LPIPS and SSIM metrics and the result is shown in Tab. 1. We also include the metrics reported by the original NeRF and for references. We have tried our best to find an alternative fluid surface reconstruction method to compare ours with. We can only Ding'11 [10] that have the same multi-camera setup with available code. Hence we use Ding'11 approach to recover the depth and normal, and then generate the view and testing camera using ray tracking and report the metrics in Tab. 1 too.
As we can see the NeReF show good metrics and it means that the synthesized data matches well with the testing camera.  [10] in term of recover accuracy. PSNR, LPIPS and SSIM values of our method and the original NeRF on the real fluid sequence.

Ablation Study
Here we analysis how several key factors in the system would affect our system: Tolerance of flow error Since optical flow provides the ground truth for our NeReF training, we first evaluate how errors in optical flow affect the final performance. From our synthetic data in above section, we have the ground truth optical flow. Then we add random noise at different amplitude levels, train and test the NeReF model and then use the optimized NeReF model for depth and normal recovery tasks. Figure 7 shows the depth inaccuracy, which is calculated by error to ground truth depth ratio, and the normal error

Our NeReF
Ding '11 NeRF GT Figure 6. The re-rendering results directly from NeReF (not through ray tracing using depth and normal) on synthetic data compared with other methods. Normal_Error Normal_Error Figure 7. We study how noises in optical flow affect the performance of NeReF. We gradually increase the noise level and train the NeReF for depth and normal recovery, and calculate the error with ground truth.
mean. As we can see, the depth inaccuracy and normal error mean increase when we add larger noise to optical flow. But it also shows that our NeReF is relatively robust to noise in optical flow as the error curve exhibit a linear increasing tendency instead of a exponential increasing curve.

Camera Number Evaluation
The number of cameras is another important term that may affect the performance significantly. We tested the camera numbers from 9, 7, 5 to 3. And we train NeReF with with the corresponding camera views. After training, we synthesize images at testing view points with the trained model and compare with the ground truth depth and normal. We use the average depth and normal error of all testing views. The result is shown in Tab number of cameras decreases, the error in Reconstruction becomes larger, which is as predicted.

Refraction and View Synthesis with NeReF
One important property of NeRF is its ability of synthesizing photo-realitic novel views. This ability comes from the representation of density, and novel view is synthesize via volumetric integration of density and produces depth. Similarly in our NeReF, we can integrate the volume to obtain depth and normal. With the depth and normal, we can directly apply Snell's law to find the refracted ray and hence find where the ray hits after refraction. As such, we can perform background change and novel view synthesis from the NeReF.
We first compare our NeReF with the original NeRF and ray tacing through depth and normal generated by [10]. The comparison is shown in Fig. 6. We can see original NeRF performs very poorly as the ray geometry are wrong. Moreover, result from ray tracing [10] contains artifacts as ray tracing can only performed at a certain resolution. While the synthesis result from our NeReF is the most close to ground truth.
Then we compare the novel view synthesis result on real Ding'11 Original NeRF Our NeReF Ground Truth Figure 8. The re-rendering results directly from NeReF (no depth or normal explicitly involved) compared with the original NeRF, ray tracing from Ding'11 depth and normal, the ground truth at the testing view.
fluid data the fluid data. Fig. 8 exhibits that results by ray tracing from Ding'11 [10] depth and normal usually contain minor artifacts, the result from original NeRF is unusable, and results from our approach are very close to the ground truth. The rendered binary pattern is much more clearer and it deforms in the same way as the real image. In Fig. 9, we show the recovered depth and normal for the frame captured in Fig. 8. And we re-render use NeReF's volume integration with a new pattern at different viewing points. Notice how distortions are presented differently in each image due to viewing point change.

Discussion
In this paper, we propose a neural scene representation for refractive fluid surfaces, called the Neural Refractive Field or NeReF. Specifically, we represent the fluid surface as a fully-connected deep network, which takes 3D coordinates as input and output the volume density and normal. We can render the refraction effect directly from the implicit representation.
We only train and test the NeReF with fluid surface in a water tank. The surface is then rather flat and we assume one time of refraction. This assumption may not hold for water in flow or more complicate fluid surface. Hence, in the future, we plan to employ our method for complicated refractive shape recovery. Moreover, our adaption  approach has removed the view dependent radiance from NeRF. Hence the render results from NeReF is a constant color from pattern no matter what direction the target view is. We plan to add the view dependent radiance to NeReF and make it be able to synthesize specular highlights.