Difference between revisions of "RTPreview"

From Bakery GPU Lightmapper: Wiki
Jump to navigation Jump to search
(Scripting)
(Scripting)
Line 63: Line 63:
 
= Scripting =
 
= Scripting =
 
When using any custom scripts that alter Bakery light values in the editor, RTPreview must be notified of change in a following way:
 
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>// Any BakeryDirectLight parameter change</nowiki>}}
 
{{code|<nowiki>if (BakeryDirectLight.lightsChanged == 0) BakeryDirectLight.lightsChanged = 1;</nowiki>}}
 
{{code|<nowiki>if (BakeryDirectLight.lightsChanged == 0) BakeryDirectLight.lightsChanged = 1;</nowiki>}}

Revision as of 08:21, 12 December 2020

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.

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.
  • Direct light's texture projection is currently not respected.
  • 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.

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;