// Guidelines: To be able to switch from deferred to forward renderer we need to have forward opaque material with both DepthOnly and ForwardOnlyOpaqueDepthOnly pass.
// We render first the opaque object as opaque alpha tested are more costly to render and could be reject by early-z (but not Hi-z as it is disable with clip instruction)
// This is handeled automatically with the RenderQueue value (OpaqueAlphaTested have a different value and thus are sorted after Opaque)
// If opaque velocity have been render during GBuffer no need to render it here
// TODO: Currently we can't render velocity vector into GBuffer, neither during forward pass (in case of forward opaque), so it is always a separate pass
// TEMP: As we are in development and have not all the setup pass we still clear the color in emissive buffer and gbuffer, but this will be removed later.
publicstaticGUIContentMaxSmoothness=newGUIContent("MaxSmoothness","Very low cost way of faking spherical area lighting. This will modify the roughness of the material lit. This is useful when the specular highlight is too small or too sharp.");
publicstaticGUIContentSpotLightShape=newGUIContent("SpotLightShape","The shape use for the spotlight. Has an impact on the cookie transformation and light angular attenuation.");
publicstaticGUIContentSpotAngle=newGUIContent("Spot Angle","Controls the angle in degrees at the base of a Spot light's cone.");
publicstaticGUIContentSpotInnerPercent=newGUIContent("Spot Inner Percent","Controls size of the angular attenuation in percent of the base angle of the Spot light's cone.");
// TODO: Review this once AdditionalShadowData is refactored
publicstaticGUIContentColor=newGUIContent("Color","Controls the color being emitted by the light.");
publicstaticGUIContentIntensity=newGUIContent("Intensity","Controls the brightness of the light. Light color is multiplied by this value.");
publicstaticGUIContentRange=newGUIContent("Range","Controls how far the light is emitted from the center of the object.");
publicstaticGUIContentLightmappingMode=newGUIContent("Mode","Specifies the light mode used to determine if and how a light will be baked. Possible modes are Baked, Mixed, and Realtime.");
publicstaticGUIContentBounceIntensity=newGUIContent("Indirect Multiplier","Controls the intensity of indirect light being contributed to the scene. A value of 0 will cause Realtime lights to be removed from realtime global illumination and Baked and Mixed lights to no longer emit indirect lighting. Has no effect when both Realtime and Baked Global Illumination are disabled.");
publicstaticGUIContentCookie=newGUIContent("Cookie","Specifies the Texture projected by the light. Spotlights require 2D texture and pointlights require texture cube.");
publicstaticGUIContentBakedShadowRadius=newGUIContent("Baked Shadow Radius","Controls the amount of artificial softening applied to the edges of shadows cast by the Point or Spot light.");
publicstaticGUIContentBakedShadowAngle=newGUIContent("Baked Shadow Angle","Controls the amount of artificial softening applied to the edges of shadows cast by directional lights.");
publicstaticGUIContentShadowResolution=newGUIContent("Resolution","Controls the rendered resolution of the shadow maps. A higher resolution will increase the fidelity of shadows at the cost of GPU performance and memory usage.");
publicstaticGUIContentShadowBias=newGUIContent("Bias","Controls the distance at which the shadows will be pushed away from the light. Useful for avoiding false self-shadowing artifacts.");
publicstaticGUIContentShadowNormalBias=newGUIContent("Normal Bias","Controls distance at which the shadow casting surfaces will be shrunk along the surface normal. Useful for avoiding false self-shadowing artifacts.");
publicstaticGUIContentShadowNearPlane=newGUIContent("Near Plane","Controls the value for the near clip plane when rendering shadows. Currently clamped to 0.1 units or 1% of the lights range property, whichever is lower.");
publicstaticGUIContentAffectDiffuse=newGUIContent("AffectDiffuse","This will disable diffuse lighting for this light. Doesn't save performance, diffuse lighting is still computed.");
publicstaticGUIContentAffectSpecular=newGUIContent("AffectSpecular","This will disable specular lighting for this light. Doesn't save performance, specular lighting is still computed.");
publicstaticGUIContentFadeDistance=newGUIContent("FadeDistance","The distance at which the light will smoothly fade before being culled to minimize popping.");
publicstaticGUIContentLightDimmer=newGUIContent("LightDimmer","Aim to be used with script, timeline or animation. It allows dimming one or multiple lights of heterogeneous intensity easily (without needing to know the intensity of each light).");
publicstaticGUIContentApplyRangeAttenuation=newGUIContent("ApplyRangeAttenuation","Allows disabling range attenuation. This is useful indoor (like a room) to avoid having to setup a large range for a light to get correct inverse square attenuation that may leak out of the indoor");
publicstaticGUIContentShadowFadeDistance=newGUIContent("ShadowFadeDistance","The shadow will fade at distance ShadowFadeDistance before being culled to minimize popping.");
publicstaticGUIContentShadowDimmer=newGUIContent("ShadowDimmer","Aim to be use with script, timeline or animation. It allows dimming one or multiple shadows. This can also be used as an optimization to fit in shadow budget manually and minimize popping.");
publicoverridevoidOnInspectorGUI()
{
m_SerializedAdditionalLightData.Update();
m_SerializedAdditionalShadowData.Update();
publicstaticGUIContentDisabledLightWarning=newGUIContent("Lighting has been disabled in at least one Scene view. Any changes applied to lights in the Scene will not be updated in these views until Lighting has been enabled again.");
publicstaticGUIContentCookieWarning=newGUIContent("Cookie textures for spot lights must be set to clamp. Repeat is not supported.");
publicstaticGUIContentIndirectBounceShadowWarning=newGUIContent("Realtime indirect bounce shadowing is not supported for Spot and Point lights.");
publicstaticGUIContentBakingWarning=newGUIContent("Light mode is currently overridden to Realtime mode. Enable Baked Global Illumination to use Mixed or Baked light modes.");
// Temporary toggle to go back to the old editor & separated additional datas
// LightShape is HD specific, it need to drive LightType from the original LightType when it make sense, so the GI is still in sync with the light shape
// LightShape is HD specific, it need to drive LightType from the original LightType
// when it make sense, so the GI is still in sync with the light shape
Utilities.QuickSort(sortKeys,0,sortCount-1);// Call our own quicksort instead of Array.Sort(sortKeys, 0, sortCount) so we don't allocate memory (note the SortCount-1 that is different from original call).
CoreUtils.QuickSort(sortKeys,0,sortCount-1);// Call our own quicksort instead of Array.Sort(sortKeys, 0, sortCount) so we don't allocate memory (note the SortCount-1 that is different from original call).
// TODO: Refactor shadow management
// The good way of managing shadow:
}
// Not necessary yet but call it for future modification with sphere influence volume
Utilities.QuickSort(sortKeys,0,sortCount-1);// Call our own quicksort instead of Array.Sort(sortKeys, 0, sortCount) so we don't allocate memory (note the SortCount-1 that is different from original call).
CoreUtils.QuickSort(sortKeys,0,sortCount-1);// Call our own quicksort instead of Array.Sort(sortKeys, 0, sortCount) so we don't allocate memory (note the SortCount-1 that is different from original call).
publicreadonlyGUIContentuseHeightBasedBlendText=newGUIContent("Use Height Based Blend","Layer will be blended with the underlying layer based on the height.");
publicreadonlyGUIContentuseMainLayerInfluenceModeText=newGUIContent("Main Layer Influence","Switch between regular layers mode and base/layers mode");
publicreadonlyGUIContentopacityAsDensityText=newGUIContent("Opacity map use as Density map","Use opacity map as (alpha channel of base color) as Density map.");
publicreadonlyGUIContentopacityAsDensityText=newGUIContent("Use Opacity map as Density map","Use opacity map as (alpha channel of base color) as Density map.");
publicreadonlyGUIContentinheritBaseNormalText=newGUIContent("Normal influence","Inherit the normal from the base layer.");
publicreadonlyGUIContentinheritBaseHeightText=newGUIContent("Heightmap influence","Inherit the height from the base layer.");
publicreadonlyGUIContentinheritBaseColorText=newGUIContent("BaseColor influence","Inherit the base color from the base layer.");
// We need one frame delay for this update to work since DynamicGI.UpdateEnvironment is executed directly but the renderloop is not (so we need to wait for the sky texture to be rendered first)
// Render sky into a cubemap - doesn't happen every frame, can be controlled
// Note that m_SkyboxCubemapRT is created with auto-generate mipmap, it mean that here we have also our mipmap correctly box filtered for importance sampling.
vargpuVP=gpuProj*worldToViewMatrix*Matrix4x4.Scale(newVector3(1.0f,1.0f,-1.0f));// Need to scale -1.0 on Z to match what is being done in the camera.wolrdToCameraMatrix API.
publicreadonlyGUIContentrange=newGUIContent("Range","Controls how far the light is emitted from the center of the object.");
publicreadonlyGUIContentcolor=newGUIContent("Color","Controls the color being emitted by the light.");
publicreadonlyGUIContentspotAngle=newGUIContent("Angle","Controls the angle in degrees at the base of a Spot light's cone.");
publicreadonlyGUIContentuseColorTemperature=newGUIContent("Use Color Temperature","Choose between RGB and temperature mode for light's color.");
publicreadonlyGUIContentcolorFilter=newGUIContent("Filter","A colored gel can be put in front of the light source to tint the light.");
publicreadonlyGUIContentcolorTemperature=newGUIContent("Temperature","Also known as CCT (Correlated color temperature). The color temperature of the electromagnetic radiation emitted from an ideal black body is defined as its surface temperature in Kelvin. White is 6500K");
publicreadonlyGUIContentintensity=newGUIContent("Intensity","Controls the brightness of the light. Light color is multiplied by this value.");
publicreadonlyGUIContentlightmappingMode=newGUIContent("Mode","Specifies the light mode used to determine if and how a light will be baked. Possible modes are Baked, Mixed, and Realtime.");
publicreadonlyGUIContentlightBounceIntensity=newGUIContent("Indirect Multiplier","Controls the intensity of indirect light being contributed to the scene. A value of 0 will cause Realtime lights to be removed from realtime global illumination and Baked and Mixed lights to no longer emit indirect lighting. Has no effect when both Realtime and Baked Global Illumination are disabled.");
publicreadonlyGUIContentcookie=newGUIContent("Cookie","Specifies the Texture mask to cast shadows, create silhouettes, or patterned illumination for the light.");
publicreadonlyGUIContentcookieSizeX=newGUIContent("Size X","Controls the size of the cookie mask currently assigned to the light.");
publicreadonlyGUIContentcookieSizeY=newGUIContent("Size Y","Controls the size of the cookie mask currently assigned to the light.");
publicreadonlyGUIContentshadowBias=newGUIContent("Bias","Controls the distance at which the shadows will be pushed away from the light. Useful for avoiding false self-shadowing artifacts.");
publicreadonlyGUIContentshadowNormalBias=newGUIContent("Normal Bias","Controls distance at which the shadow casting surfaces will be shrunk along the surface normal. Useful for avoiding false self-shadowing artifacts.");
publicreadonlyGUIContentshadowNearPlane=newGUIContent("Near Plane","Controls the value for the near clip plane when rendering shadows. Currently clamped to 0.1 units or 1% of the lights range property, whichever is lower.");
publicreadonlyGUIContentbakedShadowRadius=newGUIContent("Baked Shadow Radius","Controls the amount of artificial softening applied to the edges of shadows cast by the Point or Spot light.");
publicreadonlyGUIContentbakedShadowAngle=newGUIContent("Baked Shadow Angle","Controls the amount of artificial softening applied to the edges of shadows cast by directional lights.");
publicreadonlyGUIContentbakingWarning=newGUIContent("Light mode is currently overridden to Realtime mode. Enable Baked Global Illumination to use Mixed or Baked light modes.");
publicreadonlyGUIContentindirectBounceShadowWarning=newGUIContent("Realtime indirect bounce shadowing is not supported for Spot and Point lights.");
publicreadonlyGUIContentcookieWarning=newGUIContent("Cookie textures for spot lights should be set to clamp, not repeat, to avoid artifacts.");
// Additional light data
publicreadonlyGUIContentmaxSmoothness=newGUIContent("Max Smoothness","Very low cost way of faking spherical area lighting. This will modify the roughness of the material lit. This is useful when the specular highlight is too small or too sharp.");
publicreadonlyGUIContentaffectDiffuse=newGUIContent("Affect Diffuse","This will disable diffuse lighting for this light. Doesn't save performance, diffuse lighting is still computed.");
publicreadonlyGUIContentaffectSpecular=newGUIContent("Affect Specular","This will disable specular lighting for this light. Doesn't save performance, specular lighting is still computed.");
publicreadonlyGUIContentlightDimmer=newGUIContent("Dimmer","Aim to be used with script, timeline or animation. It allows dimming one or multiple lights of heterogeneous intensity easily (without needing to know the intensity of each light).");
publicreadonlyGUIContentfadeDistance=newGUIContent("Fade Distance","The distance at which the light will smoothly fade before being culled to minimize popping.");
publicreadonlyGUIContentspotInnerPercent=newGUIContent("Inner Percent","Controls size of the angular attenuation in percent of the base angle of the Spot light's cone.");
publicreadonlyGUIContentspotLightShape=newGUIContent("Shape","The shape use for the spotlight. Has an impact on the cookie transformation and light angular attenuation.");
publicreadonlyGUIContentshapeLengthLine=newGUIContent("Length","Length of the line light");
publicreadonlyGUIContentshapeLengthRect=newGUIContent("Size X","SizeX of the rectangle light");
publicreadonlyGUIContentshapeWidthRect=newGUIContent("Size Y","SizeY of the rectangle light");
publicreadonlyGUIContentapplyRangeAttenuation=newGUIContent("Apply Range Attenuation","Allows disabling range attenuation. This is useful indoor (like a room) to avoid having to setup a large range for a light to get correct inverse square attenuation that may leak out of the indoor");
publicreadonlyGUIContentshape=newGUIContent("Type","Specifies the current type of light. Possible types are Directional, Spot, Point, Rectangle and Line lights.");
publicreadonlyGUIContentshadowResolution=newGUIContent("Resolution","Controls the rendered resolution of the shadow maps. A higher resolution will increase the fidelity of shadows at the cost of GPU performance and memory usage.");
publicreadonlyGUIContentshadowFadeDistance=newGUIContent("Fade Distance","The shadow will fade at distance ShadowFadeDistance before being culled to minimize popping.");
publicreadonlyGUIContentshadowDimmer=newGUIContent("Dimmer","Aim to be use with script, timeline or animation. It allows dimming one or multiple shadows. This can also be used as an optimization to fit in shadow budget manually and minimize popping.");
publicStyles()
{
shapeNames=Enum.GetNames(typeof(LightShape))
.Select(x=>newGUIContent(x))
.ToArray();
}
}
staticStyless_Styles;
// Can't use a static initializer in case we need to create GUIStyle in the Styles class as
// these can only be created with an active GUI rendering context
// Note: If there is a need for an optimization in the future of this function, user can simply fill the materialList manually by commenting the code abode and
// adding to the list material they used in their game.
vargpuVP=gpuProj*worldToViewMatrix*Matrix4x4.Scale(newVector3(1.0f,1.0f,-1.0f));// Need to scale -1.0 on Z to match what is being done in the camera.wolrdToCameraMatrix API.