-
Notifications
You must be signed in to change notification settings - Fork 855
Hdrp/update decal handles pivot #3001
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
com.unity.render-pipelines.core/Editor/Gizmo/HierarchicalBox.cs
Outdated
Show resolved
Hide resolved
com.unity.render-pipelines.high-definition/Editor/Material/Decal/DecalProjectorEditor.cs
Show resolved
Hide resolved
com.unity.render-pipelines.high-definition/Editor/Material/Decal/DisplacableRectHandles.cs
Outdated
Show resolved
Hide resolved
com.unity.render-pipelines.high-definition/Editor/Material/Decal/ProjectedTransform.cs
Show resolved
Hide resolved
Bug with modifying Z Projection depth and resetting Z pivot |
Last commits are feedbacks from @SeanPuller . He will do another pass soon. |
Ok no more change beside the documentation. Remaining work (keeping ratio when scaling) will be in another PR for clarity. |
||**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.| | ||
||**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.| | ||
||**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.| | ||
||**Pivot / UV**|Move the pivot without moving the projection box. This alter the transform position.<br />Also, set the UV used on the projected texture.| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moves the decal's pivot point without moving the projection box. This changes the transform position.
Note this also sets the UV used on the projected texture.
| ----------------------- | ------------------------------------------------------------ | | ||
| **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**. | | ||
| **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. | | ||
| **Pivot** | The offset position of the transform regarding the projection box. Adjusting X and Y allows to make rotation of the projected texture around a specific position, while Z allows to have a specific offset in depth. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
* A box that describes the 3D size of the projector; the projector draws its decal on every Material inside the box. | ||
|
||
* An arrow that indicates the direction the projector faces. | ||
* An arrow that indicates the direction the projector faces. This arrow is on the pivot point. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The base of this arrow is on the pivot point.
^^
Assumed its the base, ignore this comment if it isn't
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good code overall :). I found minor things that I think you should double check before merging.
} | ||
|
||
/// <summary>Draw the rect.</summary> | ||
public void DrawRect(bool dottedLine = false, float sickness = .0f, float screenSpaceSize = 5f) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you meant thickness
instead of sickness
?
{ | ||
m_MonochromeFillColor = color; | ||
material.color = m_MonochromeFillColor; | ||
color.a = 1f; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In DisplacableRectHandles.baseColor
we also have the same alpha values, can have them declared somewhere? Just in case we want to change them will be equal in both places. Maybe a static function SetAlphaHandleValues()
?
{ | ||
if (min[axis] > max[axis]) | ||
{ | ||
// Control IDs in m_ControlIDs[0-3[ are for positive axes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo on the comment: [0-3]
if (!(obj is PositionHandleIds)) | ||
return false; | ||
|
||
var o = (PositionHandleIds)obj; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can avoid this second cast if you do:
if (!(obj is PositionHandleIds o))
return false;
// UV | ||
using (new Handles.DrawingScope(Matrix4x4.TRS(decalProjector.transform.position + decalProjector.transform.rotation * (decalProjector.offset - .5f * decalProjector.size), decalProjector.transform.rotation, Vector3.one))) | ||
{ | ||
Vector2 UVSize = new Vector2( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should name it uvSize
as it is a local variable
switch (theChangedEdge) | ||
{ | ||
case NamedEdge.Left: | ||
if (rightPosition.x < leftPosition.x) | ||
leftPosition.x = rightPosition.x; | ||
if (topPosition.y < bottomPosition.y) | ||
topPosition.y = bottomPosition.y = center.y; | ||
break; | ||
case NamedEdge.Right: | ||
if (rightPosition.x < leftPosition.x) | ||
rightPosition.x = leftPosition.x; | ||
if (topPosition.y < bottomPosition.y) | ||
topPosition.y = bottomPosition.y = center.y; | ||
break; | ||
case NamedEdge.Top: | ||
if (topPosition.y < bottomPosition.y) | ||
topPosition.y = bottomPosition.y; | ||
if (rightPosition.x < leftPosition.x) | ||
rightPosition.x = leftPosition.x = center.x; | ||
break; | ||
case NamedEdge.Bottom: | ||
if (topPosition.y < bottomPosition.y) | ||
bottomPosition.y = topPosition.y; | ||
if (rightPosition.x < leftPosition.x) | ||
rightPosition.x = leftPosition.x = center.x; | ||
break; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, another method will improve readability
EnsureEdgesFacingOutside();
using UnityEngine; | ||
using UnityEngine.Rendering; | ||
using UnityEngine.Rendering.HighDefinition; | ||
using UnityEditor.ShortcutManagement; | ||
using static UnityEditorInternal.EditMode; | ||
using UnityEditor.IMGUI.Controls; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
using System.Linq.Expressions; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you sort usings statements?
} | ||
else | ||
{ | ||
Quaternion arrowRotation = Quaternion.LookRotation(Vector3.down, Vector3.right); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where are you using arrowRotation
? I can not see it.
// PrefColor is the type to use to have a Color that is customizable inside the Preference/Colors panel. | ||
// Sadly it is internal so we must create it and grab color from it by reflection. | ||
Type prefColorType = typeof(Editor).Assembly.GetType("UnityEditor.PrefColor"); | ||
s_ColorPref = Activator.CreateInstance(prefColorType, new object[] { "HDRP/Decal", k_GizmoColorBase.r, k_GizmoColorBase.g, k_GizmoColorBase.b, k_GizmoColorBase.a }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @MaddalenaUnity wants to unify the colors under Rendering
, could you double check?
// Pivot | ||
using (new Handles.DrawingScope(fullColor, Matrix4x4.TRS(Vector3.zero, decalProjector.transform.rotation, Vector3.one))) | ||
{ | ||
EditorGUI.BeginChangeCheck(); | ||
Vector3 newPosition = ProjectedTransform.DrawHandles(decalProjector.transform.position, .5f * decalProjector.size.z - decalProjector.offset.z, decalProjector.transform.rotation); | ||
if (EditorGUI.EndChangeCheck()) | ||
{ | ||
needToRefreshDecalProjector = true; | ||
Undo.RecordObjects(new UnityEngine.Object[] { decalProjector, decalProjector.transform }, "Decal Projector Change"); | ||
|
||
// Both the DecalProjectorComponent, and the transform will be modified. | ||
// The undo system will automatically group all RecordObject() calls here into a single action. | ||
Undo.RecordObject(decalProjector.transform, "Decal Projector Change"); | ||
decalProjector.offset += Quaternion.Inverse(decalProjector.transform.rotation) * (decalProjector.transform.position - newPosition); | ||
decalProjector.transform.position = newPosition; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of //Pivot
, I think it will be clearer if you add it's own method. this also applies to //UV
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good improvements, thank you :)
@TomasKiniulis Above commit add missing public API to change pivot by script. Also add an helper to resize and use the pivot as center of the transformation. |
@TomasKiniulis > Add requested fallback when we switch edit mode and UV/Pivot is selected, we fallback on first edit mode now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verified the bugfixes and checked through the changes. Pivot and UV adjustment gizmos feels like a great addition for decals!
Some findings:
-
Depth is adjusted from from center when value is moved to 0 - which discussing with @RSlysz hard to do anything about, but could be adjusted in next QoL improvements pr, filed a ticket here: https://fogbugz.unity3d.com/f/cases/1308338/
-
Aside from pressing undo, there's no way to reset pivot position without changing position where decal is projected
-
"Modify the UV" button could benefit with an additional position gizmo(or a dot in the middle)
which would benefit if could be improved in future PRs
More info here: https://confluence.unity3d.com/display/HDRP/Update+Decal+Handles+Pivot
* [HDRP][Path Tracing] Improved volumetric scattering sampling #2840 * Update CHANGELOG.md * Fix HDRP tests with by enabling backbuffer instead of render texture (#2898) * add missing [UnityTest] attribute and use WaitForEndOfFrame * activate UseBackBuffer on SSR and SSAO scenes * update reference images for win editor * Update Vulkan linux screenshots * add missing config file to disable batch mode for DXR tests * increase VFX tests timeout to handle complex scenes with many shaders and XR variants Co-authored-by: Sebastien Lagarde <sebastien@unity3d.com> * Merge Hd/bugfix (#2928) * [HDRP] Fix coat normal space (#2888) * Fix coat normal space * Update CHANGELOG.md Co-authored-by: Sebastien Lagarde <sebastien@unity3d.com> * Avoid issues causing faulty transitions in shadows (resulting in no shadows with unconventional aspect ratio) (#2776) * Fixed volume component tooltips using the same parameter name (#2754) * Use the proper history info for Bicubic resampling in TAA (#2759) * Use proper info for previous buffer info * changelog * Fixed lookdev movement (#2757) Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * [HDRP] Fix issue with saving some quality settings in volume overrides (#2758) * Fix issue with saving some quality settings volume overrides * Fix typo in changelog Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * [HDRP] Fixed NullReferenceException in HDRenderPipeline.UpgradeResourcesIfNeeded (case 1292524) (#2765) * fix issue with confusing text (#2766) * Fix * Fix white dots * Changelog * Rename the sunrise icon to fix typo, causing issue with 2x resolution loading. (#2809) * [HDRP] Rename HDRP to HD Render Pipeline in menu item (#2819) * [HDRP] Update HDRP menu in shader graph * Update CHANGELOG.md * HDRP/Fix package version showing package after the last "verified" package (#2783) * Fix typo * Remove last version checker from wizard and add link to package manager instead * Update CHANGELOG.md * Update documentation * Update Render-Pipeline-Wizard.md Co-authored-by: Sebastien Lagarde <sebastien@unity3d.com> * Revert bad changelog merge * Update CHANGELOG.md * Update CHANGELOG.md Co-authored-by: Adrien de Tocqueville <adrien.tocqueville@unity3d.com> Co-authored-by: sebastienlagarde <sebastien@unity3d.com> Co-authored-by: Pavlos Mavridis <pavlos.mavridis@unity3d.com> Co-authored-by: John Parsaie <johnpa@unity3d.com> Co-authored-by: Remi Slysz <40034005+RSlysz@users.noreply.github.com> * Fixed invalid loop length for probe baking (case 1289680) (#2830) * Fixed invalid loop length for probe baking (case 1289680) # Conflicts: # com.unity.render-pipelines.high-definition/CHANGELOG.md # Conflicts: # com.unity.render-pipelines.high-definition/CHANGELOG.md * Update CHANGELOG.md Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Fix volumetric fog with XR single-pass (#2823) * fix volumetric fog with XR single-pass rendering * update changelog Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * [HDRP] Fix rendering issues for the first frame (#2836) * Fix first frame exposure, depth pyramid / AO * Update changelog * Comment * Typo * Add missing RenderGraphBuilder.ReadTexture call * Move ComputePackedMipChainInfo at the beginning of ExecuteWithRenderGraph Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Update 5001_Fog_FogFallback.png * Revert "Update 5001_Fog_FogFallback.png" This reverts commit 2653b9c. * Update 5001_Fog_FogFallback.unity * Fix AOV API for render graph (#2909) * Fix AOV api in rendergraph # Conflicts: # com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs * Update changelog * Fix a small discrepancy in the marker placement in light intensity sliders (#2924) * Update CHANGELOG.md * Fix issue with VT spewing errors when transparent and opaque are disabled (#2925) * Fix * Changelog Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Fixed a bug in the sphere-aabb light cluster (case 1294767). (#2920) Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Move EndCameraRendering callback out of the profiling scope (#2917) * Move EndCameraRendering callback out of the profiling scope * added a comment Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Fixed baked light being included into the ray tracing light cluster (case 1296203). (#2915) Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Handle all enums the same way for UI (#2913) Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Changed the message when the graphics device doesn't support ray tracing (case 1287355). (#2916) * [HDRP] Fix default blocks for Hair and Eye shader graphs (#2919) * Fixed default eye shader blocks * Fix missing emission block in hair shader * Updated changelog Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Init scene camera debug framesettings (#2931) * Fixed using the wrong method to define if a light should be included in the light cluster depending on its baking status. (#2932) * - Fixed using the wrong method to define if a light should be included in the light cluster depending on its baking status. * Update CHANGELOG.md Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * [HDRP] Change the behavior of custom passes when the volume is disabled (#2930) * Changed the behavior of custom passes when the Custom Pass Volume component is disabled * Updated changelog * Fixed display of LOD Bias and maximum level in frame settings when using Quality Levels (#2921) * Fixed display of LOD Bias and maximum level in frame settings when using Quality Levels * Update changelog Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Fixed an issue when trying to open a look dev env library when Look Dev is not supported. (#2929) * Fixed an issue when trying to open a look dev env library when Look Dev is not supported. * Update changelog Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Enable Reflector for Spotlight by default * - Fixed shader graph not supporting indirectdxr multibounce (case 1294694). (#2933) Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Fixed the planar depth texture not being properly created and rendered to (case 1299617). (#2926) * Fixed the planar depth texture not being properly created and rendered to (case 1299617). * adding comment Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Fixed C# 8 compilation issue with turning on nullable checks (case 1300167) (#2949) * Fixed C# 8 compilation issue with turning on nullable checks - bis (#2951) * Fixed C# 8 compilation issue with turning on nullable checks (case 1300167) * Update MaterialDebug.cs * Fix scripting light test with enableReflector true by default * Fixed affects AO for deacl materials (#2950) Co-authored-by: sebastienlagarde <sebastien@unity3d.com> * Fixed case where material keywords would not get setup before usage (#2961) * Update CHANGELOG.md Co-authored-by: Antoine Lelievre <antoinel@unity3d.com> Co-authored-by: FrancescoC-unity <43168857+FrancescoC-unity@users.noreply.github.com> Co-authored-by: Adrien de Tocqueville <adrien.tocqueville@unity3d.com> Co-authored-by: Pavlos Mavridis <pavlos.mavridis@unity3d.com> Co-authored-by: John Parsaie <johnpa@unity3d.com> Co-authored-by: Remi Slysz <40034005+RSlysz@users.noreply.github.com> Co-authored-by: Frédéric Vauchelles <55485372+fredericv-unity3d@users.noreply.github.com> Co-authored-by: Fabien Houlmann <44069206+fabien-unity@users.noreply.github.com> Co-authored-by: anisunity <42026998+anisunity@users.noreply.github.com> Co-authored-by: JulienIgnace-Unity <julien@unity3d.com> * Merge Hd/bugfix #2973 * Slight modification of 103_ReflectionQuality test to increase coverage with multibounce RTR (#2978) * Slight modify of test * reference image update * Fixed an issue with material using distortion from ShaderGraph init after Material creation (case 1294026) #2982 * Enable GetSamplePosition on metal (#2988) * HDRP docs bugfixes #2993 * Improved reflector property tooltip (#2994) * Fixed light reflector typo * Updated tooltip text to be more specific. Co-authored-by: Lewis Jordan <lewisjordan@unity3d.com> * Fix timing issues with accumulation motion blur #2999 * Hdrp/update decal handles pivot #3001 * fix alpha test screenshots * Formatting Co-authored-by: Emmanuel Turquin <emmanuel@turquin.org> Co-authored-by: Fabien Houlmann <44069206+fabien-unity@users.noreply.github.com> Co-authored-by: Antoine Lelievre <antoinel@unity3d.com> Co-authored-by: FrancescoC-unity <43168857+FrancescoC-unity@users.noreply.github.com> Co-authored-by: Adrien de Tocqueville <adrien.tocqueville@unity3d.com> Co-authored-by: Pavlos Mavridis <pavlos.mavridis@unity3d.com> Co-authored-by: John Parsaie <johnpa@unity3d.com> Co-authored-by: Remi Slysz <40034005+RSlysz@users.noreply.github.com> Co-authored-by: Frédéric Vauchelles <55485372+fredericv-unity3d@users.noreply.github.com> Co-authored-by: anisunity <42026998+anisunity@users.noreply.github.com> Co-authored-by: JulienIgnace-Unity <julien@unity3d.com> Co-authored-by: Rémi Chapelain <57442369+remi-chapelain@users.noreply.github.com> Co-authored-by: Lewis Jordan <lewis.jordan@hotmail.co.uk> Co-authored-by: Lewis Jordan <lewisjordan@unity3d.com>
Purpose of this PR
This PR add the missing customizable pivot to Decals. It is required for placement snapping and finely tuning rotation point.
This contains the following changes:
This also fix:
Testing status
Tested the handles of previous edit mode and new edit mode with
In all above cases, it seams to behave correctly.
Tested that changing the Transform's rotation make the projection volume rotate around the pivot as intended.
Tested color and face intensity change along the color set in the preference.
Tested Undo/Redo on edition by handle of the pivot point (with new edit mode)
Comments to reviewers
ColorPref are internal and cannot be directly used. I kinda hacked it by using them with reflection and Activator. It is not a nice integration but it seams to work. Particularly because the color list seams to be updated each time the window is enabled. So AFAIK what I have done should work fine.
Also, the default color provided to the ColorPref is the same than now. So this should not change on users at update without them actively modifying it.
To do this I had to tweek a little the HierarchicalBox used also for DensityVolume and ReflectionProbe's gizmo/handle. The change is minor and should not affect the behaviour of those.
All modification are only on the Editor manipulation side. So there is no actual change of the projection volume computation code. Which means that there is no need to migrate any data, they should still work fine. Though a test on that could be nice to be 100% sure.
@SeanPuller for awareness
@qa After discussion with @MaddalenaUnity , the color is not under HDRP but under Scene