Skip to content

Commit 94020c5

Browse files
RSlyszsebastienlagarde
authored andcommitted
Hdrp/update decal handles pivot #3001
1 parent 3ec3b09 commit 94020c5

File tree

16 files changed

+960
-196
lines changed

16 files changed

+960
-196
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
using UnityEngine;
3+
4+
namespace UnityEditor.Rendering
5+
{
6+
public static class GizmoUtility
7+
{
8+
public static Color GetHandleColor(Color baseColor)
9+
{
10+
baseColor.a = 1f;
11+
return baseColor;
12+
}
13+
14+
public static Color GetWireframeColor(Color baseColor)
15+
{
16+
baseColor.a = .7f;
17+
return baseColor;
18+
}
19+
20+
public static Color GetWireframeColorBehindObjects(Color baseColor)
21+
{
22+
baseColor.a = .2f;
23+
return baseColor;
24+
}
25+
}
26+
}

com.unity.render-pipelines.core/Editor/Gizmo/GizmoUtility.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

com.unity.render-pipelines.core/Editor/Gizmo/HierarchicalBox.cs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,24 @@ public Color baseColor
115115
set
116116
{
117117
value.a = 8f / 255;
118-
m_MonochromeFillColor = value;
119-
material.color = m_MonochromeFillColor;
120-
value.a = 1f;
121-
m_MonochromeHandleColor = value;
122-
value.a = 0.7f;
123-
m_WireframeColor = value;
124-
value.a = 0.2f;
125-
m_WireframeColorBehind = value;
118+
SetBaseColor(value);
126119
}
127120
}
128121

122+
/// <summary>
123+
/// Set the baseColor used to fill hull. All other colors are deduced from it except specific handle colors.
124+
/// Instead of <see cref="baseColor">baseColor</see> set, this will not force the opacity and keep what is provided for the filled faces.
125+
/// </summary>
126+
/// <param name="color">The color to use</param>
127+
public void SetBaseColor(Color color)
128+
{
129+
m_MonochromeFillColor = color;
130+
material.color = m_MonochromeFillColor;
131+
m_MonochromeHandleColor = GizmoUtility.GetHandleColor(color);
132+
m_WireframeColor = GizmoUtility.GetWireframeColor(color);
133+
m_WireframeColorBehind = GizmoUtility.GetWireframeColorBehindObjects(color);
134+
}
135+
129136
//Note: Handles.Slider not allow to use a specific ControlID.
130137
//Thus Slider1D is used (with reflection)
131138
static Type k_Slider1D = Type.GetType("UnityEditorInternal.Slider1D, UnityEditor");

com.unity.render-pipelines.high-definition/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1717
- Added support for raytracing for AxF material
1818
- Added rasterized area light shadows for AxF material
1919
- Added View Bias for mesh decals.
20+
- Added pivot point manipulation for Decals (inspector and edit mode).
21+
- Added UV manipulation for Decals (edit mode).
22+
- Added color and intensity customization for Decals.
2023

2124
### Fixed
2225
- Fixed probe volumes debug views.
@@ -46,6 +49,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
4649
- Removed the upscale radius from the RTR.
4750
- Improved robustness of volumetric sampling in path tracing (case 1295187).
4851
- Changed the convergence time of ssgi to 16 frames and the preset value
52+
- Removed the material pass probe volumes evaluation mode.
4953

5054
## [10.3.0] - 2020-12-01
5155

com.unity.render-pipelines.high-definition/Documentation~/Decal-Projector.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,33 @@ The Decal Projector includes a Scene view representation of its bounds and proje
1414

1515
* A box that describes the 3D size of the projector; the projector draws its decal on every Material inside the box.
1616

17-
* An arrow that indicates the direction the projector faces.
17+
* An arrow that indicates the direction the projector faces. The base of this arrow is on the pivot point.
1818

1919
![](Images/DecalProjector2.png)
2020

21-
The decal Projector also includes two gizmos that add handles on every face for you to click and drag to alter the size of the projector's bounds.
21+
The decal Projector also includes three gizmos. The first two add handles on every face for you to click and drag to alter the size of the projector's bounds.
2222

