Skip to content

Commit 351f44a

Browse files
svc-reach-platform-supportEvergreen
authored andcommitted
[Port] [6000.3] [SRP] Fix RSUV Sample
1 parent 26fc38b commit 351f44a

9 files changed

Lines changed: 6511 additions & 86 deletions

File tree

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
{
2+
"m_SGVersion": 3,
3+
"m_Type": "UnityEditor.ShaderGraph.GraphData",
4+
"m_ObjectId": "a42a90e435fa487c87108a7b28c61d3d",
5+
"m_Properties": [],
6+
"m_Keywords": [],
7+
"m_Dropdowns": [],
8+
"m_CategoryData": [
9+
{
10+
"m_Id": "0c2e247e8af94197813fde28b5374908"
11+
}
12+
],
13+
"m_Nodes": [
14+
{
15+
"m_Id": "ce1c1b2016d04364bb782648326a1b72"
16+
},
17+
{
18+
"m_Id": "0c5f8a1a1e124477ac6e8ef7868354b1"
19+
}
20+
],
21+
"m_GroupDatas": [],
22+
"m_StickyNoteDatas": [],
23+
"m_Edges": [
24+
{
25+
"m_OutputSlot": {
26+
"m_Node": {
27+
"m_Id": "0c5f8a1a1e124477ac6e8ef7868354b1"
28+
},
29+
"m_SlotId": 0
30+
},
31+
"m_InputSlot": {
32+
"m_Node": {
33+
"m_Id": "ce1c1b2016d04364bb782648326a1b72"
34+
},
35+
"m_SlotId": 2
36+
}
37+
}
38+
],
39+
"m_VertexContext": {
40+
"m_Position": {
41+
"x": 0.0,
42+
"y": 0.0
43+
},
44+
"m_Blocks": []
45+
},
46+
"m_FragmentContext": {
47+
"m_Position": {
48+
"x": 0.0,
49+
"y": 0.0
50+
},
51+
"m_Blocks": []
52+
},
53+
"m_PreviewData": {
54+
"serializedMesh": {
55+
"m_SerializedMesh": "{\"mesh\":{\"instanceID\":0}}",
56+
"m_Guid": ""
57+
},
58+
"preventRotation": false
59+
},
60+
"m_Path": "Sub Graphs",
61+
"m_GraphPrecision": 1,
62+
"m_PreviewMode": 2,
63+
"m_OutputNode": {
64+
"m_Id": "ce1c1b2016d04364bb782648326a1b72"
65+
},
66+
"m_SubDatas": [],
67+
"m_ActiveTargets": []
68+
}
69+
70+
{
71+
"m_SGVersion": 0,
72+
"m_Type": "UnityEditor.ShaderGraph.CategoryData",
73+
"m_ObjectId": "0c2e247e8af94197813fde28b5374908",
74+
"m_Name": "",
75+
"m_ChildObjectList": []
76+
}
77+
78+
{
79+
"m_SGVersion": 1,
80+
"m_Type": "UnityEditor.ShaderGraph.CustomFunctionNode",
81+
"m_ObjectId": "0c5f8a1a1e124477ac6e8ef7868354b1",
82+
"m_Group": {
83+
"m_Id": ""
84+
},
85+
"m_Name": "GetColor (Custom Function)",
86+
"m_DrawState": {
87+
"m_Expanded": true,
88+
"m_Position": {
89+
"serializedVersion": "2",
90+
"x": -88.66667938232422,
91+
"y": -0.0000075997850217390809,
92+
"width": 206.00001525878907,
93+
"height": 96.0
94+
}
95+
},
96+
"m_Slots": [
97+
{
98+
"m_Id": "b4f1fd4d60cb490f9dc8d744619a337d"
99+
}
100+
],
101+
"synonyms": [
102+
"code",
103+
"HLSL"
104+
],
105+
"m_Precision": 1,
106+
"m_PreviewExpanded": false,
107+
"m_DismissedVersion": 0,
108+
"m_PreviewMode": 0,
109+
"m_CustomColors": {
110+
"m_SerializableColors": []
111+
},
112+
"m_SourceType": 0,
113+
"m_FunctionName": "GetColor",
114+
"m_FunctionSource": "3f5ad0d251b7b794997e01f67893b6b8",
115+
"m_FunctionSourceUsePragmas": true,
116+
"m_FunctionBody": "Enter function body here..."
117+
}
118+
119+
{
120+
"m_SGVersion": 0,
121+
"m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot",
122+
"m_ObjectId": "72640d7d8e0a4d169c0628904f7fcf39",
123+
"m_Id": 2,
124+
"m_DisplayName": "Color",
125+
"m_SlotType": 0,
126+
"m_Hidden": false,
127+
"m_ShaderOutputName": "Color",
128+
"m_StageCapability": 3,
129+
"m_Value": {
130+
"x": 0.0,
131+
"y": 0.0,
132+
"z": 0.0,
133+
"w": 0.0
134+
},
135+
"m_DefaultValue": {
136+
"x": 0.0,
137+
"y": 0.0,
138+
"z": 0.0,
139+
"w": 0.0
140+
},
141+
"m_Labels": []
142+
}
143+
144+
{
145+
"m_SGVersion": 0,
146+
"m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot",
147+
"m_ObjectId": "b4f1fd4d60cb490f9dc8d744619a337d",
148+
"m_Id": 0,
149+
"m_DisplayName": "Color",
150+
"m_SlotType": 1,
151+
"m_Hidden": false,
152+
"m_ShaderOutputName": "Color",
153+
"m_StageCapability": 3,
154+
"m_Value": {
155+
"x": 0.0,
156+
"y": 0.0,
157+
"z": 0.0,
158+
"w": 0.0
159+
},
160+
"m_DefaultValue": {
161+
"x": 0.0,
162+
"y": 0.0,
163+
"z": 0.0,
164+
"w": 0.0
165+
},
166+
"m_Labels": []
167+
}
168+
169+
{
170+
"m_SGVersion": 0,
171+
"m_Type": "UnityEditor.ShaderGraph.SubGraphOutputNode",
172+
"m_ObjectId": "ce1c1b2016d04364bb782648326a1b72",
173+
"m_Group": {
174+
"m_Id": ""
175+
},
176+
"m_Name": "Output",
177+
"m_DrawState": {
178+
"m_Expanded": true,
179+
"m_Position": {
180+
"serializedVersion": "2",
181+
"x": 200.0,
182+
"y": 0.0,
183+
"width": 0.0,
184+
"height": 0.0
185+
}
186+
},
187+
"m_Slots": [
188+
{
189+
"m_Id": "72640d7d8e0a4d169c0628904f7fcf39"
190+
}
191+
],
192+
"synonyms": [],
193+
"m_Precision": 0,
194+
"m_PreviewExpanded": true,
195+
"m_DismissedVersion": 0,
196+
"m_PreviewMode": 0,
197+
"m_CustomColors": {
198+
"m_SerializableColors": []
199+
},
200+
"IsFirstSlotValid": true
201+
}
202+

