summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2025-10-12 15:00:47 -0700
committeryum <yum.food.vr@gmail.com>2025-10-12 15:00:47 -0700
commit6ac3da1b0bd363d70c2f6e4b7b921f2f929dedac (patch)
treecc09ebbdd7bd101bccd2f9d594279f5f66370c63
parentd2090f73f3e4f08cdbd3c3b82eb7f3ba9f459dd0 (diff)
add uv scroll, aniso16, and finish tubes
-rw-r--r--3ner.cginc7
-rw-r--r--3ner.shader31
-rw-r--r--custom31.slang2
-rw-r--r--features.cginc7
-rw-r--r--globals.cginc17
-rw-r--r--interpolators.cginc2
-rw-r--r--pbr.cginc10
-rw-r--r--vertex.cginc46
8 files changed, 103 insertions, 19 deletions
diff --git a/3ner.cginc b/3ner.cginc
index a1ab224..0536fb5 100644
--- a/3ner.cginc
+++ b/3ner.cginc
@@ -27,7 +27,7 @@ v2f vert(appdata v) {
#endif
o.uv0 = v.uv0;
o.objPos = v.vertex;
-#if defined(_CUSTOM31_FRAGMENT_NORMALS)
+#if defined(_CUSTOM31_FRAGMENT_NORMALS) || defined(_CUSTOM31_TESSELLATION)
o.objPos_orig = v.vertex;
#endif
@@ -155,8 +155,11 @@ v2f domain(
#else
o.objPos = DOMAIN_INTERP(objPos);
#endif
-#if defined(_CUSTOM31_FRAGMENT_NORMALS)
+
+#if defined(_CUSTOM31_FRAGMENT_NORMALS) || defined(_CUSTOM31_TESSELLATION)
o.objPos_orig = DOMAIN_INTERP(objPos_orig);
+ o.objPos = o.objPos_orig;
+ deform(o.objPos);
#endif
o.normal = DOMAIN_INTERP(normal);
o.tangent = DOMAIN_INTERP(tangent);
diff --git a/3ner.shader b/3ner.shader
index b31e85f..7e6564c 100644
--- a/3ner.shader
+++ b/3ner.shader
@@ -44,14 +44,43 @@ Shader "yum_food/3ner"
[HideInInspector] m_start_Custom31("Custom31", Float) = 0
[ThryToggle(_CUSTOM31)] _Custom31_Enabled("Enable", Float) = 0
[ThryToggle(_CUSTOM31_FRAGMENT_NORMALS)] _Custom31_Fragment_Normals_Enabled("Fragment normals", Float) = 0
+ [ThryToggle(_CUSTOM31_TESSELLATION)] _Custom31_Tessellation_Enabled("Tesellation support", Float) = 1
//ifex _Custom31_Tubes_Enabled==0
[HideInInspector] m_start_Custom31_Tubes("Tubes", Float) = 0
[ThryToggle(_CUSTOM31_TUBES)] _Custom31_Tubes_Enabled("Enable", Float) = 0
- _Custom31_Tubes_t("t", Range(0,1)) = 1
+
+ //ifex _Custom31_XZ_Tube_Enabled==0
+ [HideInInspector] m_start_Custom31_XZ_Tube("XZ Tube", Float) = 0
+ [ThryToggle(_CUSTOM31_XZ_TUBE)] _Custom31_XZ_Tube_Enabled("Enable", Float) = 0
+ _Custom31_XZ_Tube_t("t", Range(-1,1)) = 0
+ [HideInInspector] m_end_Custom31_XZ_Tube("XZ Tube", Float) = 0
+ //endex
+
+ //ifex _Custom31_YZ_Tube_Enabled==0
+ [HideInInspector] m_start_Custom31_YZ_Tube("YZ Tube", Float) = 0
+ [ThryToggle(_CUSTOM31_YZ_TUBE)] _Custom31_YZ_Tube_Enabled("Enable", Float) = 0
+ _Custom31_YZ_Tube_t("t", Range(-1,1)) = 0
+ [HideInInspector] m_end_Custom31_YZ_Tube("YZ Tube", Float) = 0
+ //endex
+
+ //ifex _Custom31_XY_Tube_Enabled==0
+ [HideInInspector] m_start_Custom31_XY_Tube("XY Tube", Float) = 0
+ [ThryToggle(_CUSTOM31_XY_TUBE)] _Custom31_XY_Tube_Enabled("Enable", Float) = 0
+ _Custom31_XY_Tube_t("t", Range(-1,1)) = 0
+ [HideInInspector] m_end_Custom31_XY_Tube("XY Tube", Float) = 0
+ //endex
+
[HideInInspector] m_end_Custom31_Tubes("Tubes", Float) = 0
//endex
+ //ifex _UV_Scroll_Enabled==0
+ [HideInInspector] m_start_UV_Scroll("UV Scroll", Float) = 0
+ [ThryToggle(_UV_SCROLL)] _UV_Scroll_Enabled("Enable", Float) = 0
+ _UV_Scroll_Speed("Speed (u, v, 0, 0)", Vector) = (0, -1, 0, 0)
+ [HideInInspector] m_end_UV_Scroll("UV Scroll", Float) = 0
+ //endex
+
//ifex _Marble_Enabled==0
[HideInInspector] m_start_Marble("Marble", Float) = 0
[ThryToggle(_MARBLE)] _Marble_Enabled("Enable", Float) = 0
diff --git a/custom31.slang b/custom31.slang
index 1254800..61afe4a 100644
--- a/custom31.slang
+++ b/custom31.slang
@@ -99,7 +99,7 @@ public float3 plane_to_tube(float3 xyz, no_diff float t) {
float z0 = xyz.z;
float theta = x0 * PI;
- float radius = min(1e3, (1.0f / (t * t)));
+ float radius = min(1e3, (1.0f / (t * t))) * sign(t) ;
float x = sin(theta / radius) * radius * PI_RCP;
// The z0 term here is required to make the jacobian invertible.
diff --git a/features.cginc b/features.cginc
index d6ba34d..c6786d4 100644
--- a/features.cginc
+++ b/features.cginc
@@ -30,10 +30,17 @@
//ifex _Custom31_Tubes_Enabled==0
#pragma shader_feature_local _CUSTOM31_TUBES
+#pragma shader_feature_local _CUSTOM31_XZ_TUBE
+#pragma shader_feature_local _CUSTOM31_YZ_TUBE
+#pragma shader_feature_local _CUSTOM31_XY_TUBE
//endex
//ifex _Unlit==0
#pragma shader_feature_local _UNLIT
//endex
+//ifex _UV_Scroll_Enabled==0
+#pragma shader_feature_local _UV_SCROLL
+//endex
+
#endif // __FEATURES_INC
diff --git a/globals.cginc b/globals.cginc
index 38a1019..1bd9498 100644
--- a/globals.cginc
+++ b/globals.cginc
@@ -5,6 +5,7 @@
SamplerState point_repeat_s;
SamplerState linear_repeat_s;
+SamplerState aniso16_trilinear_repeat_s;
SamplerState bilinear_repeat_s;
SamplerState linear_clamp_s;
SamplerState bilinear_clamp_s;
@@ -57,8 +58,18 @@ float3 _Cloth_Sheen_Color;
texture2D _Cloth_Sheen_DFG_LUT;
#endif // _CLOTH_SHEEN
-#if defined(_CUSTOM31_TUBES)
-float _Custom31_Tubes_t;
-#endif // _CUSTOM31_TUBES
+#if defined(_CUSTOM31_XY_TUBE)
+float _Custom31_XY_Tube_t;
+#endif // _CUSTOM31_XY_TUBE
+#if defined(_CUSTOM31_XZ_TUBE)
+float _Custom31_XZ_Tube_t;
+#endif // _CUSTOM31_XZ_TUBE
+#if defined(_CUSTOM31_YZ_TUBE)
+float _Custom31_YZ_Tube_t;
+#endif // _CUSTOM31_YZ_TUBE
+
+#if defined(_UV_SCROLL)
+float2 _UV_Scroll_Speed;
+#endif // _UV_SCROLL
#endif // __GLOBALS_INC
diff --git a/interpolators.cginc b/interpolators.cginc
index 9041e15..f9f389c 100644
--- a/interpolators.cginc
+++ b/interpolators.cginc
@@ -25,7 +25,7 @@ struct v2f {
float3 normal : TEXCOORD4;
float4 tangent : TEXCOORD5;
UNITY_LIGHTING_COORDS(6,7)
-#if defined(_CUSTOM31_FRAGMENT_NORMALS)
+#if defined(_CUSTOM31_FRAGMENT_NORMALS) || defined(_CUSTOM31_TESSELLATION)
float3 objPos_orig : TEXCOORD8;
#endif
diff --git a/pbr.cginc b/pbr.cginc
index 806a52f..06f2532 100644
--- a/pbr.cginc
+++ b/pbr.cginc
@@ -53,18 +53,22 @@ void apply_marble(float3 world_pos, inout float3 albedo) {
Pbr getPbr(v2f i) {
Pbr pbr = (Pbr) 0;
- pbr.albedo = _MainTex.Sample(trilinear_repeat_s, i.uv0 * _MainTex_ST.xy);
+#if defined(_UV_SCROLL)
+ i.uv0 += _Time[0] * _UV_Scroll_Speed;
+#endif // _UV_SCROLL
+
+ pbr.albedo = _MainTex.Sample(aniso16_trilinear_repeat_s, i.uv0 * _MainTex_ST.xy);
pbr.albedo *= _Color;
apply_marble(i.worldPos, pbr.albedo.xyz);
- float3 normal_tangent = UnpackNormal(_BumpMap.Sample(trilinear_repeat_s, i.uv0 * _BumpMap_ST.xy));
+ float3 normal_tangent = UnpackNormal(_BumpMap.Sample(aniso16_trilinear_repeat_s, i.uv0 * _BumpMap_ST.xy));
normal_tangent.xy *= _BumpScale;
// Map from tangent space to world space.
float3 bitangent = cross(i.normal, i.tangent.xyz) * i.tangent.w;
pbr.tbn = float3x3(i.tangent.xyz, bitangent, i.normal);
pbr.normal = normalize(mul(normal_tangent, pbr.tbn));
- float4 metallic_gloss = _MetallicGlossMap.Sample(trilinear_repeat_s, i.uv0 * _MetallicGlossMap_ST.xy);
+ float4 metallic_gloss = _MetallicGlossMap.Sample(aniso16_trilinear_repeat_s, i.uv0 * _MetallicGlossMap_ST.xy);
pbr.smoothness = metallic_gloss.a * _Glossiness;
pbr.metallic = metallic_gloss.r * _Metallic;
#if defined(_CLEARCOAT)
diff --git a/vertex.cginc b/vertex.cginc
index fd08bbb..2f5b5f5 100644
--- a/vertex.cginc
+++ b/vertex.cginc
@@ -4,17 +4,47 @@
#include "custom31.hlsl"
void deform(inout float3 objPos) {
-#if defined(_CUSTOM31_TUBES)
- float t = _Custom31_Tubes_t;
- objPos = plane_to_tube(objPos, t);
-#endif // _CUSTOM31_TUBES
+#if defined(_CUSTOM31_XZ_TUBE)
+ {
+ float t = _Custom31_XZ_Tube_t;
+ objPos = plane_to_tube(objPos.xyz, t);
+ }
+#endif // _CUSTOM31_XZ_TUBE
+#if defined(_CUSTOM31_YZ_TUBE)
+ {
+ float t = _Custom31_YZ_Tube_t;
+ objPos = plane_to_tube(objPos.yxz, t);
+ objPos = objPos.yxz;
+ }
+#endif // _CUSTOM31_YZ_TUBE
+#if defined(_CUSTOM31_XY_TUBE)
+ {
+ float t = _Custom31_XY_Tube_t;
+ objPos = plane_to_tube(objPos.xzy, t);
+ objPos = objPos.xzy;
+ }
+#endif // _CUSTOM31_XY_TUBE
}
void deform_normal(float3 objPos, inout float3 objNorm, inout float3 objTan) {
-#if defined(_CUSTOM31_TUBES)
- float t = _Custom31_Tubes_t;
- plane_to_tube_normal(objPos, objNorm, objTan, t);
-#endif // _CUSTOM31_TUBES
+#if defined(_CUSTOM31_XZ_TUBE)
+ {
+ float t = _Custom31_XZ_Tube_t;
+ plane_to_tube_normal(objPos, objNorm, objTan, t);
+ }
+#endif // _CUSTOM31_XZ_TUBE
+#if defined(_CUSTOM31_YZ_TUBE)
+ {
+ float t = _Custom31_YZ_Tube_t;
+ plane_to_tube_normal(objPos.yxz, objNorm.yxz, objTan.yxz, t);
+ }
+#endif // _CUSTOM31_YZ_TUBE
+#if defined(_CUSTOM31_XY_TUBE)
+ {
+ float t = _Custom31_XY_Tube_t;
+ plane_to_tube_normal(objPos.xzy, objNorm.xzy, objTan.xzy, t);
+ }
+#endif // _CUSTOM31_XY_TUBE
}
void propagateObjPos(inout v2f i) {