2323
|**Button**|**Gizmo**|**Description**|
2424
|-----|-----|-----|
25-
|![](Images/DecalProjector3.png)|**Scale**|Scales the decal with the projector box. This changes the UVs of the Material to match the size of the projector box. This stretches the decal.|
26-
|![](Images/DecalProjector4.png)|**Crop**|Crops the decal with the projector box. This changes the size of the projector box but not the UVs of the Material. This crops the decal.|
25+
|![](Images/DecalProjector3.png)|**Scale**|Scales the decal with the projector box. This changes the UVs of the Material to match the size of the projector box. This stretches the decal. The Pivot remains still.|
26+
|![](Images/DecalProjector4.png)|**Crop**|Crops the decal with the projector box. This changes the size of the projector box but not the UVs of the Material. This crops the decal. The Pivot remains still.|
27+
|![](Images/DecalProjector5.png)|**Pivot / UV**|Moves the decal's pivot point without moving the projection box. This changes the transform position.<br/>Note this also sets the UV used on the projected texture.|
28+
29+
The color of the gizmos can be set up in the Preference window inside Color panel.
2730

2831
## Using the Inspector
2932

3033
Using the Inspector allows you to change all of the Decal Projector properties, and lets you use numerical values for **Size**, **Tiling**, and **Offset**, which allows for greater precision than the click-and-drag gizmo method.
3134

3235
## Properties
3336

34-
![](Images/DecalProjector5.png)
37+
![](Images/DecalProjector6.png)
3538

3639
| **Property** | **Description** |
3740
| ----------------------- | ------------------------------------------------------------ |
3841
| **Size** | The size of the projector influence box, and thus the decal along the projected plane. The projector scales the decal to match the **Width** (along the local x-axis) and **Height** (along the local y-axis) components of the **Size**. |
3942
| **Projection Depth** | The depth of the projector influence box. The projector scales the decal to match **Projection Depth**. The Decal Projector component projects decals along the local z-axis. |
43+
| **Pivot** | The offset position of the transform regarding the projection box. To rotate the projected texture around a specific position, adjust the **X** and **Y** values. To set a depth offset for the projected texture, adjust the **Z** value. |
4044
| **Material** | The decal Material to project. The decal Material must use a HDRP/Decal Shader. |
4145
| **Decal Layer** | The layer that specifies the Materials to project the decal onto. Any Mesh Renderers or Terrain that uses a matching Decal Layer receives the decal. |
4246
| **Draw Distance** | The distance from the Camera to the Decal at which this projector stops projecting the decal and HDRP no longer renders the decal. |
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading

com.unity.render-pipelines.high-definition/Editor/Material/Decal/DecalProjectorEditor.Skin.cs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ partial class DecalProjectorEditor
66
{
77
const string k_EditShapePreservingUVTooltip = "Modifies the projector boundaries and crops/tiles the decal to fill them.";
88
const string k_EditShapeWithoutPreservingUVTooltip = "Modifies the projector boundaries and stretches the decal to fill them.";
9-
const string k_EditUVTooltip = "Modify the UV positions only";
9+
const string k_EditUVTooltip = "Modify the UV and the pivot position without moving the projection box. It can alter Transform.";
1010

1111
static readonly GUIContent k_SizeContent = EditorGUIUtility.TrTextContent("Size", "Sets the size of the projector.");
1212
static readonly GUIContent[] k_SizeSubContent = new[]
@@ -24,16 +24,8 @@ partial class DecalProjectorEditor
2424
static readonly GUIContent k_UVBiasContent = EditorGUIUtility.TrTextContent("Offset", "Sets the offset for the decal Material. Moves the decal along its UV axes.");
2525
static readonly GUIContent k_FadeFactorContent = EditorGUIUtility.TrTextContent("Fade Factor", "Controls the transparency of the decal.");
2626
static readonly GUIContent k_AffectTransparentContent = EditorGUIUtility.TrTextContent("Affects Transparent", "When enabled, HDRP draws this projector's decal on top of transparent surfaces.");
27+
static readonly GUIContent k_Offset = EditorGUIUtility.TrTextContent("Pivot", "Controls the position of the pivot point of the decal.");
2728

28-
public static readonly Color k_GizmoColorBase = Color.white;
29-
public static readonly Color[] k_BaseHandlesColor = new Color[]
30-
{
31-
Color.white,
32-
Color.white,
33-
Color.white,
34-
Color.white,
35-
Color.white,
36-
Color.white
37-
};
29+
public static readonly Color k_GizmoColorBase = new Color(1, 1, 1, 8f / 255);
3830
}
3931
}

0 commit comments

Comments
 (0)