Packages/com.unity.render-pipelines.core/Samples~/RendererShaderUserValue_Common/Materials/SubGraphs/GetColorRSUV.shadersubgraph.meta

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

Packages/com.unity.render-pipelines.core/Samples~/RendererShaderUserValue_Common/Models/Agora/SM_Generic_Grass_Patch_01.fbx.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Packages/com.unity.render-pipelines.core/Samples~/RendererShaderUserValue_Common/Models/Agora/SM_Generic_Grass_Patch_02.fbx.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Packages/com.unity.render-pipelines.core/Samples~/RendererShaderUserValue_Common/Models/Agora/SM_Generic_Grass_Patch_03.fbx.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Packages/com.unity.render-pipelines.core/Samples~/RendererShaderUserValue_Common/Scripts/CustomFunctions/FunctionsRSUV.hlsl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ void GetTexture2DArraySize_float(UnityTexture2DArray texture2DArray, out float W
99
Height = h;
1010
}
1111

12+
void GetColor_float(out float4 Color)
13+
{
14+
uint data = GetData();
15+
Color = DecodeUintToFloat4(data);
16+
}
17+
1218
void GetRendererShaderUserValueHealth_float(out float Health, out bool ShowHealthBar, out float HealthBarOpacity)
1319
{
1420
uint data = GetData();

Packages/com.unity.render-pipelines.core/Samples~/RendererShaderUserValue_Common/Scripts/HelpersRSUV.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,19 @@ public static int DecodeData(uint value, int bitOffset, int length)
5959
// Encode a Color32 type into the full raw uint
6060
public static uint EncodeData(Color32 color)
6161
{
62-
return ((uint)color.r << 24) |
63-
((uint)color.g << 16) |
64-
((uint)color.b << 8) |
65-
(uint)color.a;
62+
return ((uint)color.r << 16) |
63+
((uint)color.g << 8) |
64+
((uint)color.b << 0) |
65+
(uint)color.a << 24;
6666
}
6767

6868
// Encode a Color type into the full raw uint
6969
public static uint EncodeData(Color color)
7070
{
71-
byte r = (byte)(Mathf.Clamp01(color.r) * 255f);
72-
byte g = (byte)(Mathf.Clamp01(color.g) * 255f);
73-
byte b = (byte)(Mathf.Clamp01(color.b) * 255f);
74-
byte a = (byte)(Mathf.Clamp01(color.a) * 255f);
71+
byte r = (byte)(Mathf.Clamp01(color.linear.r) * 255f);
72+
byte g = (byte)(Mathf.Clamp01(color.linear.g) * 255f);
73+
byte b = (byte)(Mathf.Clamp01(color.linear.b) * 255f);
74+
byte a = (byte)(Mathf.Clamp01(color.linear.a) * 255f);
7575

7676
return EncodeData(new Color32(r, g, b, a));
7777
}

0 commit comments

Comments
 (0)