Difference between revisions of "RTPreview"

From Bakery GPU Lightmapper: Wiki
Jump to navigation Jump to search
(Limitations)
 
(9 intermediate revisions by the same user not shown)
Line 2: Line 2:
  
 
<hr>
 
<hr>
''' Currently RTPreview is still awaiting Asset Store approval. As a temporary measure, you can currently get it by contacting me in [https://discord.gg/dP3SkdM Discord] '''
+
'''[https://assetstore.unity.com/packages/tools/level-design/bakery-real-time-preview-164462 Get it on Asset store]'''
 
<hr>
 
<hr>
  
Line 9: Line 9:
 
RTPreview is not a production renderer, but a "how lightmapper sees your scene" kind of view. What you will see is what every traced ray sees in Bakery, meaning its main purpose is fine-tuning lighting and making sure your geometry and materials are properly represented.
 
RTPreview is not a production renderer, but a "how lightmapper sees your scene" kind of view. What you will see is what every traced ray sees in Bakery, meaning its main purpose is fine-tuning lighting and making sure your geometry and materials are properly represented.
  
Similar to Bakery itself, RTPreview can take advantage of RTX hardware to render faster.
+
Similar to Bakery itself, RTPreview can take advantage of RTX hardware to render faster (but does not require it).
  
 
= Installing =
 
= Installing =
Line 48: Line 48:
 
* Bitmasks are currently not respected in preview.
 
* Bitmasks are currently not respected in preview.
  
* Direct light's texture projection is currently not respected.
+
* [[Subsurface_scattering|Subsurface scattering]] does not currently render in preview.
 +
 
 +
* When rendering to a window, no Unity post effects are applied (window exists as a completely separate program). When rendering to Scene View, post effects can be applied, but only in the built-in render pipeline for now. Will be improved in future updates.
 +
 
 +
* Very large scenes (or scenes with too many high resolution lightmaps) can cause an "Out of memory" error, even if they can be baked. This is because preview has to share video memory with Unity running the same scene, while baking makes it possible to unload it from engine.
 +
 
 +
= Troubleshooting =
 +
If RTPreview opens and then closes by itself immediately or after a few seconds, please check and report last lines printed to .ftracelog.txt (placed in Assets/Editor/x64/Bakery by default).
 +
 
 +
= Scripting =
 +
