Ray Tracing - Reflections
This template features examples of how to get started with Ray Traced Reflections in Lens Studio 4.40 , and includes several high end examples to help you get a start into creating stunning visuals using Ray Tracing.

These examples are structured from simple to complex use cases so you can look at each example and compare with others to easily learn how to empower your work with Ray Tracing.
The template comes with six examples. These examples can be found in the Scene Hierarchy
panel under their names.

Video Tutorial
Getting Started with Ray Tracing Reflections
If this is your first time working with Ray Tracing in Lens Studio, it is recommended to vist the Ray Tracing in Lens Studio guide to learn more.
To get started with Ray Tracing in Lens Studio, you will need to enable Advanced Graphics Features for the project. Navigate to the Project Info window and enable this setting.

This setting has already been enabled for this template.
Camera
For Ray Traced Reflections to be displayed, you will need to enable Ray Tracing on the main Camera.

Under this setting, you will see additional settings to control the visual quality of Ray Tracing.
Only one camera can have Ray Tracing enabled, so make sure you place all your ray traced objects under one camera.
Emitter / Receiver Relationship
In the first example, you will take a look at the emitter receiver relationship in Lens Studio.

Ray Traced Reflections work as the relationship between emitter objects - objects that are seen in reflections, and receiver objects - objects that render the reflections on themselves. You can also think of them as reflected objects (emitters) and reflective objects (receivers).
Take a look at the red panda object, click on one of the 3d meshes for the panda and look at the ‘Render Mesh Visual’ component. You can see there are two new settings on this component - Reflection Emitter and Reflection Receiver. Using these settings you can control the way ray tracing works in the Lens.

Emitter Object
Emitters are meshes that are visible in reflections.
You can see that our panda is set as an emitter object with the ‘Reflection Emitter’ checkbox enabled on the mesh.

You can add the elephant in the reflections too.
- Navigate to the
Elephant [TRY_ME]
object, - Enable the Object

- On the
Render Mesh Visual
component for theelephant_med
object, enable theReflection Emitter
checkbox.

You should now see the Elephant in the mirror.
Emitter objects are relatively simple to use, just add them and you’ll see them in reflections.
Please consider that the number of emitters and the complexity of the mesh affects the performance of the lens. We’ll discuss this subject in detail in later examples.
Receiver Object
Now, take a look at the mirror object, navigate to the Render Mesh Visual
of the Mirror_Plane
object.

You can see that the Mirror_Plane
object has Reflection Receiver
turned on. This enables the mirror to render reflections.

You can make the floor reflective as well;
- Navigate to the ‘Floor’ object.
- Enable ‘Reflection Receiver’.

Now you have a more complete scene with everything reflecting correctly in the scene. Play around with the materials and swap out different objects to get your desired visuals. Ray Tracing currently supports all meshes using Render Mesh Visual
so feel free to try your art and see how Ray Traced Reflections enhances your Lens.
Real World Environment
In this example, you will learn how to add content from the real world environment to your AR Lens..
Enable the 02 - Adding World Environment
object to take a look at the example.

For the purpose of this example, the panda’s inner tube has been turned into a reflective object.
You should take a look at the Ground_Plane [TRY_ME]
object in the ReprojectionTools [TRY_ME]
prefab.

You will see that the ground object is set as an emitter, but you can also see there’s another script attached to it called Reprojection Script
.

This reprojection tool takes the camera feed and reprojects it on a mesh based on the mesh’s placement in the scene. You can use this tool on any mesh you may want in your scene. For your convenience, Snap has added three examples for you to try them out.
World_Dome will give you a 360 dome to get background information too.
The Reprojection Script
takes a few references:
- Main Camera: A reference to our main camera in the scene.
- Source Object: A reference to the scene object we want to use as the emitter in the scene.
Because you already have a real world surface in the camera feed, you will want to avoid seeing the 3d asset in the camera. You can use the ‘Hide From Camera’ setting on the Emitter Object. This will hide the object from the camera, but will still be visible in reflection.
AstroCat
In this example, you will take a look at a more polished end result and how Snap has utilized Ray Tracing to enhance the visual quality of our asset. Feel free to play around with the materials and get your own custom look, or replace the assets with your own to get started.

