Files
UnrealEngineUWP/Engine/Shaders/Shared/PathTracingDefinitions.h
chris kulla 190f8d8252 Path Tracer: Refactor material eval/sample API to give independent control over diffuse vs specular scattering
This allows us to implement the Affect Specular control in the lights and also be able to decompose the image by the type of scattering (volume,diffuse,specular,etc..).

The PathState now stores the first scattering type in the path state so that we can decompose the image by scatter event type. Refraction is given slightly special treatment. A path is allowed to refract multiple times before we decide on the diffuse vs. specular vs volume status. This is done so that objects behind glass can be treated the same as objects seen directly. This can be important in the case of (for example) a character wearing glasses, or characters seen behind the windows of a vehicle.

Add controls to post process volume to select which lighting components we want to have enabled. This allows rendering of diffuse/specular/volume elements separately from the beauty image. These top level controls also impact early exits in the path tracer when we realize that a given path will no longer make any contribution to the image. This allows specular only or volume only renders to be faster than the combined render.


There were many refactors along the way:
 * Refactor blend mode handling to reduce the amount of logic needed. Take advantage of the fact that some modes such as modulate or holdout are only encountered with unlit mode, which the integrator will never pick for lighting calculations.
 * Move RadianceProbe eval/sample to GPULightmass only
 * Refactor all BSDFs to use V_World and L_World instead of incoming/outgoing directions as all BSDFs did this renaming immediately anyway.
 * Only pass 3 random numbers to MaterialSample as this is the most that any of the shading models uses (and the 4th component is reserved for path termination anyway).
 * Refactor all BSDFs to allow sharing of the common setup code relating to the probability of lobe selection
 * SolidGlass and ThinGlass now both implement the entire bsdf, which allows the logic for refraction to take into account all lobes at once.

#rb Patrick.Kelly
#jira UE-126337
#preflight 63c6d5d502024f93d8671a2b

[CL 23767142 by chris kulla in ue5-main branch]
2023-01-18 18:32:54 -05:00

51 lines
2.8 KiB
C

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
// Constants for 'SamplerType'
#define PATHTRACER_SAMPLER_DEFAULT 0
#define PATHTRACER_SAMPLER_ERROR_DIFFUSION 1
// Constants for the 'Flags' field of FPathTracingLight
#define PATHTRACER_FLAG_LIGHTING_CHANNEL_MASK (7 << 0) // Which lighting channel is this light assigned to?
#define PATHTRACER_FLAG_TRANSMISSION_MASK (1 << 3) // Does the light affect the transmission side?
#define PATHTRACER_FLAG_NON_INVERSE_SQUARE_FALLOFF_MASK (1 << 4) // Does the light have a non-inverse square decay?
#define PATHTRACER_FLAG_STATIONARY_MASK (1 << 5) // Only used by GPULightmass
#define PATHTRACER_FLAG_TYPE_MASK (7 << 6)
#define PATHTRACING_LIGHT_SKY (0 << 6)
#define PATHTRACING_LIGHT_DIRECTIONAL (1 << 6)
#define PATHTRACING_LIGHT_POINT (2 << 6)
#define PATHTRACING_LIGHT_SPOT (3 << 6)
#define PATHTRACING_LIGHT_RECT (4 << 6)
#define PATHTRACER_FLAG_CAST_SHADOW_MASK (1 << 9)
#define PATHTRACER_FLAG_CAST_VOL_SHADOW_MASK (1 << 10)
#define PATHTRACER_FLAG_HAS_RECT_TEXTURE_MASK (1 << 11)
#define PATHTRACER_MASK_CAMERA 0x01 // opaque and alpha tested meshes and particles as a whole (primary ray) excluding hairs
#define PATHTRACER_MASK_HAIR_CAMERA 0x02 // For primary ray tracing against hair
#define PATHTRACER_MASK_SHADOW 0x04 // Whether the geometry is visible for shadow rays
#define PATHTRACER_MASK_HAIR_SHADOW 0x08 // Whether hair is visible for shadow rays
#define PATHTRACER_MASK_INDIRECT 0x10 // opaque and alpha tested meshes and particles as a whole (indirect ray) excluding hairs
#define PATHTRACER_MASK_HAIR_INDIRECT 0x20 // For indirect ray tracing against hair
#define PATHTRACER_MASK_EMPTY_SLOT1 0x40
#define PATHTRACER_MASK_EMPTY_SLOT2 0x80
#define PATHTRACER_MASK_IGNORE 0x00 // used when mapping general tracing mask to path tracing mask
#define PATHTRACER_MASK_UNUSED (PATHTRACER_MASK_EMPTY_SLOT1|PATHTRACER_MASK_EMPTY_SLOT2)
#define PATHTRACER_MASK_ALL 0xFF
// Constants for light contribution types (AOV decomposition of the image)
// Leaving all constants enabled creates the beauty image, but turning off some bits allows
// the path tracer to create an image with only certain components enabled
#define PATHTRACER_CONTRIBUTION_EMISSIVE 1
#define PATHTRACER_CONTRIBUTION_DIFFUSE 2
#define PATHTRACER_CONTRIBUTION_SPECULAR 4
#define PATHTRACER_CONTRIBUTION_VOLUME 8
// Constants for the path tracer light grid
#define PATHTRACER_LIGHT_GRID_SINGULAR_MASK 0x80000000u
#define PATHTRACER_LIGHT_GRID_LIGHT_COUNT_MASK 0x7FFFFFFFu
// Constants for the energy conservation texture sizes
#define PATHTRACER_ENERGY_TABLE_RESOLUTION 32