From ccdda956f7de812bb9c318161c6852301a60d413 Mon Sep 17 00:00:00 2001 From: yum Date: Tue, 25 Mar 2025 18:21:18 -0700 Subject: Add spherize feature --- 2ner.cginc | 10 ++++++++++ 2ner.shader | 8 ++++++++ features.cginc | 4 ++++ globals.cginc | 5 +++++ 4 files changed, 27 insertions(+) diff --git a/2ner.cginc b/2ner.cginc index 10b41a8..e8d6ae3 100644 --- a/2ner.cginc +++ b/2ner.cginc @@ -70,6 +70,16 @@ v2f vert(appdata v) { shatterWaveVert(v.vertex.xyz, v.normal, v.tangent); #endif +#if defined(_SPHERIZE) + { + float3 tgt_normal = normalize(v.vertex.xyz); + float3 tgt_tangent = normalize(float3(tgt_normal.y, -tgt_normal.x, 0)); + float3 tgt_pos = tgt_normal * _Spherize_Radius; + v.normal = normalize(lerp(v.normal, tgt_normal, _Spherize_Strength)); + v.vertex.xyz = lerp(v.vertex.xyz, tgt_pos, _Spherize_Strength); + } +#endif + #if defined(OUTLINE_PASS) [branch] if (!_Outlines_Enabled_Dynamic) { diff --git a/2ner.shader b/2ner.shader index d6047e1..377f705 100644 --- a/2ner.shader +++ b/2ner.shader @@ -528,6 +528,14 @@ Shader "yum_food/2ner" [HideInInspector] m_end_Tessellation("Tessellation", Float) = 0 //endex + //ifex _Spherize_Enabled==0 + [HideInInspector] m_start_Spherize("Spherize", Float) = 0 + [ThryToggle(_SPHERIZE)] _Spherize_Enabled("Enable", Float) = 0 + _Spherize_Radius("Radius", Float) = 1 + _Spherize_Strength("Strength", Range(0, 1)) = 1 + [HideInInspector] m_end_Spherize("Spherize", Float) = 0 + //endex + //ifex _Vertex_Domain_Warping_Enabled==0 [HideInInspector] m_start_Vertex_Domain_Warping("Vertex domain warping", Float) = 0 [ThryToggle(_VERTEX_DOMAIN_WARPING)]_Vertex_Domain_Warping_Enabled("Enable", Float) = 0 diff --git a/features.cginc b/features.cginc index 163da78..da2cd69 100644 --- a/features.cginc +++ b/features.cginc @@ -208,5 +208,9 @@ #pragma shader_feature_local _TESSELLATION //endex +//ifex _Spherize_Enabled==0 +#pragma shader_feature_local _SPHERIZE +//endex + #endif // __FEATURES_INC diff --git a/globals.cginc b/globals.cginc index ba223ee..9cabad6 100644 --- a/globals.cginc +++ b/globals.cginc @@ -429,4 +429,9 @@ float3 _Tessellation_Edge_Factors; float _Tessellation_Inside_Factor; #endif // _TESSELLATION +#if defined(_SPHERIZE) +float _Spherize_Radius; +float _Spherize_Strength; +#endif // _SPHERIZE + #endif // __GLOBALS_INC -- cgit v1.2.3