Giter Club home page Giter Club logo

unityurptoonlitshaderexample's Introduction

About this repository

This repository does NOT contain the full version of NiloToonURP.
Instead, it includes a simple, short and easy-to-read URP toon shader example for Unity2022.3LTS, which is intended for shader coding tutorial purposes. The shader example is licensed under the MIT license, giving you the freedom to use the code as you wish. If you'd like to retain the current tutorial shader, we recommend forking it or downloading a copy now, as it may be removed in the future.

*this README also shows photos and information about the NiloToonURP(full version)

NiloToonURP(full version)'s rendering

screenshot screenshot shader ON screenshot shader OFF screenshot shader ON screenshot shader OFF screenshot shader ON screenshot shader OFF screenshot

screenshot Outline options(1/2/3)
screenshot screenshot screenshot screenshot screenshot shader ON screenshot shader OFF screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot

We are now developing an 'easy-to-use, high-performance, and cross-platform (including mobile, VR, and WebGL)' closed-source toon shader package—NiloToonURP—to assist Unity URP users in achieving high-quality anime/toon-like rendering.

NiloToonURP is supporting:

  • Unity 2021.3LTS(URP 12.x)
  • Unity 2022.3LTS(URP 14.x)
  • Unity 2023.2 (URP 16.x)
  • Unity6 (URP 17.x)

Download NiloToonURP PC .exe demo (2021.3.17LTS build):

Download NiloToonURP Android .apk demo (2021.3.17LTS build):

NiloToonURP's demo runtime video:

NiloToonURP's UI preview:

How to get NiloToonURP full source code?

If you or your company/organization/team needs:

  • latest full source code (with all detail comments and notes, NOT Obfuscated code, NOT .dll)
  • latest user document
  • perpetual royalty-free commercial license
  • every future update
  • NiloToon's tech support
  • (optional) we set up your character models's rendering in the best way possible for you, using NiloToonURP
  • (optional) your project-specific customization and support

