Skip to content

Commit ce68b27

Browse files
Adapt selection picker to URP (#657)
* Add dedicated render pass to render the selection picker lookup texture on URP * Add code path to selection picker to handle URP * Add missing meta file * Update version define for URP + clean up * Fix compiler issue + shader clean up * Set package requirement for URP shaders * Fix FacePickerURP shader so it doesn't picked hidden faces * Fix typo and EdgePicker shader for URP * Swap .cginc extension to .hlsl * Add changelog entry * Clean up * handling gizmos in scene view and cleaning some code around * Change LightMode tag for Vertices pass * reverting breaking change in the picking --------- Co-authored-by: Thomas Lopez <thomas.lopez@unity3d.com> Co-authored-by: Thomas Lopez <66317117+lopezt-unity@users.noreply.github.com>
1 parent 392f489 commit ce68b27

25 files changed

Lines changed: 844 additions & 11 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1515
### Fixed
1616

1717
- [UUM-133861] Fixed "Look rotation viewing vector is zero" log being spammed when holding shift while using a create tool such as Create Sprite.
18+
- [UUM-133859] Fixed an issue in URP projects where the Editor would recompile scripts when after a rectangle selection in ProBuilder.
1819
- [UUM-133530] Fixed the `Set Double Sided` custom action in the Editor Sample, which was previously remaining disabled.
1920
- [UUM-133530] Ensured that the context menu respects the value of `MenuAction.enabled`.
2021
- [UUM-133531] Fixed component icons in Light theme.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!114 &-6385779826880740979
4+
MonoBehaviour:
5+
m_ObjectHideFlags: 11
6+
m_CorrespondingSourceObject: {fileID: 0}
7+
m_PrefabInstance: {fileID: 0}
8+
m_PrefabAsset: {fileID: 0}
9+
m_GameObject: {fileID: 0}
10+
m_Enabled: 1
11+
m_EditorHideFlags: 0
12+
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
13+
m_Name:
14+
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Editor::UnityEditor.Rendering.Universal.AssetVersion
15+
version: 10
16+
--- !u!21 &2100000
17+
Material:
18+
serializedVersion: 8
19+
m_ObjectHideFlags: 0
20+
m_CorrespondingSourceObject: {fileID: 0}
21+
m_PrefabInstance: {fileID: 0}
22+
m_PrefabAsset: {fileID: 0}
23+
m_Name: EdgePickerURP
24+
m_Shader: {fileID: 4800000, guid: 5a6aaaf03bf583c4e9adee705d3255d7, type: 3}
25+
m_Parent: {fileID: 0}
26+
m_ModifiedSerializedProperties: 0
27+
m_ValidKeywords: []
28+
m_InvalidKeywords: []
29+
m_LightmapFlags: 5
30+
m_EnableInstancingVariants: 0
31+
m_DoubleSidedGI: 0
32+
m_CustomRenderQueue: -1
33+
stringTagMap: {}
34+
disabledShaderPasses:
35+
- MOTIONVECTORS
36+
m_LockedProperties:
37+
m_SavedProperties:
38+
serializedVersion: 3
39+
m_TexEnvs:
40+
- unity_Lightmaps:
41+
m_Texture: {fileID: 0}
42+
m_Scale: {x: 1, y: 1}
43+
m_Offset: {x: 0, y: 0}
44+
- unity_LightmapsInd:
45+
m_Texture: {fileID: 0}
46+
m_Scale: {x: 1, y: 1}
47+
m_Offset: {x: 0, y: 0}
48+
- unity_ShadowMasks:
49+
m_Texture: {fileID: 0}
50+
m_Scale: {x: 1, y: 1}
51+
m_Offset: {x: 0, y: 0}
52+
m_Ints: []
53+
m_Floats:
54+
- _QueueControl: 0
55+
- _QueueOffset: 0
56+
m_Colors:
57+
- _BaseColor: {r: 0, g: 0, b: 0, a: 1}
58+
- _Tint: {r: 0, g: 0, b: 0, a: 1}
59+
m_BuildTextureStacks: []
60+
m_AllowLocking: 1

Content/Resources/Materials/EdgePickerURP.mat.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!21 &2100000
4+
Material:
5+
serializedVersion: 8
6+
m_ObjectHideFlags: 0
7+
m_CorrespondingSourceObject: {fileID: 0}
8+
m_PrefabInstance: {fileID: 0}
9+
m_PrefabAsset: {fileID: 0}
10+
m_Name: FacePickerURP
11+
m_Shader: {fileID: 4800000, guid: 9cb691ed12f573842860b94cad8331e1, type: 3}
12+
m_Parent: {fileID: 0}
13+
m_ModifiedSerializedProperties: 0
14+
m_ValidKeywords: []
15+
m_InvalidKeywords: []
16+
m_LightmapFlags: 5
17+
m_EnableInstancingVariants: 0
18+
m_DoubleSidedGI: 0
19+
m_CustomRenderQueue: -1
20+
stringTagMap: {}
21+
disabledShaderPasses:
22+
- MOTIONVECTORS
23+
m_LockedProperties:
24+
m_SavedProperties:
25+
serializedVersion: 3
26+
m_TexEnvs:
27+
- unity_Lightmaps:
28+
m_Texture: {fileID: 0}
29+
m_Scale: {x: 1, y: 1}
30+
m_Offset: {x: 0, y: 0}
31+
- unity_LightmapsInd:
32+
m_Texture: {fileID: 0}
33+
m_Scale: {x: 1, y: 1}
34+
m_Offset: {x: 0, y: 0}
35+
- unity_ShadowMasks:
36+
m_Texture: {fileID: 0}
37+
m_Scale: {x: 1, y: 1}
38+
m_Offset: {x: 0, y: 0}
39+
m_Ints: []
40+
m_Floats:
41+
- _QueueControl: 0
42+
- _QueueOffset: 0
43+
m_Colors:
44+
- _BaseColor: {r: 0, g: 0, b: 0, a: 1}
45+
- _Tint: {r: 1, g: 1, b: 1, a: 1}
46+
m_BuildTextureStacks: []
47+
m_AllowLocking: 1
48+
--- !u!114 &4155378413201584216
49+
MonoBehaviour:
50+
m_ObjectHideFlags: 11
51+
m_CorrespondingSourceObject: {fileID: 0}
52+
m_PrefabInstance: {fileID: 0}
53+
m_PrefabAsset: {fileID: 0}
54+
m_GameObject: {fileID: 0}
55+
m_Enabled: 1
56+
m_EditorHideFlags: 0
57+
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
58+
m_Name:
59+
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Editor::UnityEditor.Rendering.Universal.AssetVersion
60+
version: 10

Content/Resources/Materials/FacePickerURP.mat.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!114 &-8161258857830796102
4+
MonoBehaviour:
5+
m_ObjectHideFlags: 11
6+
m_CorrespondingSourceObject: {fileID: 0}
7+
m_PrefabInstance: {fileID: 0}
8+
m_PrefabAsset: {fileID: 0}
9+
m_GameObject: {fileID: 0}
10+
m_Enabled: 1
11+
m_EditorHideFlags: 0
12+
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
13+
m_Name:
14+
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Editor::UnityEditor.Rendering.Universal.AssetVersion
15+
version: 10
16+
--- !u!21 &2100000
17+
Material:
18+
serializedVersion: 8
19+
m_ObjectHideFlags: 0
20+
m_CorrespondingSourceObject: {fileID: 0}
21+
m_PrefabInstance: {fileID: 0}
22+
m_PrefabAsset: {fileID: 0}
23+
m_Name: VertexPickerURP
24+
m_Shader: {fileID: 4800000, guid: 488491a14dff2924db58a2ddc0b9e26f, type: 3}
25+
m_Parent: {fileID: 0}
26+
m_ModifiedSerializedProperties: 0
27+
m_ValidKeywords: []
28+
m_InvalidKeywords: []
29+
m_LightmapFlags: 5
30+
m_EnableInstancingVariants: 0
31+
m_DoubleSidedGI: 0
32+
m_CustomRenderQueue: -1
33+
stringTagMap: {}
34+
disabledShaderPasses:
35+
- MOTIONVECTORS
36+
m_LockedProperties:
37+
m_SavedProperties:
38+
serializedVersion: 3
39+
m_TexEnvs:
40+
- unity_Lightmaps:
41+
m_Texture: {fileID: 0}
42+
m_Scale: {x: 1, y: 1}
43+
m_Offset: {x: 0, y: 0}
44+
- unity_LightmapsInd:
45+
m_Texture: {fileID: 0}
46+
m_Scale: {x: 1, y: 1}
47+
m_Offset: {x: 0, y: 0}
48+
- unity_ShadowMasks:
49+
m_Texture: {fileID: 0}
50+
m_Scale: {x: 1, y: 1}
51+
m_Offset: {x: 0, y: 0}
52+
m_Ints: []
53+
m_Floats:
54+
- _QueueControl: 0
55+
- _QueueOffset: 0
56+
m_Colors:
57+
- _BaseColor: {r: 0, g: 0, b: 0, a: 1}
58+
- _Tint: {r: 0, g: 0, b: 0, a: 1}
59+
m_BuildTextureStacks: []
60+
m_AllowLocking: 1

Content/Resources/Materials/VertexPickerURP.mat.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
Shader "Hidden/ProBuilder/EdgePickerURP"
2+
{
3+
SubShader
4+
{
5+
PackageRequirements
6+
{
7+
"com.unity.render-pipelines.universal": "17.0"
8+
}
9+
10+
Tags
11+
{
12+
"ProBuilderPicker"="EdgePass"
13+
"RenderType"="Opaque"
14+
"RenderPipeline"="UniversalPipeline"
15+
"Queue"="Geometry"
16+
"IgnoreProjector"="True"
17+
"DisableBatching"="True"
18+
}
19+
20+
Pass
21+
{
22+
Name "Edges"
23+
Tags { "LightMode"="ProBuilderPickerA" }
24+
ZTest Less
25+
ZWrite On
26+
Cull Off
27+
Blend Off
28+
29+
HLSLPROGRAM
30+
#pragma vertex vert
31+
#pragma fragment frag
32+
33+
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
34+
#include "ProBuilderCG_URP.hlsl"
35+
36+
struct Attributes
37+
{
38+
float4 positionOS : POSITION;
39+
float4 color : COLOR;
40+
};
41+
42+
struct Varyings
43+
{
44+
float4 positionCS : SV_POSITION;
45+
float4 color : COLOR;
46+
};
47+
48+
Varyings vert(Attributes input)
49+
{
50+
Varyings output;
51+
output.positionCS = UnityObjectToClipPosWithOffset(input.positionOS.xyz);
52+
output.color = input.color;
53+
return output;
54+
}
55+
56+
half4 frag(Varyings input) : SV_Target
57+
{
58+
clip(input.color.a - 0.75);
59+
return input.color;
60+
}
61+
ENDHLSL
62+
}
63+
}
64+
65+
// Fallback to built-in renderer version
66+
Fallback "Hidden/ProBuilder/EdgePicker"
67+
}

Content/Shader/EdgePickerURP.shader.meta

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
Shader "Hidden/ProBuilder/FacePickerURP"
2+
{
3+
SubShader
4+
{
5+
PackageRequirements
6+
{
7+
"com.unity.render-pipelines.universal": "17.0"
8+
}
9+
10+
Tags
11+
{
12+
"ProBuilderPicker"="Base"
13+
"RenderType"="Opaque"
14+
"RenderPipeline"="UniversalPipeline"
15+
"Queue"="Geometry"
16+
"DisableBatching"="True"
17+
}
18+
19+
Pass
20+
{
21+
Name "Base"
22+
Tags { "LightMode"="ProBuilderPickerA" }
23+
ZTest LEqual
24+
ZWrite On
25+
Cull Back
26+
Blend Off
27+
28+
HLSLPROGRAM
29+
#pragma vertex vert
30+
#pragma fragment frag
31+
32+
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
33+
#include "ProBuilderCG_URP.hlsl"
34+
35+
struct Attributes
36+
{
37+
float4 positionOS : POSITION;
38+
float4 color : COLOR;
39+
};
40+
41+
struct Varyings
42+
{
43+
float4 positionCS : SV_POSITION;
44+
float4 color : COLOR;
45+
};
46+
47+
Varyings vert(Attributes input)
48+
{
49+
Varyings output;
50+
51+
VertexPositionInputs positions = GetVertexPositionInputs(input.positionOS.xyz);
52+
output.positionCS = positions.positionCS;
53+
output.color = input.color;
54+
55+
return output;
56+
}
57+
58+
half4 frag(Varyings input) : SV_Target
59+
{
60+
return input.color;
61+
}
62+
ENDHLSL
63+
}
64+
}
65+
66+
// Fallback to built-in renderer version
67+
Fallback "Hidden/ProBuilder/FacePicker"
68+
}

0 commit comments

Comments
 (0)