You can open the AstroCat Clean [TRY_ME]
example to set up the AstroCat example from scratch and create your own custom visual. AstroCat is wearing very reflective and metallic armor, so you will want to set all objects as emitters and receivers.
For adding your own custom mesh in the AstroCat example, you will need to set up the following:
- You can set up the mirror object by setting the mirror plane as receiver and emitter, and making the frame emitter only.
- You can set up the stage, making the rotating light as an emitter object and the stage both receiver and emitter.
Feel free to play around with the materials and refine the look.
Performance is directly related to the number of emitters you have in the scene and their complexity. For optimal performance, you should refrain from setting an object as an emitter if it’s not visually necessary.
Ray Tracing Optimization Examples
Ray Tracing can be very performance heavy, especially if you want to have high-end looking visuals with complex meshes. In this example, you will take a look at a footwear example and see how Snap has optimized this example to perform well.

You can take a look at the final example 06 - Heels
to see the final optimized version. You will learn more about the optimization process in examples 04 and 05.
High/Low Optimization (Advanced)
You should start with understanding the biggest source of performance degradation in Ray Tracing, complex emitters. The more complex an emitter mesh is (number of polygons) the heavier it’s going to be in terms of performance.

The heel model is approximately around 12,000 triangles each. For performance optimization, Snap created a low poly variant to use as an emitter. Our low poly comes at around 1400 triangles, almost one tenth of the original high polygon asset.
While the low poly asset might not hold up in close ups, the lack of details won’t be noticeable in reflections and will result in a huge performance improvement.


In the Heel_R
object, you will see two objects, Heel_R_High
and Heel_R_Low
. In this setup, the high poly version will be the primary source of visuals and will act as the receiver object for high fidelity visuals. Then, the Heel_R_Low
object will act as the emitter object that’ll only be visible in reflections.
To set up this relationship between the models, you will need to perform the following:
- Place the low poly
Heel_R_Low
version at the same location as the high poly version.- You can do that by zeroing the transform of the low poly object.
- Set all the child mesh objects of
Heel_R_Low
as emitters. - Once we enable the emitter checkbox, you will see a new setting called
Hide From Camera
. This setting allows us to place objects in the scene that won’t be visible in the camera feed, but will still be visible in reflections. - Set the high poly object as a receiver to enable reflections in the
Heel_R_High
to have a performance increase and a beautiful high poly object in the camera feed.
For reference, you can take a look at how the Heel_L
objects are set up and compare.
Complexity of meshes as receivers bear no implication on performance. This means you can make them as complex as you want up to the limit of 65,000 triangles.
Reflection Groups Optimization (Advanced)
For performance optimization, you should consider the amount of emitters in your scene. For Ray Tracing purposes, each receiver pixel that interacts with an emitter adds to the complexity of the scene, even if you don’t see the emitter in the end result.
This can get complicated when there are a lot of emitters and a lot of receivers in the scene and you might not see the interaction in the reflections.

For this purpose, Snap has created the Reflection Groups tab under emitters and receivers. You can think of Reflection Groups as layers that are specific for reflection interaction, they do not affect anything in the scene other than the Ray Traced Reflections.
Ray Tracing currently has ten groups per Lens that we can use to further optimize the scene.


By placing an emitter in a specific group, you can set specific receivers to ignore that group and thus not interact with the specific emitter, saving on performance and optimizing the scene.
For the heels example, you can set each element as a specific group, and then set receivers to only interact with emitters that will be visible for that receiver. The bottom of the heel model has no way to see the inner parts of the heel or the label, so it has no need to see it as a receiver. Additionally, the platform does not see the inner parts either, so you can discard that as well.
You can take a look at the Heel_L
objects to see how the groups were set for emitters and receivers to optimize their interaction. The most important thing to consider for groups is how what will be visible to our users.
Both emitters and receivers can interact with any number of groups, you can set up the ray tracing interaction any way you want. It's suggested to set emitters to only use a single group, and then assign receivers to interact with the relevant groups. This allows the scene to be more manageable.
Previewing Your Lens
You’re now ready to preview your Lens! To preview your Lens in Snapchat, follow the Pairing to Snapchat guide.
What's Next?
Now that you have explored the Reflections Template, you can visit the Asset Library for more examples and high end assets to use in your project or study as a reference.
You should also take a look at some of our Shopping and Try-On templates to add Ray Tracing to different products.