of NiloToonURP for your URP project, please send the following info to [email protected]

  • name (your personal name or your company/organization/team's name)
  • a google account email for gaining permission to download all NiloToonURP files in google drive
  • any public website that shows your/your company/organization/team's work or public media (e.g. personal website/company website/youtube/bilibili/twitter...)

NiloToonURP user's creations (public media, not NDA content)

*we only provided NiloToonURP's download permission + tech support, we didn't work on these creations directly

Genshin Impact MV - When The Stars Align (Genshin Impact website -> http://genshin.hoyoverse.com)

screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot

キラッとプリ⭐︎チャン (https://twitter.com/pretty_vlive)

screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot

Suisei Channel - hololive (https://www.youtube.com/@HoshimachiSuisei)

screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot

VSPO!(ぶいすぽっ!) - 胡桃のあ (https://www.youtube.com/@963Noah)

screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot

VVV MUSIC LIVE 公式(ブイスリー) (https://twitter.com/VVVMusicLive)

screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot

screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot

hololive ホロライブ - VTuber Group (https://www.youtube.com/@hololive)

screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot

杏仁ミル Annin Miru Channel (https://www.youtube.com/@AnninMiru)

screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot

ISEGYE IDOL (이세계아이돌) - 주르르 JURURU (https://www.youtube.com/@JU_RURU)

screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot

ぶいごまチャンネル V後藤真希 (https://www.youtube.com/@V_GOTO_MAKI)

screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot

VSPO!(ぶいすぽっ!) - 小森めと (https://www.youtube.com/@Met_Komori)

screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot

screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot

Starseed:Asnia Trigger / 스타시드: 아스니아 트리거 (starseed.com2us.com)

screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot

Neo-Porte(ネオポルテ)- 天帝フォルテ / Tentei Forte (https://www.youtube.com/@tenteiforte4631)

screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot

VirtuaReal / Nijisanji CN - 七海Nana7mi (https://space.bilibili.com/434334701)

screenshot screenshot screenshot screenshot

Neo-Porte(ネオポルテ)- 夜絆ニウ / yozuna niu (https://www.youtube.com/@niu_yozuna)

screenshot screenshot screenshot screenshot screenshot screenshot screenshot

Stargazer Official @ 스타게이저 @ スターゲイザー (https://twitter.com/StargazerCoLtd)

screenshot

VSPO!(ぶいすぽっ!) - 花芽すみれ (https://www.youtube.com/@KagaSumire)

screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot

VirtuaReal Star - hanser (https://space.bilibili.com/11073)

screenshot screenshot screenshot screenshot

Gawr Gura Ch. hololive-EN (https://www.youtube.com/@GawrGura):

screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot

Neo-Porte(ネオポルテ)- 緋月ゆい / Hizuki Yui

screenshot screenshot screenshot screenshot screenshot screenshot screenshot

VSPO!(ぶいすぽっ!【公式】) (https://www.youtube.com/@Vspo77)

screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot

Takanashi Kiara Ch. hololive-EN (https://www.youtube.com/@TakanashiKiara)

screenshot screenshot screenshot screenshot screenshot screenshot screenshot

screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot

VSPO!(ぶいすぽっ!【公式】) (https://www.youtube.com/@Vspo77)

screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot

阿梓从小就很可爱 (https://space.bilibili.com/7706705/)

screenshot screenshot screenshot screenshot screenshot

screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot

hololive - Shion Ch. 紫咲シオン (https://www.youtube.com/@MurasakiShion)

screenshot screenshot screenshot screenshot

  • 【holo27 MV】紫咲シオン x ラプラス・ダークネス - リップシンク【ホロライブ x DECO27】 -> https://youtu.be/NjtIAuZQN_E

VSPO!(ぶいすぽっ!【公式】) (https://www.youtube.com/@Vspo77)

screenshot screenshot screenshot screenshot screenshot screenshot

screenshot screenshot screenshot

VSPO!(ぶいすぽっ!) - 八雲べに (https://www.youtube.com/@yakumo_beni)

screenshot screenshot screenshot screenshot screenshot

Moona Hoshinova hololive-ID (https://www.youtube.com/@MoonaHoshinova):

screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot

screenshot screenshot screenshot screenshot screenshot screenshot screenshot

史黛菈 埃蕾諾亞 / Stella Eleanor Ch. (https://www.youtube.com/@NKStellaEleanor)

screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot

screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot

Nijisanji & bilibili - VirtuaReal (https://www.nijisanji.jp/talents?filter=virtuareal):

screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot

ISEGYE IDOL (이세계아이돌) - 비챤 VIichan (https://www.youtube.com/@viichan116)

screenshot screenshot screenshot screenshot

screenshot screenshot screenshot screenshot screenshot screenshot

崩坏学园2-灵依娘desu (https://space.bilibili.com/133934):

screenshot screenshot screenshot screenshot screenshot screenshot

懶貓子 & 杏仁ミル

screenshot screenshot

Rumi ch. 懶貓子 (https://youtu.be/Zlef92wDMnA):

screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot

screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot

screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot

screenshot screenshot screenshot screenshot

screenshot screenshot screenshot screenshot screenshot screenshot

screenshot

screenshot screenshot screenshot screenshot screenshot

screenshot screenshot screenshot

screenshot screenshot screenshot screenshot

screenshot screenshot

screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot

Warudo on Steam(supporting NiloToonURP) (https://store.steampowered.com/app/2079120/Warudo/)

screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot

screenshot screenshot screenshot screenshot screenshot

screenshot

  • Kanauru MV | CapSule - Mori Calliope x Hoshimachi Suisei

screenshot screenshot screenshot

screenshot

screenshot screenshot screenshot screenshot screenshot

VSPO!(ぶいすぽっ!) - 英リサ.Hanabusa Lisa (https://www.youtube.com/@lisahanabusa)

screenshot screenshot screenshot screenshot

myer gugu(崩坏的栗子_108番) (https://www.artstation.com/myergugu)

screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot

screenshot screenshot screenshot screenshot screenshot screenshot screenshot

Nijisanji & bilibili - VirtuaReal (https://www.nijisanji.jp/talents?filter=virtuareal):

screenshot screenshot screenshot screenshot

screenshot screenshot screenshot screenshot screenshot (after clicking the link below, it will require you to press enter on the link again in your browser)

screenshot (after clicking the link below, it will require you to press enter on the link again in your browser)

screenshot screenshot screenshot screenshot screenshot

screenshot screenshot

screenshot screenshot screenshot

screenshot screenshot screenshot

screenshot

screenshot

screenshot

screenshot screenshot screenshot screenshot

screenshot screenshot screenshot

screenshot

screenshot

screenshot

screenshot screenshot screenshot screenshot screenshot screenshot

VirtuaReal Star - hanser (https://space.bilibili.com/11073)

screenshot screenshot

screenshot

screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot

screenshot screenshot screenshot

screenshot screenshot

screenshot screenshot screenshot screenshot

screenshot screenshot screenshot (you need to enter the link to the browser again in order to play it)

Other NiloToonURP's images (gallery)

screenshot

shader ON screenshot shader OFF screenshot

screenshot

shader ON screenshot normal debug screenshot shader OFF screenshot

screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot screenshot


SHADER ON screenshot screenshot BEFORE screenshot AFTER: screenshot see it in motion-> https://youtu.be/D9ocVzGJfI8


3D enviroment model TEST
screenshot screenshot see it in motion-> https://youtu.be/GcW0pNo-zus

湊 あくあ(みなと あくあ,Minato Aqua) model TEST screenshot screenshot screenshot see it in motion-> https://youtu.be/7zICgzdxuGg

see it in motion-> https://youtu.be/X3XoYMTleJ0

Auto Phong tessellation

(shader off, no tessellation) screenshot (shader on, no tessellation) screenshot (shader on, enable tessellation! Phong tessellation can make your model smooth without changing your .fbx) screenshot see it in motion-> https://youtu.be/D-MxyBa0nJE

Kawaii model TEST (@ganbaru_sisters) screenshot screenshot

SHADER ON screenshot SHADER OFF screenshot HD screenshot

shader ON screenshot shader OFF screenshot


BEFORE screenshot AFTER screenshot see it in motion-> https://youtu.be/KpRkxPnHuK0

BEFORE screenshot AFTER screenshot (more shadow from trees) screenshot

BEFORE screenshot AFTER: screenshot see it in motion-> https://youtu.be/hUWacEQH6js

BEFORE

screenshot

AFTER:

screenshot

BEFORE

screenshot

AFTER:

screenshot

add 2D hair shadow & rim light

screenshot

see it in motion-> https://youtu.be/S67GlGAnvWA


BEFORE screenshot AFTER: screenshot

see it in motion-> https://youtu.be/M6FKoEiOAzU


BEFORE screenshot AFTER: Sunny + StreetLight ON screenshot Sunny + StreetLight OFF screenshot Night + StreetLight ON screenshot Night + StreetLight OFF screenshot see it in motion -> https://youtu.be/jDSnJmZrKPw

BEFORE screenshot AFTER screenshot

BEFORE screenshot AFTER screenshot see it in motion -> https://youtu.be/ZfSZOHTBypc

BEFORE screenshot AFTER screenshot see it in motion -> https://youtu.be/EgxiWPk-vaE


BEFORE screenshot AFTER screenshot see it in motion -> https://youtu.be/Ty4DXLFqqDo

BEFORE screenshot AFTER screenshot see it in motion -> https://youtu.be/cebGl_MaWnI

BEFORE screenshot AFTER screenshot see it in motion ->https://youtu.be/nl5z0r8a9vk

screenshot screenshot screenshot see it in motion -> https://youtu.be/uVI_QOioER4

Fake Skin SSS & specular screenshot screenshot

BEFORE screenshot AFTER screenshot

What is included in this simplified tutorial example toon-lit shader repository?

This repository only contains a very simple toon-lit URP tutorial shader example, to help people write their first custom toon-lit shader in URP.

This example shader's default result(without editing material params) = the following picture screenshot

Because this example toon lit shader aims to help people learn shader writing in URP, it is an extremely simplified version. This repository only contains ~3% of the NiloToonURP(full version)'s code, which only contains the most basic & easily understandable sections, to make sure everyone can understand the shader code easily.

It is actually a "How to write your first custom toon-lit shader in URP?" example, instead of a good-looking toon-lit shader (lots of toon-lit tricks are not included in this example shader, for tutorial reasons).

Why create this "simplified version" toon lit shader?

Lots of my shader friends are looking for a toon-lit example shader in URP (not Shader Graph), I want them to switch to URP(instead of still staying in built-in RP), so I decided to provide a simple enough URP toon-lit shader example in URP.

How to try this simplified toon-lit example shader in my URP project?

  1. Clone all .shader & .hlsl files into your URP project.
  2. Put these files inside the same folder.
  3. Change your character's material's shader to "SimpleURPToonLitExample(With Outline)"
  4. make sure at least _BaseMap(albedo) is assigned
  5. setup DONE, you can now test your character with light probe/directional light/point light/spot light
  6. edit the material properties to see how the render result changes
  7. Most important: open these shader files, and spend some time reading them, you will understand how to write custom lit shaders in URP very quickly
  8. Most important: open "SimpleURPToonLitOutlineExample_LightingEquation.hlsl", edit it, and experiment with your own toon lighting equation ideas, which is the key part of toon lit shader!

I see the shader is working now, but the outline is broken?

For this tutorial shader, you can let Unity calculate smoothed normal for you, which can produce a better outline, but doing this will make the lighting slightly incorrect.

  1. click your character's .fbx
  2. In the model tab
  3. edit "Normals" to Calculate
  4. edit "Smoothing Angle" to 180

screenshot
before calculating smooth normal (print screen of the tutorial shader, not NiloToonURP)
screenshot
after calculating smooth normal (print screen of the tutorial shader, not NiloToonURP) screenshot

*NiloToonURP(full version) contains many editor/runtime C# scripts, some of them are for producing correct lighting and perfect outline together automatically.

What is NOT included in this simplified tutorial shader?

For simplicity reasons, most of the features from the NiloToonURP(full version) are removed, or else for beginners, this simple tutorial example shader will be way too complex for reading & learning. Some of the removed features are:

  • face anime lighting (auto-fix face ugly lighting due to vertex normal without modifying .fbx, very important)
  • smooth outline normal auto baking (auto-fix ugly outlines without modifying .fbx and lighting normal, very important)
  • auto 2D hair shadow on the face (very important, it is very difficult to produce good-looking shadow results on the face using URP's shadow map)
  • constant width rim light (similar to the method of Blue Protocol / Genshin Impact)
  • tricks to render eye/eyebrow over hair (ZOffset, stencil, and renderer redraw helpers)
  • PBR specular lighting (GGX)
  • all kinds of MatCap features(additive/multiply/shadow/replace...)
  • "HSV,tint,texture tint,texture override" shadow & outline color control
  • almost all the extra texture input options like roughness, specular, normal map, detail map, parallax, occlusion, emission...
  • LOTS of sliders to control lighting style, shadow color, final color, outline, rim light...
  • per character "dither fade inout / rim light / color control / extra outline / dissolve / ..." control script
  • volume override control of global "rim light / shadow / color control..."
  • special bloom post-process volume that can control the param of character/non-character area separately. Usually to prevent character over-bloom, or make the character emitting bloom on allowed areas only
  • anime postprocessing volume
  • shadow control volume
  • perspective removal per character, to avoid character's 3D distorted by high FOV camera
  • shader stripping editor script, to keep runtime shader memory usage and build time lower
  • (lots of other features)
  • just too much for me to write all the removed features here, the NiloToonURP(full version) and this simple tutorial shader example are two totally different products already

How to get a test character model?

The easiest way to get a character model is by downloading Unity-Chan in the Unity AssetStore.

Also, here are some websites where you can download models(If the creator allows it)

if you downloaded a .pmx file, use MMD4Mecanim to convert it to .fbx & prefab directly inside unity http://stereoarts.jp/

if you downloaded a .vrm file, use UniVRM to convert it to prefab directly inside Unity https://github.com/vrm-c/UniVRM

Editor version requirement

  • Unity 2022.3

Apply our shader to another model (2020-2 early version screenshots) https://youtu.be/uVI_QOioER4

screenshot screenshot screenshot screenshot screenshot screenshot

More old screenshots from the Full version shader:

screenshot https://youtu.be/IP293mAmBCk

screenshot screenshot screenshot

screenshot screenshot

different Background image TEST screenshot screenshot screenshot screenshot screenshot

Credits

model's creator in shader demo image/video:

unityurptoonlitshaderexample's People

Contributors

colinleung-nilocat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

unityurptoonlitshaderexample's Issues

Objects disappear if Depth Priming is not set to "Disabled"

In an existing project and a blank project I just created for testing, the shader does not work as intended.

Currently it is behaving like this:

┌────────────────────┬──────────────────────────┐
│ Depth Priming Mode │       Visibility         │
├────────────────────┼──────────────────────────┤
│ Disabled           │ Scene & Game Window      │
│ Auto               │ Game Window Only         │
│ Forced             │ Only shadows are visible │
└────────────────────┴──────────────────────────┘

You can see a video of this here.

Both projects/scenes have identical camera settings, post-processing, and URP Asset settings. Both projects shown have Light Layers enabled.

Unity Version: 2021.2.7f1
URP Version: 12.1.2

Material doesn't have a texture property '_MainTex'

Hi,

I am very new to both unity and shader, and I come across your brilliant project.
I just tried to pull your code and import to a new project I loaded together with Unity-chan. I tried to change her body material to this project, but everything goes purple and the following error was thrown

Material 'body' with Shader 'SimpleURPToonLitExample(With Outline)' doesn't have a texture property '_MainTex' UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

image

I have tried to

  1. add the original picture to _BaseMap (Albedo)
  2. change the variable _BaseMap to _MainTex in SimpleURPToonLitOutlineExample.shader
    but both does not work...

If it helps, I am using Unity version 2020.1.f11.

I am very new to these tools and concepts, I am sorry if I asked a stupid question.

No answer

Hi,

I sent you an email in order to buy your full shader, but there was no response. Are you still active?

Cull Front issue

角色模型的袖子,是单层面片,前面和后面贴图是不同的,但用了shader后,都变成了后层,怎么办?outline pass似乎是必须Cull Front,改成Cull OFF整个人都灰了
973 7VV8L%3CVFC%6{93FML
9DM(}J3Y_)@$GQZQ9MP)COS
38172I)~6RY(VMPQLXN57FH
左边是nilotoon,右边是simplelit

GPU instancing

Hello,

Thank you for shader, it is very good work.
But i need performance. How can add GPU instancing in shader?

Shader error

shader error in 'SimpleURPToonLitExample(With Outline)': undeclared identifier 'AdditionalLightShadow' at Assets/UnityURPToonLitShaderExample-master/SimpleURPToonLitOutlineExample_Shared.hlsl(354) (on d3d11)
image

compilation error on iOS build

Hello there,

I wanted to use this as a toon shader base for my game, but when I build for iOS the materials with the shader appear in magenta color when game is run on the device. This is the log for the compilation error:

Compilation failed: 
program_source:104:29: error: as_type cast from 'half' to 'int' is not allowed
    u_xlati18 = u_xlatb18 ? as_type<int>(u_xlat16_1.x) : int(0);
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~

I'm total noob when it comes to shaders, and I couldn't figure out what part of code exactly compiles to the one above. Can you please help me with it?

Here is the rest of the dump:


#include <metal_stdlib>
#include <metal_texture>
using namespace metal;
#if !(__HAVE_FMA__)
#define fma(a,b,c) ((a) * (b) + (c))
#endif
#ifndef XLT_REMAP_O
	#define XLT_REMAP_O {0, 1, 2, 3, 4, 5, 6, 7}
#endif
constexpr constant uint xlt_remap_o[] = XLT_REMAP_O;
struct FGlobals_Type
{
    float4 _MainLightPosition;
    half4 _MainLightColor;
    half4 _MainLightShadowParams;
};
struct UnityPerDraw_Type
{
    float4 hlslcc_mtx4x4unity_ObjectToWorld[4];
    float4 hlslcc_mtx4x4unity_WorldToObject[4];
    float4 unity_LODFade;
    half4 unity_WorldTransformParams;
    half4 unity_LightData;
    half4 unity_LightIndices[2];
    float4 unity_ProbesOcclusion;
    half4 unity_SpecCube0_HDR;
    float4 unity_LightmapST;
    float4 unity_DynamicLightmapST;
    half4 unity_SHAr;
    half4 unity_SHAg;
    half4 unity_SHAb;
    half4 unity_SHBr;
    half4 unity_SHBg;
    half4 unity_SHBb;
    half4 unity_SHC;
};
struct UnityPerMaterial_Type
{
    float4 _BaseMap_ST;
    half4 _BaseColor;
    float _UseAlphaClipping;
    half _Cutoff;
    half3 _IndirectLightConstColor;
    half _IndirectLightMultiplier;
    half _DirectLightMultiplier;
    half _CelShadeMidPoint;
    half _CelShadeSoftness;
    half _ReceiveShadowMappingAmount;
    float _UseEmission;
    half3 _EmissionColor;
    half3 _EmissionMapChannelMask;
    float _OutlineWidth;
    half3 _OutlineColor;
};
struct Mtl_FragmentIn
{
    float2 TEXCOORD0 [[ user(TEXCOORD0) ]] ;
    half3 TEXCOORD3 [[ user(TEXCOORD3) ]] ;
    float4 TEXCOORD6 [[ user(TEXCOORD6) ]] ;
};
struct Mtl_FragmentOut
{
    half4 SV_TARGET0 [[ color(xlt_remap_o[0]) ]];
};
constexpr sampler _mtl_xl_shadow_sampler(address::clamp_to_edge, filter::linear, compare_func::greater_equal);
fragment Mtl_FragmentOut xlatMtlMain(
    constant FGlobals_Type& FGlobals [[ buffer(0) ]],
    constant UnityPerDraw_Type& UnityPerDraw [[ buffer(1) ]],
    constant UnityPerMaterial_Type& UnityPerMaterial [[ buffer(2) ]],
    sampler sampler_MainLightShadowmapTexture [[ sampler (0) ]],
    sampler sampler_BaseMap [[ sampler (1) ]],
    sampler sampler_EmissionMap [[ sampler (2) ]],
    texture2d<half, access::sample > _BaseMap [[ texture(0) ]] ,
    texture2d<half, access::sample > _EmissionMap [[ texture(1) ]] ,
    depth2d<float, access::sample > _MainLightShadowmapTexture [[ texture(2) ]] ,
    Mtl_FragmentIn input [[ stage_in ]])
{
    Mtl_FragmentOut output;
    half4 u_xlat16_0;
    half3 u_xlat16_1;
    half3 u_xlat16_2;
    half3 u_xlat16_3;
    half3 u_xlat16_4;
    float u_xlat5;
    half u_xlat16_5;
    bool u_xlatb5;
    half u_xlat16_9;
    half u_xlat16_18;
    int u_xlati18;
    bool u_xlatb18;
    half u_xlat16_20;
    u_xlat16_0 = _BaseMap.sample(sampler_BaseMap, input.TEXCOORD0.xy);
    u_xlat16_0.xyz = u_xlat16_0.xyz * UnityPerMaterial._BaseColor.xyz;
    u_xlat16_1.x = half((float(0.0)!=UnityPerMaterial._UseAlphaClipping) ? 0xFFFFFFFFu : uint(0));
    u_xlat16_2.x = fma(u_xlat16_0.w, UnityPerMaterial._BaseColor.w, (-UnityPerMaterial._Cutoff));
    u_xlatb18 = u_xlat16_2.x<half(0.0);
    u_xlati18 = u_xlatb18 ? as_type<int>(u_xlat16_1.x) : int(0);
    if((u_xlati18)!=0){discard_fragment();}
    u_xlatb18 = float(0.0)!=UnityPerMaterial._UseEmission;
    if(u_xlatb18){
        u_xlat16_1.xyz = _EmissionMap.sample(sampler_EmissionMap, input.TEXCOORD0.xy).xyz;
        u_xlat16_1.xyz = u_xlat16_1.xyz * UnityPerMaterial._EmissionColor.xyzx.xyz;
        u_xlat16_1.xyz = u_xlat16_1.xyz * UnityPerMaterial._EmissionMapChannelMask.xyzx.xyz;
        u_xlat16_1.xyz = u_xlat16_1.xyz;
    }
    u_xlat16_2.xyz = (bool(u_xlatb18)) ? u_xlat16_1.xyz : half3(0.0, 0.0, 0.0);
    u_xlat16_20 = dot(input.TEXCOORD3.xyz, input.TEXCOORD3.xyz);
    u_xlat16_20 = rsqrt(u_xlat16_20);
    u_xlat16_3.xyz = half3(u_xlat16_20) * input.TEXCOORD3.xyz;
    u_xlat16_4.x = max(UnityPerDraw.unity_SHAr.w, half(0.0));
    u_xlat16_4.y = max(UnityPerDraw.unity_SHAg.w, half(0.0));
    u_xlat16_4.z = max(UnityPerDraw.unity_SHAb.w, half(0.0));
    u_xlat16_4.xyz = fma(u_xlat16_4.xyz, half3(UnityPerMaterial._IndirectLightMultiplier), UnityPerMaterial._IndirectLightConstColor.xxyz.yzw);
    u_xlat16_18 = _MainLightShadowmapTexture.sample_compare(_mtl_xl_shadow_sampler, input.TEXCOORD6.xy, saturate(input.TEXCOORD6.z), level(0.0));
    u_xlat16_20 = (-FGlobals._MainLightShadowParams.x) + half(1.0);
    u_xlat16_20 = fma(u_xlat16_18, FGlobals._MainLightShadowParams.x, u_xlat16_20);
    u_xlatb18 = 0.0>=input.TEXCOORD6.z;
    u_xlatb5 = input.TEXCOORD6.z>=1.0;
    u_xlatb18 = u_xlatb18 || u_xlatb5;
    u_xlat16_3.x = dot(float3(u_xlat16_3.xyz), FGlobals._MainLightPosition.xyz);
    u_xlat16_5 = u_xlat16_20 + half(-1.0);
    u_xlat5 = fma(float(UnityPerMaterial._ReceiveShadowMappingAmount), float(u_xlat16_5), 1.0);
    u_xlat16_20 = (u_xlatb18) ? half(1.0) : half(u_xlat5);
    u_xlat16_9 = min(UnityPerDraw.unity_LightData.z, half(2.0));
    u_xlat16_20 = u_xlat16_20 * u_xlat16_9;
    u_xlat16_9 = (-UnityPerMaterial._CelShadeSoftness) + UnityPerMaterial._CelShadeMidPoint;
    u_xlat16_3.z = UnityPerMaterial._CelShadeSoftness + UnityPerMaterial._CelShadeMidPoint;
    u_xlat16_3.xz = (-half2(u_xlat16_9)) + u_xlat16_3.xz;
    u_xlat16_9 = half(1.0) / u_xlat16_3.z;
    u_xlat16_3.x = u_xlat16_9 * u_xlat16_3.x;
    u_xlat16_3.x = clamp(u_xlat16_3.x, 0.0h, 1.0h);
    u_xlat16_9 = fma(u_xlat16_3.x, half(-2.0), half(3.0));
    u_xlat16_3.x = u_xlat16_3.x * u_xlat16_3.x;
    u_xlat16_3.x = u_xlat16_3.x * u_xlat16_9;
    u_xlat16_20 = u_xlat16_20 * u_xlat16_3.x;
    u_xlat16_20 = u_xlat16_20 * UnityPerMaterial._DirectLightMultiplier;
    u_xlat16_3.xyz = u_xlat16_0.xyz * FGlobals._MainLightColor.xyz;
    u_xlat16_3.xyz = half3(u_xlat16_20) * u_xlat16_3.xyz;
    u_xlat16_3.xyz = fma(u_xlat16_0.xyz, u_xlat16_4.xyz, u_xlat16_3.xyz);
    u_xlat16_2.xyz = u_xlat16_2.xyz + u_xlat16_3.xyz;
    output.SV_TARGET0.xyz = u_xlat16_2.xyz * UnityPerMaterial._OutlineColor.xyzx.xyz;
    output.SV_TARGET0.w = half(1.0);
    return output;
}

Bright Pink

I downloaded and unzipped the file. Then I dragged the folder into my editor. After I created a new material I changed the shader from Standard to SimpleURPToonLitExample and it turned bright pink.

Getting some "Couldn't open include file..." errors With 2021.3.33

First of all, thank you very much for sharing these. Actually, I used these shaders before, and now when I want to use them again, I encountered these errors. I tried to research and fix them, but I couldn't manage. I checked if the relevant files were removed from the mentioned repository, but I couldn't find a solution because I'm not very knowledgeable about shaders. How can this issue be resolved?

Version : 2021.3.33f URP
Platform : Windows 10

image

wow

라이트맵
Pink in the shadow area. How did you do it? this is beauti!!!
Is it a light map?

Imported tutorial shader not working correctly on lighting.

First of all, your tutorial shader is greatly appreciated. Thanks for your hard work.

It's my first time to write a custom URP shader, so I'm trying to import your tutorial shader to my project. But there's something wrong with the lighting.

image
On a directional light, the character receives light from every direction(no dark sides).

image
On a point/spot light, the character does not receive any light. The most frustrating thing is, the character receives light from point/spot light when it's closer than 1.5-unit distance.(no matter how far the light range is)

Although, outlines are working properly, and the character produces shadows, other objects (using URP lit shader) normally receive shadows from it. So I'm curious if there's a problem with my project or configurations.

I tested on my project, unity 2021.3.7 LTS and URP 12.1.7, with this version of tutorial shader
https://github.com/ColinLeung-NiloCat/UnityURPToonLitShaderExample/tree/4802381d313d19c04fff97eca59f9a0b34a7e15a
And tested on a basic URP template project, unity 2022.3.20 LTS and URP 14.0.10, with current version of tutorial shader. Same results in both versions.

I made sure to apply material -> shader to tutorial shader, unity gameobject's mesh renderer component->cast shadows=On, unity light object component -> shadow type=hard/soft shadows, URP asset -> Lighting -> Main/Additional Light -> Per pixel, Cast Shadows = True.

This is my URP asset and Universal Render Data. And all the other settings are default.
image
image
image

Thank you for your help!

Anti-Aliasing causes emulator/PC-Quality Demo to run at 1 FPS

When quality slider is set to emulator/PC, the demo runs at a maximum of 1 FPS in all situations except when I turn anti-aliasing off in the "check" scene featuring Klee and Ganyu.

Screen Recording 1
Screen Recording 2 - Less stuttering
Screen recording is done with OBS. The AA at emulator/PC quality taxes my GPU enough that it causes stuttering in my recording. I tried to optimize my encoding settings and uploaded a second screen recording that I hope is helpful. You can notice the recording stutter when my mouse jumps to a new position suddenly. My mouse was moving smoothly across the screen when I recorded this.

My specs as shown in the debug UI are:

OS: Windows 10 (10.0.19042) 64bit [WindowsPlayer]
CPU: AMD Ryzen 7 3700X 8-Core Processor [16 Cores]
GPU: NVIDIA GeForce GTX 1660 SUPER
GPU: Direct3D 11.0 [level 11.1] [Direct3D11]
GPU: SM: 5.0, VRAM: 5991 MB
RAM: 16292 MB
SCR: 3840x2160@60Hz [window size: 3840x2160, DPI: 144]
Model: System Product Name (ASUS)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.