summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2025-12-03 16:32:59 -0800
committeryum <yum.food.vr@gmail.com>2025-12-03 16:33:00 -0800
commit97b268b7f2a32b5917da5f7f1528619e2dcf362b (patch)
tree581c0e2550722e482e8639b0606d905b8469d203
parente8f64516cfd27bb0b6ec1bb866909300185a7507 (diff)
add glitter uv channel
-rw-r--r--2ner.shader1
-rw-r--r--glitter.cginc4
-rw-r--r--globals.cginc1
-rw-r--r--yum_pbr.cginc1
4 files changed, 6 insertions, 1 deletions
diff --git a/2ner.shader b/2ner.shader
index dede8d4..937c560 100644
--- a/2ner.shader
+++ b/2ner.shader
@@ -2227,6 +2227,7 @@ Shader "yum_food/2ner"
[HideInInspector] m_start_Glitter("Glitter", Float) = 0
[ThryToggle(_GLITTER)] _Glitter_Enabled("Enable", Float) = 0
[HDR] _Glitter_Color("Color", Color) = (1, 1, 1, 1)
+ [IntRange] _Glitter_UV_Channel("UV channel", Range(0, 3)) = 0
_Glitter_Emission("Emission", Color) = (1, 1, 1, 1)
_Glitter_Layers("Layers", Range(1, 5)) = 1
_Glitter_Grid_Size("Grid size", Float) = 1
diff --git a/glitter.cginc b/glitter.cginc
index a8e6aad..e8df133 100644
--- a/glitter.cginc
+++ b/glitter.cginc
@@ -7,6 +7,7 @@
struct GlitterParams {
float4 color;
+ float2 uv_channel;
uint layers;
float cell_size;
float size;
@@ -38,7 +39,8 @@ float4 getGlitter(v2f i, GlitterParams params, float3 normal) {
float c_acc = 0;
[loop]
for (uint layer_i = 0; layer_i < params.layers; layer_i++) {
- float2 p = i.uv01.xy + glitter_offset_vectors[layer_i] * params.cell_size * 0.5;
+ float2 uv = get_uv_by_channel(i, params.uv_channel);
+ float2 p = uv + glitter_offset_vectors[layer_i] * params.cell_size * 0.5;
float3 cell_id = float3(floor(p / params.cell_size), layer_i);
float cell_rand = rand3(cell_id*.0001);
diff --git a/globals.cginc b/globals.cginc
index 78f34cd..0c3b9ed 100644
--- a/globals.cginc
+++ b/globals.cginc
@@ -491,6 +491,7 @@ float _Focal_Length_Multiplier;
#if defined(_GLITTER)
float4 _Glitter_Color;
+float _Glitter_UV_Channel;
float3 _Glitter_Emission;
float _Glitter_Layers;
float _Glitter_Grid_Size;
diff --git a/yum_pbr.cginc b/yum_pbr.cginc
index f70f056..cec42d2 100644
--- a/yum_pbr.cginc
+++ b/yum_pbr.cginc
@@ -271,6 +271,7 @@ YumPbr GetYumPbr(v2f i, float3x3 tangentToWorld) {
#if (defined(FORWARD_BASE_PASS) || defined(FORWARD_ADD_PASS)) && defined(_GLITTER)
GlitterParams glitter_p;
glitter_p.color = _Glitter_Color;
+ glitter_p.uv_channel = _Glitter_UV_Channel;
glitter_p.layers = _Glitter_Layers;
glitter_p.cell_size = _Glitter_Grid_Size;
glitter_p.size = _Glitter_Size;