diff options
| author | yum <yum.food.vr@gmail.com> | 2025-04-18 13:00:48 -0700 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2025-04-18 13:00:48 -0700 |
| commit | 66c73e2634fb9e652728a405a9104318d051bb00 (patch) | |
| tree | 4e3f8a6cc058fb110812c86732cf459210e52a1d | |
| parent | a522e7738d75e84cc1ee1491a098421622ef1918 (diff) | |
add 2 more uv channels
| -rw-r--r-- | 2ner.cginc | 4 | ||||
| -rw-r--r-- | 2ner.shader | 8 | ||||
| -rw-r--r-- | decals.cginc | 5 | ||||
| -rw-r--r-- | interpolators.cginc | 17 | ||||
| -rw-r--r-- | tessellation.cginc | 1 | ||||
| -rw-r--r-- | texture_utils.cginc | 6 |
6 files changed, 28 insertions, 13 deletions
@@ -132,11 +132,15 @@ v2f vert(appdata v) { #endif
o.uv01.xy = v.uv0;
o.uv01.zw = v.uv1;
+ o.uv23.xy = v.uv2;
+ o.uv23.zw = v.uv3;
#if defined(_MIRROR_UVS_IN_MIRROR)
[branch]
if (isInMirror()) {
o.uv01.x = 1.0 - o.uv01.x;
o.uv01.z = 1.0 - o.uv01.z;
+ o.uv23.x = 1.0 - o.uv23.x;
+ o.uv23.z = 1.0 - o.uv23.z;
}
#endif
o.worldPos = mul(unity_ObjectToWorld, v.vertex);
diff --git a/2ner.shader b/2ner.shader index 55d08a4..0b8c951 100644 --- a/2ner.shader +++ b/2ner.shader @@ -297,7 +297,7 @@ Shader "yum_food/2ner" _Decal0_MainTex("Base color", 2D) = "white" {} _Decal0_Opacity("Opacity", Range(0, 1)) = 1.0 _Decal0_Angle("Angle", Range(0, 1)) = 0.0 - _Decal0_UV_Channel("UV channel", Range(0, 1)) = 0 + _Decal0_UV_Channel("UV channel", Range(0, 3)) = 0 [ThryToggle(_DECAL0_TILING_MODE)] _Decal0_Tiling_Mode("Tiling mode", Float) = 0 [ThryToggle(_DECAL0_REPLACE_ALPHA)] _Decal0_Replace_Alpha_Mode("Replace alpha", Float) = 0 //ifex _Decal0_Normal_Enabled==0 @@ -339,7 +339,7 @@ Shader "yum_food/2ner" _Decal1_MainTex("Base color", 2D) = "white" {} _Decal1_Opacity("Opacity", Range(0, 1)) = 1.0 _Decal1_Angle("Angle", Range(0, 1)) = 0.0 - _Decal1_UV_Channel("UV channel", Range(0, 1)) = 0 + _Decal1_UV_Channel("UV channel", Range(0, 3)) = 0 [ThryToggle(_DECAL1_TILING_MODE)] _Decal1_Tiling_Mode("Tiling mode", Float) = 0 [ThryToggle(_DECAL1_REPLACE_ALPHA)] _Decal1_Replace_Alpha_Mode("Replace alpha", Float) = 0 //ifex _Decal1_Normal_Enabled==0 @@ -381,7 +381,7 @@ Shader "yum_food/2ner" _Decal2_MainTex("Base color", 2D) = "white" {} _Decal2_Opacity("Opacity", Range(0, 1)) = 1.0 _Decal2_Angle("Angle", Range(0, 1)) = 0.0 - _Decal2_UV_Channel("UV channel", Range(0, 1)) = 0 + _Decal2_UV_Channel("UV channel", Range(0, 3)) = 0 [ThryToggle(_DECAL2_TILING_MODE)] _Decal2_Tiling_Mode("Tiling mode", Float) = 0 [ThryToggle(_DECAL2_REPLACE_ALPHA)] _Decal2_Replace_Alpha_Mode("Replace alpha", Float) = 0 //ifex _Decal2_Normal_Enabled==0 @@ -423,7 +423,7 @@ Shader "yum_food/2ner" _Decal3_MainTex("Base color", 2D) = "white" {} _Decal3_Opacity("Opacity", Range(0, 1)) = 1.0 _Decal3_Angle("Angle", Range(0, 1)) = 0.0 - _Decal3_UV_Channel("UV channel", Range(0, 1)) = 0 + _Decal3_UV_Channel("UV channel", Range(0, 3)) = 0 [ThryToggle(_DECAL3_TILING_MODE)] _Decal3_Tiling_Mode("Tiling mode", Float) = 0 [ThryToggle(_DECAL3_REPLACE_ALPHA)] _Decal3_Replace_Alpha_Mode("Replace alpha", Float) = 0 //ifex _Decal3_Normal_Enabled==0 diff --git a/decals.cginc b/decals.cginc index 59ab085..60968af 100644 --- a/decals.cginc +++ b/decals.cginc @@ -4,6 +4,7 @@ #include "features.cginc"
#include "globals.cginc"
#include "math.cginc"
+#include "texture_utils.cginc"
// Struct to hold all decal parameters
struct DecalParams {
@@ -58,7 +59,7 @@ struct DecalParams { sin(params.angle * TAU), cos(params.angle * TAU) \
); \
\
- float2 raw_decal_uv = (params.uv_channel == 0) ? i.uv01.xy : i.uv01.zw; \
+ float2 raw_decal_uv = get_uv_by_channel(i, params.uv_channel); \
float2 decal_uv = (raw_decal_uv * params.mainTex_ST.xy + params.mainTex_ST.zw); \
decal_uv = mul(decal_rot, decal_uv); \
decal_uv = (params.tiling_mode == DECAL_TILING_MODE_CLAMP ? saturate(decal_uv) : decal_uv);
@@ -90,7 +91,7 @@ struct DecalParams { #define APPLY_DECAL_SEC02_CLAMP_OFF(i, albedo, normal_tangent, metallic, smoothness, params) {}
#define APPLY_DECAL_SEC03_MASK_ON(i, albedo, normal_tangent, metallic, smoothness, params) \
- float decal_mask = params.mask.Sample(linear_repeat_s, raw_decal_uv); \
+ float decal_mask = params.mask.SampleLevel(linear_repeat_s, raw_decal_uv, 0); \
decal_albedo.a *= decal_mask;
#define APPLY_DECAL_SEC03_MASK_OFF(i, albedo, normal_tangent, metallic, smoothness, params) \
diff --git a/interpolators.cginc b/interpolators.cginc index 59f339a..aaca5fb 100644 --- a/interpolators.cginc +++ b/interpolators.cginc @@ -7,6 +7,8 @@ struct appdata { float4 vertex : POSITION;
float2 uv0 : TEXCOORD0;
float2 uv1 : TEXCOORD1;
+ float2 uv2 : TEXCOORD2;
+ float2 uv3 : TEXCOORD3;
float3 normal : NORMAL;
float4 tangent : TANGENT;
@@ -19,13 +21,14 @@ struct v2f { #endif
linear noperspective centroid float4 pos : SV_POSITION;
float4 uv01 : TEXCOORD0;
- float4 objPos : TEXCOORD1;
- float3 worldPos : TEXCOORD2;
- float3 normal : TEXCOORD3;
- float3 tangent : TEXCOORD4;
- float3 binormal : TEXCOORD5;
- float4 eyeVec : TEXCOORD6; // eyeVec.xyz | fogCoord
- UNITY_LIGHTING_COORDS(7,8)
+ float4 uv23 : TEXCOORD1; // just one more uv slot bro please
+ float4 objPos : TEXCOORD2;
+ float3 worldPos : TEXCOORD3;
+ float3 normal : TEXCOORD4;
+ float3 tangent : TEXCOORD5;
+ float3 binormal : TEXCOORD6;
+ float4 eyeVec : TEXCOORD7; // eyeVec.xyz | fogCoord
+ UNITY_LIGHTING_COORDS(8,9)
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
diff --git a/tessellation.cginc b/tessellation.cginc index fc79177..3df57b1 100644 --- a/tessellation.cginc +++ b/tessellation.cginc @@ -108,6 +108,7 @@ v2f domain( o.tangent = DOMAIN_INTERP(tangent); o.binormal = DOMAIN_INTERP(binormal); o.uv01 = DOMAIN_INTERP(uv01); + o.uv23 = DOMAIN_INTERP(uv23); #if defined(_TESSELLATION) && defined(_SHATTER_WAVE) #if defined(OUTLINE_PASS) diff --git a/texture_utils.cginc b/texture_utils.cginc index 4d02fbc..5909c72 100644 --- a/texture_utils.cginc +++ b/texture_utils.cginc @@ -12,6 +12,12 @@ float2 get_uv_by_channel(v2f i, uint which_channel) { case 1: return i.uv01.zw; break; + case 2: + return i.uv23.xy; + break; + case 3: + return i.uv23.zw; + break; default: return 0; break; |
