Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
* [Procedural Sky](Override-Procedural-Sky.md)
* [Volumetric Clouds](Override-Volumetric-Clouds.md)
* [Visual Environment](Override-Visual-Environment.md)
* [Volumes API](Volumes-API.md)
* Render Pipeline Settings
* [HDRP Asset](HDRP-Asset.md)
* [Frame Settings](Frame-Settings.md)
Expand Down Expand Up @@ -206,7 +205,11 @@
* [Scripting your own Custom Pass in C#](Custom-Pass-Scripting.md)
* [Troubleshooting](Custom-Pass-Troubleshooting.md)
* [Custom Material Inspector](hdrp-custom-material-inspector.md)
* [Creating and Editing Lights at Runtime](creating-and-editing-lights-at-runtime.md)
* [Creating a Decal Projector at Runtime](creating-a-decal-projector-at-runtime.md)
* [Adjusting Emissive Intensity at Runtime](adjusting-emissive-intensity-at-runtime.md)
* [Editing Frame Settings at Runtime](Frame-Settings-API.md)
* [Editing Volumes at Runtime](Volumes-API.md)
* [Render Graph](render-graph.md)
* [HDRP Glossary](Glossary.md)
* [Known Issues and How To Fix Them](Known-Issues.md)
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Adjusting emissive intensity at runtime

For High Definition Render Pipeline (HDRP) non-Shader Graph shaders, such as the [Lit](Lit-Shader.md), [Unlit](Unlit-Shader.md), and [Decal](Decal-Shader.md) shaders, changing the `_EmissiveIntensity` property does not have any effect at runtime. This is because `_EmissiveIntensity` is not an independent property. The shader only uses `_EmissiveIntensity` to serialize the property in the UI and stores the final result in the `_EmissiveColor` property. To edit the intensity of emissive materials, set the `_EmissiveColor` and multiply it by the intensity you want.

```
using UnityEngine;

public class EditEmissiveIntensityExample : MonoBehaviour
{
public GameObject m_EmissiveObject;

void Start()
{
float emissiveIntensity = 10;
Color emissiveColor = Color.green;
m_EmissiveObject.GetComponent<Renderer>().material.SetColor("_EmissiveColor", emissiveColor * emissiveIntensity);
}
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Creating a Decal Projector at runtime

The [Decal Projector](Decal-Projector.md) component enables you to project decals into an environment. When you create a Decal Projector at runtime, the workflow is slightly different to the workflow you usually use when instantiating [Prefabs](https://docs.unity3d.com/Manual/Prefabs.html).

Instantiating a new DecalProjector from a Prefab does not automatically create a new instance of the DecalProjector's material. If you spawn multiple instances of the DecalProjector and make changes in one of its materials, the changes affect every DecalProjector instance. In the usual Prefab workflow, Unity creates a new instance of the material with the new Prefab instance. To match this usual workflow you must manually create a new material from the Prefab when you instantiate a new DecalProjector instance. For an example of how to do this, see the following code sample.

```
using UnityEngine;
using UnityEngine.Rendering.HighDefinition;

public class CreateDecalProjectorExample : MonoBehaviour
{
public GameObject m_DecalProjectorPrefab;

void Start()
{
GameObject m_DecalProjectorObject = Instantiate(m_DecalProjectorPrefab);
DecalProjector m_DecalProjectorComponent = m_DecalProjectorObject.GetComponent<DecalProjector>();

// Creates a new material instance for the DecalProjector.
m_DecalProjectorComponent.material = new Material(m_DecalProjectorComponent.material);

}
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Creating and editing lights at runtime

The High Definition Render Pipeline (HDRP) extends Unity's [Light](https://docs.unity3d.com/Manual/class-Light.html) component with additional data and functionality. To do this, it adds the [HDAdditionalLightData](./api/UnityEngine.Rendering.HighDefinition.HDAdditionalLightData.html) component to the GameObject that the Light component is attached to. Because of this, you cannot create and edit Lights at runtime in the usual way. This document explains how to create an HDRP [Light](Light-Component.md) at runtime and how to edit its properties.

## Creating a new light

HDRP provides a utility function that adds a Light component to a GameObject, and sets up its dependencies. The function is `AddHDLight` and it takes an [HDLightTypeAndShape](./api/UnityEngine.Rendering.HighDefinition.HDLightTypeAndShape.html) as a parameter which sets the Light's type and shape.

```
using UnityEngine;
using UnityEngine.Rendering.HighDefinition;

public class HDLightCreationExample : MonoBehaviour
{
public GameObject m_Object;
void Start()
{
// Calls a Utility function to create an HDRP Light on a GameObject.
HDAdditionalLightData lightData = m_Object.AddHDLight(HDLightTypeAndShape.ConeSpot);

// Sets property values for the Light.
lightData.intensity = 5;
lightData.range = 1.5f;
lightData.SetSpotAngle(60);
}
}

```


## Editing an existing Light

HDRP does not use the data stored in the Light component. Instead it stores Light data in another component called `HDAdditionalLightData`. To access a property, use the `HDAdditionalLightData` component, even if the property is visible in the Light component Inspector. The following code sample changes the Light's intensity:

```
using UnityEngine;
using UnityEngine.Rendering.HighDefinition;

public class HDLightEditingExample : MonoBehaviour
{
public GameObject m_LightObject;

void Start()
{
HDAdditionalLightData lightData;
lightData = m_LightObject.GetComponent<HDAdditionalLightData>();
// The Light intensity is stored in HDAdditionalLightData.
lightData.intensity = 40f;
}
}
```