When using any custom scripts that alter Bakery light values in the editor, RTPreview must be notified of change in a following way:
 +
{{code|<nowiki>// Any BakeryDirectLight parameter change</nowiki>}}
 +
{{code|<nowiki>if (BakeryDirectLight.lightsChanged == 0) BakeryDirectLight.lightsChanged = 1;</nowiki>}}
 +
{{code|<nowiki>//</nowiki>}}
 +
{{code|<nowiki>// Any BakeryDirectLight enabled/disabled/created/deleted</nowiki>}}
 +
{{code|<nowiki>BakeryDirectLight.lightsChanged = 2;</nowiki>}}
  
* [[Manual#Ambient_occlusion|Ambient occlusion]] does not currently render in preview.
 
  
* [[Subsurface_scattering|Subsurface scattering]] does not currently render in preview.
+
{{code|<nowiki>// Any BakeryPointLight parameter change</nowiki>}}
 +
{{code|<nowiki>if (BakeryPointLight.lightsChanged == 0) BakeryPointLight.lightsChanged = 1;</nowiki>}}
 +
{{code|<nowiki>//</nowiki>}}
 +
{{code|<nowiki>// Any BakeryPointLight enabled/disabled/created/deleted</nowiki>}}
 +
{{code|<nowiki>BakeryPointLight.lightsChanged = 2;</nowiki>}}
 +
 
 +
 
 +
{{code|<nowiki>// Any BakerySkyLight parameter change</nowiki>}}
 +
{{code|<nowiki>if (BakerySkyLight.lightsChanged == 0) BakerySkyLight.lightsChanged = 1;</nowiki>}}
 +
{{code|<nowiki>//</nowiki>}}
 +
{{code|<nowiki>// Any BakerySkyLight enabled/disabled/created/deleted</nowiki>}}
 +
{{code|<nowiki>BakerySkyLight.lightsChanged = 2;</nowiki>}}
  
* When rendering to a window, no Unity post effects are applied (window exists as a completely separate program). When rendering to Scene View, post effects can be applied, but note that preview image is 8-bit sRGB, so any HDR postprocessing (such as tonemapping) will not display correctly. Will be improved in future updates.
 
  
* Very large scenes (or scenes with too many high resolution lightmaps) can cause an "Out of memory" error, even if they can be baked. This is because preview has to share video memory with Unity running the same scene, while baking makes it possible to unload it from engine.
+
{{code|<nowiki>// Any BakeryLightMesh parameter change</nowiki>}}
 +
{{code|<nowiki>if (BakeryLightMesh.lightsChanged == 0) BakeryLightMesh.lightsChanged = 1;</nowiki>}}

Latest revision as of 11:27, 1 February 2024

Video


Get it on Asset store


RTPreview is a real-time ray tracing plugin for Bakery Lightmapper that makes it possible to quickly visualize and tweak lighting for future lightmaps before baking them.

RTPreview is not a production renderer, but a "how lightmapper sees your scene" kind of view. What you will see is what every traced ray sees in Bakery, meaning its main purpose is fine-tuning lighting and making sure your geometry and materials are properly represented.

Similar to Bakery itself, RTPreview can take advantage of RTX hardware to render faster (but does not require it).

Installing

You need to have Bakery installed first. Then download RTPreview package and just install it on top. RTPreview will be unpacked to standard Bakery folders: Assets/Bakery and Assets/Editor/x64/Bakery.

Bulbgraph.pngIf you moved Bakery folders elsewhere, you will need to manually copy extracted files to their new locations. Make sure lmPreview.ptx and surrounding files are in the same folder as ftrace.exe

Running

Click Bakery -> Preview. Then you have two options:

  • Disable Render In Scene View. Type desired width/height of the window. Click Open Preview. Preview will be shown in its own window.
  • Enable Render In Scene View. Click Open Preview. Preview will be rendered directly in Scene View.

In both cases preview camera will follow editor camera.

Click Close Preview to close the window or stop rendering to Scene View.

Export geometry and maps checkbox controls if scene geometry/materials will be exported to Bakery. Must be enabled if running for the first time or if there were any changes to them.

Tweaking

Any Direct Light, Sky Light, Point Light and Light Mesh can be changed interactively while preview is running.

Additionally, global GI bounce count, Indirect boost, Backface GI and Emissive boost can be modified.

Exposure value can be tweaked to control HDR brightness of the image.

Limitations

  • You shouldn't expect materials to look as they do in engine. Bakery uses Unity's Meta Pass to gather albedo/emission information, meaning surface textures will have the same resolution as lightmaps (probably on the low side). However, a benefit of this approach is that any procedurally computed color coming from custom shaders will be visible. Another benefit is being able to see future lightmap resolution from textures and making sure they didn't leak any wrong color during mip-mapping. Meta Pass does not provide specular information, so there will be no specular highlights or reflections in preview.
  • Any resolution-related settings only affect Meta Pass, but not lighting. Lighting in preview is calculated for every screen pixel.
  • Any sample count settings (GI samples, shadow samples for various lights) have no effect on preview. Preview uses infinite, progressively increasing sample count for everything. One special case that is taken into account is setting shadow samples to 0 for Direct and Point lights in order to disable their shadows completely.
  • Scene geometry (including Light Mesh geometry) and materials can not be changed while preview is running. To apply these changes you must close and open preview again with "Export geometry and maps" option enabled.
  • Objects set to not cast any shadows are not visible in preview. This is actually how Bakery works: objects not casting shadows can gather lighting lighting around them but are transparent for rays.
  • Bitmasks are currently not respected in preview.
  • When rendering to a window, no Unity post effects are applied (window exists as a completely separate program). When rendering to Scene View, post effects can be applied, but only in the built-in render pipeline for now. Will be improved in future updates.
  • Very large scenes (or scenes with too many high resolution lightmaps) can cause an "Out of memory" error, even if they can be baked. This is because preview has to share video memory with Unity running the same scene, while baking makes it possible to unload it from engine.

Troubleshooting

If RTPreview opens and then closes by itself immediately or after a few seconds, please check and report last lines printed to .ftracelog.txt (placed in Assets/Editor/x64/Bakery by default).

Scripting

When using any custom scripts that alter Bakery light values in the editor, RTPreview must be notified of change in a following way:

// Any BakeryDirectLight parameter change
if (BakeryDirectLight.lightsChanged == 0) BakeryDirectLight.lightsChanged = 1;
//
// Any BakeryDirectLight enabled/disabled/created/deleted
BakeryDirectLight.lightsChanged = 2;


// Any BakeryPointLight parameter change
if (BakeryPointLight.lightsChanged == 0) BakeryPointLight.lightsChanged = 1;
//
// Any BakeryPointLight enabled/disabled/created/deleted
BakeryPointLight.lightsChanged = 2;


// Any BakerySkyLight parameter change
if (BakerySkyLight.lightsChanged == 0) BakerySkyLight.lightsChanged = 1;
//
// Any BakerySkyLight enabled/disabled/created/deleted
BakerySkyLight.lightsChanged = 2;


// Any BakeryLightMesh parameter change
if (BakeryLightMesh.lightsChanged == 0) BakeryLightMesh.lightsChanged = 1;