diff options
| -rw-r--r-- | LICENSE | 20 | ||||
| -rw-r--r-- | README.md | 64 | ||||
| -rw-r--r-- | tooner_lighting.cginc | 12 |
3 files changed, 92 insertions, 4 deletions
@@ -0,0 +1,20 @@ +Copyright (c) 2024 yum_food + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/README.md b/README.md new file mode 100644 index 0000000..7b8e300 --- /dev/null +++ b/README.md @@ -0,0 +1,64 @@ +## Tooner + +A toon shader for VRChat. + +Features: +* PBR +* Decals +* Reflection probe override +* Min/max brightness +* Emissions +* Flat/realistic normals +* Matcaps +* Rim lighting +* Outlines +* Glitter +* Explosion +* Geometry scroll (similar to Poiyomi's shatterwave) +* UV scroll +* OKLCH color adjustment +* Clones +* Opaque, cutout, fade rendering modes +* Back/front/no culling modes +* LTCGI +* Shadow caster pass +* Extensive use of variants to minimize performance cost + +Disclaimers: +1. This is a WIP. +2. I am not a graphics expert. +3. Stability is a non-goal. Keywords are likely to change in the interest of + performance and simplicity. + +Strawman FAQ + +1. Why create another toon shader? + +To deepen my understanding of lighting and to have a "simple" foundation on +top of which to create bespoke shader effects. lilToon and Poiyomi are both way +too fucking huge and complicated to fit my needs. + +2. Does it work? + +Sort of. I haven't implemented shadow receiving yet, so some water effects are +fucked up. + +3. Is it optimized? + +Sort of. I haven't benchmarked it. I know it's slower than Poiyomi. + +I use keywords on every feature so it shouldn't be obscenely bad. But I haven't +gotten to the point of like, deduplicating all computation and shoving as much +as possible into the vertex shader. So it's like. Sort of optimized. + +I'd like to strike a balance between performance and readability. Since it's +mostly for *my* use, I don't feel a need to make it totally optimal. + +4. Demos? + +This avatar uses it: [gumroad](https://yumfood.gumroad.com/l/lychee). + +I'm working on a world but haven't published yet. + +Will update this section with real demos later. + diff --git a/tooner_lighting.cginc b/tooner_lighting.cginc index 45a69e8..ec72ac6 100644 --- a/tooner_lighting.cginc +++ b/tooner_lighting.cginc @@ -493,8 +493,9 @@ float4 effect(inout v2f i) #if defined(_MATCAP0_MASK) float4 matcap_mask_raw = _Matcap0_Mask.SampleGrad(linear_repeat_s, i.uv.xy, iddx, iddy); - float matcap_mask = matcap_mask_raw.r * matcap_mask_raw.a; + float matcap_mask = matcap_mask_raw.r; matcap_mask = (bool) round(_Matcap0_Mask_Invert) ? 1 - matcap_mask : matcap_mask; + matcap_mask *= matcap_mask_raw.a; #else float matcap_mask = 1; #endif @@ -530,8 +531,9 @@ float4 effect(inout v2f i) #if defined(_MATCAP1_MASK) float4 matcap_mask_raw = _Matcap1_Mask.SampleGrad(linear_repeat_s, i.uv.xy, iddx, iddy); - float matcap_mask = matcap_mask_raw.r * matcap_mask_raw.a; + float matcap_mask = matcap_mask_raw.r; matcap_mask = (bool) round(_Matcap1_Mask_Invert) ? 1 - matcap_mask : matcap_mask; + matcap_mask *= matcap_mask_raw.a; #else float matcap_mask = 1; #endif @@ -576,8 +578,9 @@ float4 effect(inout v2f i) float3 matcap = rl * _Rim_Lighting0_Color * _Rim_Lighting0_Strength; #if defined(_RIM_LIGHTING0_MASK) float4 matcap_mask_raw = _Rim_Lighting0_Mask.SampleGrad(linear_repeat_s, i.uv.xy, iddx, iddy); - float matcap_mask = matcap_mask_raw.r * matcap_mask_raw.a; + float matcap_mask = matcap_mask_raw.r; matcap_mask = (bool) round(_Rim_Lighting0_Mask_Invert) ? 1 - matcap_mask : matcap_mask; + matcap_mask *= matcap_mask_raw.a; #else float matcap_mask = 1; #endif @@ -613,8 +616,9 @@ float4 effect(inout v2f i) float3 matcap = rl * _Rim_Lighting1_Color * _Rim_Lighting1_Strength; #if defined(_RIM_LIGHTING1_MASK) float4 matcap_mask_raw = _Rim_Lighting1_Mask.SampleGrad(linear_repeat_s, i.uv.xy, iddx, iddy); - float matcap_mask = matcap_mask_raw.r * matcap_mask_raw.a; + float matcap_mask = matcap_mask_raw.r; matcap_mask = (bool) round(_Rim_Lighting1_Mask_Invert) ? 1 - matcap_mask : matcap_mask; + matcap_mask *= matcap_mask_raw.a; #else float matcap_mask = 1; #endif |
