SchultzGames
Para tirar dúvidas, crie um tópico especifico na área "Dúvidas em Geral" e aguarde ser respondido. Evite comentar em tópicos não relacionados a sua dúvida :D
TÓPICOS RECENTES:
Tópico:
Postado em:
Postado por:
Arquivo jar não encontrado
OBJETO sendo detruído imediatamente mesmo com o...
Meu site de Modelos 3D
DÚVIDA - ao pressionar andar, o player parece cancelar a gravidade (VÍDEO)
[RESLVIDO] Unity - "transform.SetParent()" em 2 objetos move outros objetos
Dúvida sobre resoluções de tela
Duvida na AppleStore
pressionando a tecla abaixar, o player continua andando abaixado (2D).
Fala Pessoal! Saiu mais um trailer do jogo que venho desenvolvendo
[RESOLVIDO] passar de uma animação para a outra rapidamente pelo animator
Unity - PlayerPrefs n são apagados no Celular mesmo Reiniciando o Aparelho
Modeloes 3D do Site Sketchfab
Blender - Modelos Importados transparentes
[PEDIDO]Cololar jogo na loja play store
Como pegar um objeto e fazer ele aparecer em forma de Estamina no Inspector
Procuro Pessoas para Projeto
Algum tutorial de como fazer um app que receba fotos e q fiqu armazenado no
Procuro um time para um jogo de corrida
[RESOLVIDO] Botões de Ataque e Pular carrega duas animações ao mesmo tempo
DEATH ISLAND 0.2.5 SURVIVAL GAME 4 ANOS EM DESENVOLVIMENTO
Player travando na colisão com o chão Unity 2D
Como resolver vazamento de memoria?
Instanciar uma classe nos atributos de outra classe é uma boa prática?
Jogo multiplayer com steam
Unity - Renderizção com Câmera Jogo Lento e travando. Alguém pfv?!
Mini Quarteirão com Texturas 3D VENDA
Controle do braço e cabeça no fps
PRECISO FAZER QUE MEU GAME FIQUE ONLINE
Ativar o objeto correto em Clones.
[TUTORIAL] Como fazer um interruptor simples (Unity 2018)
Preciso de 20 testadores jogo mobile
O Labirinto II - Trailer Oficial
Ue posso divulgar meu game que ainda esta em criaçao aqui no forum?
[RESOLVIDO] Inverter o sprite para a direçao que o personagem anda.
Set Active não a reabiilitado C#
Build APK VR Google Cardbord com video.
[PROGRAMADOR FREELA] $$
Mais Um jogo!
Collider (mesh?)
[TUTORIAL] Deformar mesh com batidas (para objetos, veículos, etc)
WW2 Low poly Pack (Free)
Procuro freelancer
Novo Teaser do jogo Dark Age
Unity Admob Erro
Sombras estão quadradas na build
nao consigo fazer o player sentar no sofa alguem me ajuda
Unity - Ao mudar de scene, todas as Lights são deletadas
210 Linhas de código para inimigo é muito grande?
modelar avatar e skins para um jogo web
ShapeKeys do Blender para a Unity altera áreas próximas
COMO EVITAR QUE UM OBJETO (PLAYER,ITEM ETC...) ATRAVESSE UMA PAREDE.
Ajuda em Script de Verificação de Ação e Reação
unity Failed to load PlayerSettings (internal index #0). Most likely data f
Materiais do Blander não aparecem no MeshRendere do Objeto na Unity
Repetiçoes de Textura no Terreno
SERVER IS DOWN - UNITY+MSQL
Procuro programadores - Novo jogo
Problema com o MS VEHICLES
Preciso de ajuda com a Unity
Problema com vídeo em 360° na Unity
Problemas no MS Vehicles
unity- eventos na Animação com Armature/Bones vinda do blender não funciona
ajuda exibir resultados simulados em uma liga Game Unity
Unity - ParticleSystem não é redirecionado no rawimage no canvas
Como resolver o problema de "face orientation" no Blender.
[DÚVIDA] Tive um problema com meu Canvas
erro na Directional Light
Problemas com o Directional Light da Unity 3D
Novo jogo da franquia Sphere game em desenvolvimento
malha da roda não girando com wheel collider unity
Problemas com ambiguidade
Touch mobile
INVALID TOKEN
Como acessar o "HD Render Pipeline" do HDRP por script?
CHAT GPT PRA JOGO DE TIRO? comentem
Tutorial script inimigo segue e foge do player
Ainda vale a pena lançar Asset na Asset Store?
Ajuda com tabela de historico de pontuaçao.
[TUTORIAL] Entrar no carro estilo GTA
Como derrapar um Whell Collider
Como altertar o valor do "Asymptote Value" do Whell Collider via Script
Preciso de ajuda para substituir valor de variavel em outro script
Ajuda com Top Down Shooter utilizando Photon
Duvida com Netcode
[RESOLVIDO] Unity - Movendo a Câmera na Horizontal/Vertical com Touch
Alguém me ajuda com os anúncios pfv
Segundo Trailer do jogo Dark Age, Feliz Natal a todos!
Unity - ScrollRect, Viewport, Content - O Conteúdo ñ inicia no topo
Coleta de itens
Unity - Cadastro do email do jogador
[GRATIS] PACK DE MODELOS 3D PARA JOGO DE TERROR
Onde Conseguir músicas para meu Jogo?
error CS0246 em Script
Alguem teve ja esse problema?
[Projeto em Andamento] Draug, um jogo de hordas
DISPONIVEL PARA FAZER MODELOS 3D
Unity-Loja.Como os Jogadores terão acesso aos ítens comprados na PlayStore?
Bugando depois do Build.
Primeiro Trailer do jogo Dark Age
Qua Out 23, 2024 8:39 pm
Sex Out 18, 2024 4:05 pm
Dom Out 06, 2024 6:02 pm
Sáb Out 05, 2024 6:37 am
Qui Out 03, 2024 10:09 pm
Seg Set 30, 2024 9:25 am
Sáb Set 28, 2024 11:39 am
Seg Set 09, 2024 7:33 am
Dom Set 08, 2024 10:08 pm
Ter Set 03, 2024 11:59 am
Qua Ago 28, 2024 7:45 pm
Qua Ago 28, 2024 7:18 pm
Qua Ago 28, 2024 8:34 am
Dom Ago 25, 2024 8:37 pm
Sáb Ago 24, 2024 1:58 pm
Sex Ago 23, 2024 3:30 pm
Sex Ago 23, 2024 3:23 pm
Qua Ago 21, 2024 5:48 pm
Dom Ago 18, 2024 8:51 pm
Sex Ago 16, 2024 12:59 pm
Qua Ago 14, 2024 10:57 am
Sáb Ago 10, 2024 8:03 pm
Sex Ago 09, 2024 7:37 pm
Dom Ago 04, 2024 4:41 pm
Dom Ago 04, 2024 3:16 pm
Qui Jul 25, 2024 2:48 pm
Dom Jul 21, 2024 7:07 pm
Dom Jul 21, 2024 12:07 am
Sáb Jul 13, 2024 12:33 am
Qui Jun 27, 2024 5:49 pm
Qui Jun 20, 2024 12:30 pm
Dom Jun 09, 2024 7:43 pm
Dom Jun 09, 2024 2:16 pm
Seg Jun 03, 2024 11:39 am
Seg maio 27, 2024 12:45 pm
Seg maio 20, 2024 9:01 pm
Dom maio 19, 2024 3:08 pm
Sáb maio 18, 2024 11:46 am
Sáb maio 11, 2024 8:55 am
Qui maio 09, 2024 11:33 pm
Seg Abr 29, 2024 9:34 pm
Qui Abr 25, 2024 3:34 pm
Seg Abr 22, 2024 5:15 pm
Seg Abr 15, 2024 12:23 pm
Seg Abr 08, 2024 9:27 pm
Seg Abr 08, 2024 8:01 am
Sáb Abr 06, 2024 8:05 pm
Qui Abr 04, 2024 11:34 pm
Qui Abr 04, 2024 11:13 pm
Sex Mar 22, 2024 2:41 pm
Dom Mar 10, 2024 2:30 pm
Sex Mar 01, 2024 1:27 pm
Qui Fev 22, 2024 9:57 pm
Ter Fev 20, 2024 12:15 am
Seg Fev 19, 2024 1:06 pm
Seg Fev 12, 2024 1:56 pm
Seg Fev 12, 2024 1:17 pm
Dom Fev 11, 2024 8:55 pm
Dom Fev 11, 2024 11:16 am
Seg Fev 05, 2024 4:18 pm
Dom Fev 04, 2024 9:39 pm
Qua Jan 31, 2024 11:59 pm
Ter Jan 30, 2024 7:37 pm
Ter Jan 23, 2024 6:33 pm
Dom Jan 21, 2024 6:03 pm
Sáb Jan 20, 2024 7:03 pm
Sáb Jan 20, 2024 6:58 pm
Sáb Jan 20, 2024 6:39 pm
Sex Jan 19, 2024 8:40 am
Dom Jan 14, 2024 5:30 pm
Qua Jan 10, 2024 10:29 pm
Qua Jan 10, 2024 8:55 pm
Qua Jan 10, 2024 7:14 pm
Ter Jan 09, 2024 3:55 pm
Ter Jan 09, 2024 8:04 am
Sáb Jan 06, 2024 8:02 pm
Sex Jan 05, 2024 7:01 am
Sex Jan 05, 2024 12:12 am
Qui Jan 04, 2024 6:55 pm
Qui Jan 04, 2024 12:52 pm
Qui Jan 04, 2024 4:34 am
Ter Jan 02, 2024 11:48 pm
Dom Dez 31, 2023 7:25 pm
Qua Dez 27, 2023 5:44 pm
Qua Dez 27, 2023 3:08 pm
Sáb Dez 23, 2023 7:27 pm
Sáb Dez 23, 2023 5:06 pm
Qui Dez 21, 2023 8:10 pm
Seg Dez 18, 2023 2:04 pm
Sex Dez 15, 2023 5:11 pm
Qui Dez 14, 2023 9:13 pm
Qui Dez 14, 2023 2:47 pm
Qui Dez 14, 2023 1:48 pm
Qua Dez 13, 2023 8:58 pm
Ter Dez 12, 2023 2:32 pm
Seg Dez 11, 2023 1:53 pm
Qua Dez 06, 2023 8:13 pm
Sáb Dez 02, 2023 8:06 pm
Qui Nov 30, 2023 7:49 am



































































































Shader não funciona no Unity URP

Ir para baixo

DÚVIDA Shader não funciona no Unity URP

Mensagem por AGAMENOM Dom Jun 18, 2023 6:11 pm

Eu estou produzindo um jogo com a temática de MMD ou TDA para simplificar.

E estou usando um pacote chamado MMD4Mecanim para isso.
So que o unity URP é muito melhor para fazer coisas relacionadas a clima e ambientação do que o unity base.

O problema é que os Shader do pacote estão ficando rosas no URP.

Então se alguém souber como arrumar ou onde eu posso conseguir ajuda com isso seria de grande ajuda.

Vou deixar aqui embaixo os códigos do Shader e o link para o pacote caso queira ver com mais exatidão.

Link do pacote: https://stereoarts.jp/

Códigos dos Importadores de inclusão do Shader:
Código:
// Not for redistribution without the author's express written permission
#include "HLSLSupport.cginc"
#include "UnityShaderVariables.cginc"
#define UNITY_PASS_SHADOWCOLLECTOR
#define SHADOW_COLLECTOR_PASS
#include "UnityCG.cginc"
#include "Lighting.cginc"
#include "MMD4Mecanim-MMDLit-Lighting.cginc"
#include "MMD4Mecanim-MMDLit-Surface-Lighting.cginc"

#define INTERNAL_DATA
#define WorldReflectionVector(data,normal) data.worldRefl
#define WorldNormalVector(data,normal) normal

//half4 _Color;
//sampler2D _MainTex;

struct v2f_surf {
  V2F_SHADOW_COLLECTOR;
  float2 pack0 : TEXCOORD5;
};
v2f_surf vert_surf (appdata_full v) {
  v2f_surf o;
  o.pack0.xy = v.texcoord;
  TRANSFER_SHADOW_COLLECTOR(o)
  return o;
}
fixed4 frag_surf (v2f_surf IN) : MMDLIT_SV_TARGET{
  half4 albedo = (half4)tex2D(_MainTex, IN.pack0.xy);
  albedo.a *= _Color.a; // for Transparency
  MMDLIT_CLIP(albedo.a)

  SHADOW_COLLECTOR_FRAGMENT(IN)
}

fixed4 frag_fast (v2f_surf IN) : MMDLIT_SV_TARGET{
  MMDLIT_CLIP_FAST(1.0)
  SHADOW_COLLECTOR_FRAGMENT(IN)
}

#ifdef TESSELLATION_ON
#ifdef UNITY_CAN_COMPILE_TESSELLATION

// tessellation domain shader
[UNITY_domain("tri")]
v2f_surf ds_surf(UnityTessellationFactors tessFactors, const OutputPatch<InternalTessInterp_appdata_full, 3> vi, float3 bary : SV_DomainLocation)
{
   appdata_full v = _ds_appdata_full(tessFactors, vi, bary);
   v2f_surf o = vert_surf(v);
   return o;
}

#endif // UNITY_CAN_COMPILE_TESSELLATION
#endif // TESSELLATION_ON

Código:
// Not for redistribution without the author's express written permission
#include "HLSLSupport.cginc"
#include "UnityShaderVariables.cginc"
#ifndef UNITY_PASS_FORWARDADD
#define UNITY_PASS_FORWARDADD
#endif
#include "UnityCG.cginc"
#include "Lighting.cginc"
#include "MMD4Mecanim-MMDLit-AutoLight.cginc"

#define INTERNAL_DATA
#define WorldReflectionVector(data,normal) data.worldRefl
#define WorldNormalVector(data,normal) normal

#include "MMD4Mecanim-MMDLit-Lighting.cginc"
#include "MMD4Mecanim-MMDLit-Surface-Lighting.cginc"
#include "MMD4Mecanim-MMDLit-Compatible.cginc"

struct v2f_surf
{
   float4 pos : SV_POSITION;
   float4 pack0 : TEXCOORD0;
   half3 normal : TEXCOORD1;
   half4 lightDir : TEXCOORD2;
   half4 viewDir : TEXCOORD3;
   LIGHTING_COORDS(4,5)
};

float4 _MainTex_ST;

v2f_surf vert_surf(appdata_full v)
{
   v2f_surf o;
   o.pos = _UnityObjectToClipPos(v.vertex);
   o.pack0.xy = v.texcoord.xy;
   o.normal = mul((float3x3)_UNITY_OBJECT_TO_WORLD, SCALED_NORMAL);
   o.lightDir.xyz = WorldSpaceLightDir(v.vertex);
   o.viewDir.xyz = WorldSpaceViewDir(v.vertex);
   half NdotL = dot(o.normal, (half3)o.lightDir);
   half toonRefl = MMDLit_GetToolRefl(NdotL);
   o.pack0.z = toonRefl;
   o.pack0.w = MMDLit_GetForwardAddStr(toonRefl);
   o.lightDir.w = 0.0;
   o.viewDir.w = MMDLit_GetToonShadow(toonRefl);
   TRANSFER_VERTEX_TO_FRAGMENT(o);
   return o;
}

inline half3 frag_core(in v2f_surf IN, half4 albedo)
{
   half atten = LIGHT_ATTENUATION(IN); // SHADOW_ATTENUATION() might be 1.0 (Can use LIGHT_ATTENUATION() only.)
   #ifndef USING_DIRECTIONAL_LIGHT
   half3 lightDir = normalize((half3)IN.lightDir);
   #else
   half3 lightDir = (half3)IN.lightDir;
   #endif

   half toonRefl = (half)IN.pack0.z;
   half forwardAddStr = (half)IN.pack0.w;
   half toonShadow = IN.viewDir.w;
   half NdotL = IN.lightDir.w;
   half3 c = MMDLit_Lighting_Add(
      (half3)albedo,
      NdotL,
      toonRefl,
      toonShadow,
      IN.normal,
      (half3)lightDir,
      normalize((half3)IN.viewDir),
      atten);

   c *= forwardAddStr;
   return c;
}

fixed4 frag_surf(v2f_surf IN) : MMDLIT_SV_TARGET
{
   half4 albedo = MMDLit_GetAlbedo(IN.pack0.xy);
   albedo.a *= _Color.a; // for Transparency
   MMDLIT_CLIP(albedo.a)
   half3 c = frag_core(IN, albedo);
   c = min(c, 1.0);
   c *= albedo.a;
   return fixed4(c, 0.0);
}

fixed4 frag_fast(v2f_surf IN) : MMDLIT_SV_TARGET
{
   half4 albedo = MMDLit_GetAlbedo(IN.pack0.xy);
   MMDLIT_CLIP_FAST(albedo.a)
   half3 c = frag_core(IN, albedo);
   return fixed4(c, 0.0);
}

#ifdef TESSELLATION_ON
#ifdef UNITY_CAN_COMPILE_TESSELLATION

// tessellation domain shader
[UNITY_domain("tri")]
v2f_surf ds_surf(UnityTessellationFactors tessFactors, const OutputPatch<InternalTessInterp_appdata_full, 3> vi, float3 bary : SV_DomainLocation)
{
   appdata_full v = _ds_appdata_full(tessFactors, vi, bary);
   v2f_surf o = vert_surf(v);
   return o;
}

#endif // UNITY_CAN_COMPILE_TESSELLATION
#endif // TESSELLATION_ON

Código:
// Not for redistribution without the author's express written permission
// UNITY_SHADER_NO_UPGRADE
#include "AutoLight.cginc"

// ------------------------------
//  Light helpers (5.0+ version)
// ------------------------------

#if UNITY_VERSION >= 540
#define _UNITY_WORLD_TO_LIGHT unity_WorldToLight
#else
#define _UNITY_WORLD_TO_LIGHT _LightMatrix0
#endif

#if UNITY_VERSION >= 500

#undef UNITY_LIGHT_ATTENUATION

#ifdef POINT
#define UNITY_LIGHT_ATTENUATION(destName, input, worldPos) \
   unityShadowCoord3 lightCoord = mul(_UNITY_WORLD_TO_LIGHT, unityShadowCoord4(worldPos, 1)).xyz; \
   fixed destName = (tex2D(_LightTexture0, dot(lightCoord, lightCoord).rr).UNITY_ATTEN_CHANNEL);
#endif

#ifdef SPOT
#define UNITY_LIGHT_ATTENUATION(destName, input, worldPos) \
   unityShadowCoord4 lightCoord = mul(_UNITY_WORLD_TO_LIGHT, unityShadowCoord4(worldPos, 1)); \
   fixed destName = (lightCoord.z > 0) * UnitySpotCookie(lightCoord) * UnitySpotAttenuate(lightCoord.xyz);
#endif


#ifdef DIRECTIONAL
#define UNITY_LIGHT_ATTENUATION(destName, input, worldPos)   fixed destName = 1.0;
#endif


#ifdef POINT_COOKIE
#define UNITY_LIGHT_ATTENUATION(destName, input, worldPos) \
   unityShadowCoord3 lightCoord = mul(_UNITY_WORLD_TO_LIGHT, unityShadowCoord4(worldPos, 1)).xyz; \
   fixed destName = tex2D(_LightTextureB0, dot(lightCoord, lightCoord).rr).UNITY_ATTEN_CHANNEL * texCUBE(_LightTexture0, lightCoord).w;
#endif

#ifdef DIRECTIONAL_COOKIE
#define UNITY_LIGHT_ATTENUATION(destName, input, worldPos) \
   unityShadowCoord2 lightCoord = mul(_UNITY_WORLD_TO_LIGHT, unityShadowCoord4(worldPos, 1)).xy; \
   fixed destName = tex2D(_LightTexture0, lightCoord).w;
#endif

#endif // UNITY_VERSION >= 500

// -----------------------------
//  Light helpers (4.x version)
// -----------------------------

#undef LIGHT_ATTENUATION

#ifdef POINT
#define LIGHT_ATTENUATION(a)   (tex2D(_LightTexture0, dot(a._LightCoord,a._LightCoord).rr).UNITY_ATTEN_CHANNEL)
#endif

#ifdef SPOT
#define LIGHT_ATTENUATION(a)   ( (a._LightCoord.z > 0) * UnitySpotCookie(a._LightCoord) * UnitySpotAttenuate(a._LightCoord.xyz) )
#endif


#ifdef DIRECTIONAL
   #define LIGHT_ATTENUATION(a)   1.0
#endif


#ifdef POINT_COOKIE
#define LIGHT_ATTENUATION(a)   (tex2D(_LightTextureB0, dot(a._LightCoord,a._LightCoord).rr).UNITY_ATTEN_CHANNEL * texCUBE(_LightTexture0, a._LightCoord).w)
#endif

#ifdef DIRECTIONAL_COOKIE
#define LIGHT_ATTENUATION(a)   (tex2D(_LightTexture0, a._LightCoord).w)
#endif

// -----------------------------
//  Salvage some macros (2018.1 or later)
// -----------------------------

#if UNITY_VERSION >= 201801
#if !defined(UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS)

#undef DECLARE_LIGHT_COORDS
#undef COMPUTE_LIGHT_COORDS

#ifdef POINT
#       define DECLARE_LIGHT_COORDS(idx) unityShadowCoord3 _LightCoord : TEXCOORD##idx;
#       define COMPUTE_LIGHT_COORDS(a) a._LightCoord = mul(unity_WorldToLight, mul(unity_ObjectToWorld, v.vertex)).xyz;
#endif

#ifdef SPOT
#       define DECLARE_LIGHT_COORDS(idx) unityShadowCoord4 _LightCoord : TEXCOORD##idx;
#       define COMPUTE_LIGHT_COORDS(a) a._LightCoord = mul(unity_WorldToLight, mul(unity_ObjectToWorld, v.vertex));
#endif

#ifdef DIRECTIONAL
#define DECLARE_LIGHT_COORDS(idx)
#define COMPUTE_LIGHT_COORDS(a)
#endif

#ifdef POINT_COOKIE
#       define DECLARE_LIGHT_COORDS(idx) unityShadowCoord3 _LightCoord : TEXCOORD##idx;
#       define COMPUTE_LIGHT_COORDS(a) a._LightCoord = mul(unity_WorldToLight, mul(unity_ObjectToWorld, v.vertex)).xyz;
#endif

#ifdef DIRECTIONAL_COOKIE
#       define DECLARE_LIGHT_COORDS(idx) unityShadowCoord2 _LightCoord : TEXCOORD##idx;
#       define COMPUTE_LIGHT_COORDS(a) a._LightCoord = mul(unity_WorldToLight, mul(unity_ObjectToWorld, v.vertex)).xy;
#endif

#endif //!defined(UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS)
#endif // UNITY_VERSION >= 201801

Código:
// Not for redistribution without the author's express written permission
#include "HLSLSupport.cginc"
#include "UnityShaderVariables.cginc"
#ifndef UNITY_PASS_SHADOWCASTER
#define UNITY_PASS_SHADOWCASTER
#endif
#include "UnityCG.cginc"
#include "Lighting.cginc"
#include "MMD4Mecanim-MMDLit-Lighting.cginc"
#include "MMD4Mecanim-MMDLit-Surface-Lighting.cginc"

#define INTERNAL_DATA
#define WorldReflectionVector(data,normal) data.worldRefl
#define WorldNormalVector(data,normal) normal

struct v2f_surf {
  V2F_SHADOW_CASTER;
  float2 pack0 : TEXCOORD1;
};
v2f_surf vert_surf (appdata_full v) {
  v2f_surf o;
  o.pack0.xy = v.texcoord;
  TRANSFER_SHADOW_CASTER(o)
  return o;
}
fixed4 frag_surf (v2f_surf IN) : MMDLIT_SV_TARGET{
  half4 albedo = (half4)tex2D(_MainTex, IN.pack0.xy);
  albedo.a *= _Color.a; // for Transparency
  MMDLIT_CLIP(albedo.a)

  SHADOW_CASTER_FRAGMENT(IN)
}

fixed4 frag_fast (v2f_surf IN) : MMDLIT_SV_TARGET{
  MMDLIT_CLIP_FAST(1.0)
  SHADOW_CASTER_FRAGMENT(IN)
}

#ifdef TESSELLATION_ON
#ifdef UNITY_CAN_COMPILE_TESSELLATION

// tessellation domain shader
[UNITY_domain("tri")]
v2f_surf ds_surf(UnityTessellationFactors tessFactors, const OutputPatch<InternalTessInterp_appdata_full, 3> vi, float3 bary : SV_DomainLocation)
{
   appdata_full v = _ds_appdata_full(tessFactors, vi, bary);
   v2f_surf o = vert_surf(v);
   return o;
}

#endif // UNITY_CAN_COMPILE_TESSELLATION
#endif // TESSELLATION_ON

Código:
// Not for redistribution without the author's express written permission
#include "HLSLSupport.cginc"
#include "UnityShaderVariables.cginc"
#ifndef UNITY_PASS_FORWARDADD
#define UNITY_PASS_FORWARDADD
#endif
#include "UnityCG.cginc"
#include "Lighting.cginc"
#include "MMD4Mecanim-MMDLit-AutoLight.cginc"

#define INTERNAL_DATA
#define WorldReflectionVector(data,normal) data.worldRefl
#define WorldNormalVector(data,normal) normal

#include "MMD4Mecanim-MMDLit-Lighting.cginc"
#include "MMD4Mecanim-MMDLit-SurfaceEdge-Lighting.cginc"

struct v2f_surf {
   float4 pos : SV_POSITION;
   LIGHTING_COORDS(0,1)
};

v2f_surf vert_surf (appdata_full v)
{
   v2f_surf o;
   float3 worldN = mul((float3x3)_UNITY_OBJECT_TO_WORLD, SCALED_NORMAL);
   v.vertex = MMDLit_GetEdgeVertex(v.vertex, v.normal);
   o.pos = MMDLit_TransformEdgeVertex(v.vertex);
   TRANSFER_VERTEX_TO_FRAGMENT(o);
   return o;
}

fixed4 frag_surf (v2f_surf IN) : MMDLIT_SV_TARGET
{
   half alpha;
   half3 albedo = MMDLit_GetAlbedo(alpha);

   MMDLIT_CLIP(alpha)
   
   half3 c = MMDLit_Lighting(albedo, LIGHT_ATTENUATION(IN), half3(0.0, 0.0, 0.0));
   c = min(c, 1.0);
   c *= alpha;
   return fixed4(c, 0.0);
}

#ifdef TESSELLATION_ON
#ifdef UNITY_CAN_COMPILE_TESSELLATION

// tessellation domain shader
[UNITY_domain("tri")]
v2f_surf ds_surf(UnityTessellationFactors tessFactors, const OutputPatch<InternalTessInterp_appdata_full, 3> vi, float3 bary : SV_DomainLocation)
{
   appdata_full v = _ds_appdata_full(tessFactors, vi, bary);
   v2f_surf o = vert_surf(v);
   return o;
}

#endif // UNITY_CAN_COMPILE_TESSELLATION
#endif // TESSELLATION_ON

Código:
// Not for redistribution without the author's express written permission
#include "HLSLSupport.cginc"
#include "UnityShaderVariables.cginc"
#ifndef UNITY_PASS_FORWARDBASE
#define UNITY_PASS_FORWARDBASE
#endif
#include "UnityCG.cginc"
#include "Lighting.cginc"

#include "MMD4Mecanim-MMDLit-Lighting.cginc"
#include "MMD4Mecanim-MMDLit-NEXTEdge-Lighting.cginc"

struct v2f_surf {
  float4 pos : SV_POSITION;
  half3 viewDir : TEXCOORD1;
  half3 normal : TEXCOORD2;
};

v2f_surf vert_surf (appdata_full v)
{
   v2f_surf o;
   v.vertex = MMDLit_GetEdgeVertex(v.vertex, v.normal);
   o.pos = MMDLit_TransformEdgeVertex(v.vertex);
   o.normal = mul((float3x3)_UNITY_OBJECT_TO_WORLD, SCALED_NORMAL);
   o.viewDir = (half3)WorldSpaceViewDir(v.vertex);
   return o;
}

half4 frag_surf (v2f_surf IN) : MMDLIT_SV_TARGET
{
   half4 c = _EdgeColor;
   half3 viewDir = normalize(IN.viewDir);
   half r = saturate(dot(-viewDir, IN.normal));
   c.a *= r * ALPHA_SCALE;
   return c;
}

Código:
// Not for redistribution without the author's express written permission
#include "HLSLSupport.cginc"
#include "UnityShaderVariables.cginc"
#ifndef UNITY_PASS_FORWARDBASE
#define UNITY_PASS_FORWARDBASE
#endif
#include "UnityCG.cginc"
#include "Lighting.cginc"
#include "MMD4Mecanim-MMDLit-AutoLight.cginc"

#define INTERNAL_DATA
#define WorldReflectionVector(data,normal) data.worldRefl
#define WorldNormalVector(data,normal) normal

#include "MMD4Mecanim-MMDLit-Lighting.cginc"
#include "MMD4Mecanim-MMDLit-SurfaceEdge-Lighting.cginc"

struct v2f_surf {
   float4 pos : SV_POSITION;
   LIGHTING_COORDS(0,1)
   half3 vlight : TEXCOORD2;
};

v2f_surf vert_surf (appdata_full v)
{
   v2f_surf o;
   v.vertex = MMDLit_GetEdgeVertex(v.vertex, v.normal);
   o.pos = MMDLit_TransformEdgeVertex(v.vertex);
   float3 worldN = mul((float3x3)_UNITY_OBJECT_TO_WORLD, SCALED_NORMAL);
   o.vlight = ShadeSH9(float4(worldN, 1.0));
   TRANSFER_VERTEX_TO_FRAGMENT(o);
   return o;
}

fixed4 frag_surf (v2f_surf IN) : MMDLIT_SV_TARGET
{
   half alpha;
   half3 albedo = MMDLit_GetAlbedo(alpha);

   MMDLIT_CLIP(alpha)
   
   half atten = LIGHT_ATTENUATION(IN);
   half3 c;

   c = MMDLit_Lighting(albedo, atten, IN.vlight);
   return fixed4(c, alpha);
}

#ifdef TESSELLATION_ON
#ifdef UNITY_CAN_COMPILE_TESSELLATION

// tessellation domain shader
[UNITY_domain("tri")]
v2f_surf ds_surf(UnityTessellationFactors tessFactors, const OutputPatch<InternalTessInterp_appdata_full, 3> vi, float3 bary : SV_DomainLocation)
{
   appdata_full v = _ds_appdata_full(tessFactors, vi, bary);
   v2f_surf o = vert_surf(v);
   return o;
}

#endif // UNITY_CAN_COMPILE_TESSELLATION
#endif // TESSELLATION_ON

Código:
// Not for redistribution without the author's express written permission
#include "HLSLSupport.cginc"
#include "UnityShaderVariables.cginc"
#ifndef UNITY_PASS_FORWARDBASE
#define UNITY_PASS_FORWARDBASE
#endif
#include "UnityCG.cginc"
#include "Lighting.cginc"
#include "MMD4Mecanim-MMDLit-AutoLight.cginc"

#define INTERNAL_DATA
#define WorldReflectionVector(data,normal) data.worldRefl
#define WorldNormalVector(data,normal) normal

#include "MMD4Mecanim-MMDLit-Lighting.cginc"
#include "MMD4Mecanim-MMDLit-Surface-Lighting.cginc"
#include "MMD4Mecanim-MMDLit-Compatible.cginc"

#ifdef TESSELLATION_ON
#include "Tessellation.cginc"
#endif

struct v2f_surf {
   float4 pos : SV_POSITION;
   float2 pack0 : TEXCOORD0;
   half3 normal : TEXCOORD1;
   half3 vlight : TEXCOORD2;
   half3 viewDir : TEXCOORD3;
   LIGHTING_COORDS(4,5)
   half3 mmd_globalAmbient : TEXCOORD6;
   #ifdef SPHEREMAP_ON
   half3 mmd_uvwSphere : TEXCOORD7;
   #endif
};

float4 _MainTex_ST;

v2f_surf vert_surf(appdata_full v)
{
   v2f_surf o;
   o.pos = _UnityObjectToClipPos(v.vertex);
   o.pack0.xy = v.texcoord.xy;
   float3 worldN = mul((float3x3)_UNITY_OBJECT_TO_WORLD, SCALED_NORMAL);
   o.normal = worldN;

   #ifdef SPHEREMAP_ON
   float4x4 matMV = MMDLit_GetMatrixMV();
   half3 norm = normalize(mul((float3x3)matMV, v.normal));
   half3 eye = normalize(mul(matMV, v.vertex).xyz);
   o.mmd_uvwSphere = reflect(eye, norm);
   #endif
   
   o.viewDir = (half3)WorldSpaceViewDir(v.vertex);
   
   o.vlight = ShadeSH9(float4(worldN, 1.0));
   o.mmd_globalAmbient = o.vlight;
   #ifdef VERTEXLIGHT_ON
   float3 worldPos = mul(_UNITY_OBJECT_TO_WORLD, v.vertex).xyz;
   o.vlight += Shade4PointLights(
      unity_4LightPosX0, unity_4LightPosY0, unity_4LightPosZ0,
      unity_LightColor[0].rgb, unity_LightColor[1].rgb, unity_LightColor[2].rgb, unity_LightColor[3].rgb,
      unity_4LightAtten0, worldPos, worldN );
   #endif // VERTEXLIGHT_ON
   // Feedback Ambient.
   o.vlight *= MMDLit_GetAmbientRate();

   TRANSFER_VERTEX_TO_FRAGMENT(o);
   return o;
}

inline half4 frag_core(in v2f_surf IN, half4 albedo)
{
   half atten = LIGHT_ATTENUATION(IN);
   half shadowAtten = SHADOW_ATTENUATION(IN);
   half3 c;

   half3 baseC;
   half NdotL = dot(IN.normal, _WorldSpaceLightPos0.xyz);
   c = MMDLit_Lighting(
      (half3)albedo,
      #ifdef SPHEREMAP_ON
      IN.mmd_uvwSphere,
      #else
      half3( 0.0, 0.0, 0.0 ),
      #endif
      NdotL,
      IN.normal,
      _WorldSpaceLightPos0.xyz,
      normalize(IN.viewDir),
      atten,
      shadowAtten,
      baseC,
      IN.mmd_globalAmbient);

   c += baseC * IN.vlight;

   return half4(c, albedo.a);
}

// for Transparency
half4 frag_surf(v2f_surf IN) : MMDLIT_SV_TARGET
{
   half4 albedo = MMDLit_GetAlbedo(IN.pack0.xy);
   albedo.a *= _Color.a; // for Transparency
   MMDLIT_CLIP(albedo.a)
   return frag_core(IN, albedo);
}

// for Opaque
half4 frag_fast(v2f_surf IN) : MMDLIT_SV_TARGET
{
   half4 albedo = MMDLit_GetAlbedo(IN.pack0.xy);
   MMDLIT_CLIP_FAST(albedo.a)
   return frag_core(IN, albedo);
}

#ifdef TESSELLATION_ON
#ifdef UNITY_CAN_COMPILE_TESSELLATION

// tessellation domain shader
[UNITY_domain("tri")]
v2f_surf ds_surf(UnityTessellationFactors tessFactors, const OutputPatch<InternalTessInterp_appdata_full, 3> vi, float3 bary : SV_DomainLocation)
{
   appdata_full v = _ds_appdata_full(tessFactors, vi, bary);
   v2f_surf o = vert_surf(v);
   return o;
}

#endif // UNITY_CAN_COMPILE_TESSELLATION
#endif // TESSELLATION_ON

Código:
// Not for redistribution without the author's express written permission
// UNITY_SHADER_NO_UPGRADE
#ifndef MMDLIT_SURFACE_TESSELLATION_INCLUDED
#define MMDLIT_SURFACE_TESSELLATION_INCLUDED

#ifdef TESSELLATION_ON
#include "HLSLSupport.cginc" // UNITY_CAN_COMPILE_TESSELLATION
#include "Lighting.cginc" // UnityTessellationFactors
#include "Tessellation.cginc"

#ifdef UNITY_CAN_COMPILE_TESSELLATION

float _TessPhongStrength;
float _TessEdgeLength;
float _TessExtrusionAmount;

#if UNITY_VERSION >= 500
struct InternalTessInterp_appdata_full
{
   float4 vertex : INTERNALTESSPOS;
   float4 tangent : TANGENT;
   float3 normal : NORMAL;
   float4 texcoord : TEXCOORD0;
   float4 texcoord1 : TEXCOORD1;
   float4 texcoord2 : TEXCOORD2;
   float4 texcoord3 : TEXCOORD3;
#if defined(SHADER_API_XBOX360)
   half4 texcoord4 : TEXCOORD4;
   half4 texcoord5 : TEXCOORD5;
#endif // defined(SHADER_API_XBOX360)
   fixed4 color : COLOR;
   //   UNITY_INSTANCE_ID
};
#else // UNITY_VERSION >= 500
struct InternalTessInterp_appdata_full
{
   float4 vertex : INTERNALTESSPOS;
   float4 tangent : TANGENT;
   float3 normal : NORMAL;
   float4 texcoord : TEXCOORD0;
   float4 texcoord1 : TEXCOORD1;
   fixed4 color : COLOR;
#if defined(SHADER_API_XBOX360)
   half4 texcoord2 : TEXCOORD2;
   half4 texcoord3 : TEXCOORD3;
   half4 texcoord4 : TEXCOORD4;
   half4 texcoord5 : TEXCOORD5;
#endif // defined(SHADER_API_XBOX360)
};
#endif // UNITY_VERSION >= 500

InternalTessInterp_appdata_full tess_appdata_full(appdata_full v)
{
   InternalTessInterp_appdata_full o;
   o.vertex = v.vertex;
   o.tangent = v.tangent;
   o.normal = v.normal;
   o.texcoord = v.texcoord;
   o.texcoord1 = v.texcoord1;
   o.color = v.color;
#if UNITY_VERSION >= 500
   o.texcoord2 = v.texcoord2;
   o.texcoord3 = v.texcoord3;
#if defined(SHADER_API_XBOX360)
   o.texcoord4 = v.texcoord4;
   o.texcoord5 = v.texcoord5;
#endif // defined(SHADER_API_XBOX360)
#else // UNITY_VERSION >= 500
#if defined(SHADER_API_XBOX360)
   o.texcoord2 = v.texcoord2;
   o.texcoord3 = v.texcoord3;
   o.texcoord4 = v.texcoord4;
   o.texcoord5 = v.texcoord5;
#endif // defined(SHADER_API_XBOX360)
#endif // UNITY_VERSION >= 500
   return o;
}

// tessellation hull constant shader
UnityTessellationFactors hsconst_appdata_full(InputPatch<InternalTessInterp_appdata_full, 3> v)
{
   float4 tf = UnityEdgeLengthBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, _TessEdgeLength);
   UnityTessellationFactors o;
   o.edge[0] = tf.x;
   o.edge[1] = tf.y;
   o.edge[2] = tf.z;
   o.inside = tf.w;
   return o;
}

// tessellation hull shader
[UNITY_domain("tri")]
[UNITY_partitioning("fractional_odd")]
[UNITY_outputtopology("triangle_cw")]
[UNITY_patchconstantfunc("hsconst_appdata_full")]
[UNITY_outputcontrolpoints(3)]
InternalTessInterp_appdata_full hs_appdata_full(InputPatch<InternalTessInterp_appdata_full, 3> v, uint id : SV_OutputControlPointID)
{
   return v[id];
}

inline appdata_full _ds_appdata_full(UnityTessellationFactors tessFactors, const OutputPatch<InternalTessInterp_appdata_full, 3> vi, float3 bary : SV_DomainLocation)
{
   appdata_full v;
   v.vertex = vi[0].vertex*bary.x + vi[1].vertex*bary.y + vi[2].vertex*bary.z;
   float3 pp[3];
   for (int i = 0; i < 3; ++i)
      pp[i] = v.vertex.xyz - vi[i].normal * (dot(v.vertex.xyz, vi[i].normal) - dot(vi[i].vertex.xyz, vi[i].normal));
   v.vertex.xyz = _TessPhongStrength * (pp[0] * bary.x + pp[1] * bary.y + pp[2] * bary.z) + (1.0f - _TessPhongStrength) * v.vertex.xyz;
   v.tangent = vi[0].tangent*bary.x + vi[1].tangent*bary.y + vi[2].tangent*bary.z;
   v.normal = vi[0].normal*bary.x + vi[1].normal*bary.y + vi[2].normal*bary.z;
   v.vertex.xyz += v.normal.xyz * _TessExtrusionAmount;
   v.texcoord = vi[0].texcoord*bary.x + vi[1].texcoord*bary.y + vi[2].texcoord*bary.z;
   v.texcoord1 = vi[0].texcoord1*bary.x + vi[1].texcoord1*bary.y + vi[2].texcoord1*bary.z;
   v.color = vi[0].color*bary.x + vi[1].color*bary.y + vi[2].color*bary.z;
#if UNITY_VERSION >= 500
   v.texcoord2 = vi[0].texcoord2*bary.x + vi[1].texcoord2*bary.y + vi[2].texcoord2*bary.z;
   v.texcoord3 = vi[0].texcoord3*bary.x + vi[1].texcoord3*bary.y + vi[2].texcoord3*bary.z;
#if defined(SHADER_API_XBOX360)
   v.texcoord4 = vi[0].texcoord4*bary.x + vi[1].texcoord4*bary.y + vi[2].texcoord4*bary.z;
   v.texcoord5 = vi[0].texcoord5*bary.x + vi[1].texcoord5*bary.y + vi[2].texcoord5*bary.z;
#endif // defined(SHADER_API_XBOX360)
#else // UNITY_VERSION >= 500
#if defined(SHADER_API_XBOX360)
   v.texcoord2 = vi[0].texcoord2*bary.x + vi[1].texcoord2*bary.y + vi[2].texcoord2*bary.z;
   v.texcoord3 = vi[0].texcoord3*bary.x + vi[1].texcoord3*bary.y + vi[2].texcoord3*bary.z;
   v.texcoord4 = vi[0].texcoord4*bary.x + vi[1].texcoord4*bary.y + vi[2].texcoord4*bary.z;
   v.texcoord5 = vi[0].texcoord5*bary.x + vi[1].texcoord5*bary.y + vi[2].texcoord5*bary.z;
#endif // defined(SHADER_API_XBOX360)
#endif // UNITY_VERSION >= 500
   return v;
}

#endif // UNITY_CAN_COMPILE_TESSELLATION
#endif // TESSELLATION_ON

#endif // MMDLIT_SURFACE_TESSELLATION_INCLUDED

Código:
// UNITY_SHADER_NO_UPGRADE
#ifndef MMD4MECANIM_MMDLIT_COMPATIBLE_INCLUDED
#define MMD4MECANIM_MMDLIT_COMPATIBLE_INCLUDED

#if UNITY_VERSION >= 540
#define _UNITY_OBJECT_TO_WORLD unity_ObjectToWorld
#else
#define _UNITY_OBJECT_TO_WORLD _Object2World
#endif

#if UNITY_VERSION >= 560
#define _UNITY_SHADOW_ATTENUATION UNITY_SHADOW_ATTENUATION
#else
#define _UNITY_SHADOW_ATTENUATION(a, worldPos) SHADOW_ATTENUATION(a)
#endif

#if UNITY_VERSION >= 550
#define _UNITY_VERTEX_INPUT_INSTANCE_ID UNITY_VERTEX_INPUT_INSTANCE_ID
#else
#define _UNITY_VERTEX_INPUT_INSTANCE_ID UNITY_INSTANCE_ID
#endif

#if UNITY_VERSION >= 540
#define _UnityObjectToClipPos(V_) UnityObjectToClipPos(V_)
#define _UnityObjectToViewPos(V_) UnityObjectToViewPos(V_)
#else
#define _UnityObjectToClipPos(V_) mul(UNITY_MATRIX_MVP, V_)
#define _UnityObjectToViewPos(V_) mul(UNITY_MATRIX_MV, float4((float3)V_, 1.0)).xyz
#endif

#if UNITY_VERSION >= 540
#ifdef UNITY_USE_PREMULTIPLIED_MATRICES
inline float4x4 MMDLit_GetMatrixMV() { return UNITY_MATRIX_MV; }
#else
inline float4x4 MMDLit_GetMatrixMV() { return mul(UNITY_MATRIX_V, _UNITY_OBJECT_TO_WORLD); }
#endif
#else
inline float4x4 MMDLit_GetMatrixMV() { return UNITY_MATRIX_MV; }
#endif

#endif

Código:
// Not for redistribution without the author's express written permission
#ifndef MMDLIT_SURFACEEDGE_LIGHTING_INCLUDED
#define MMDLIT_SURFACEEDGE_LIGHTING_INCLUDED

#include "MMD4Mecanim-MMDLit-Surface-Tessellation.cginc"
#include "MMD4Mecanim-MMDLit-Compatible.cginc"

half _AmbientToDiffuse;
half4 _EdgeColor;
float _EdgeSize;

#define MMDLIT_GLOBALLIGHTING (0.6)
#define MMDLIT_EDGE_ZOFST (0.00001)

inline float MMDLit_GetEdgeSize()
{
   return _EdgeSize;
}

inline float4 MMDLit_GetEdgeVertex(float4 vertex, float3 normal)
{
#if 1
   float edge_size = MMDLit_GetEdgeSize();
#else
   // Adjust edge_size by distance & fovY
   float4 world_pos = mul(MMDLit_GetMatrixMV(), vertex);
   float r_proj_y = UNITY_MATRIX_P[1][1];
   float edge_size = abs(MMDLit_GetEdgeSize() / r_proj_y * world_pos.z) * 2.0;
#endif
   return vertex + float4(normal.xyz * edge_size, 0.0);
}

inline float4 MMDLit_TransformEdgeVertex(float4 vertex)
{
#if 0
   vertex = _UnityObjectToClipPos(vertex);
   vertex.z += MMDLIT_EDGE_ZOFST * vertex.w;
   return vertex;
#else
   return _UnityObjectToClipPos(vertex);
#endif
}

inline half3 MMDLit_GetAlbedo(out half alpha)
{
   alpha = _EdgeColor.a;
   return (half3)_EdgeColor;
}

inline half3 MMDLit_Lighting(half3 albedo, half atten, half3 globalAmbient)
{
   half3 color = (half3)_LightColor0 * MMDLIT_ATTEN(atten);
   color *= MMDLIT_GLOBALLIGHTING;
   #ifdef AMB2DIFF_ON
   color *= saturate(globalAmbient * _AmbientToDiffuse); // Feedback ambient for Unity5.
   #endif
   #ifdef UNITY_PASS_FORWARDADD
   // No Ambient.
   #else
   color += globalAmbient;
   #endif
   color *= albedo;
   return color;
}

#endif // MMDLIT_SURFACEEDGE_LIGHTING_INCLUDED

Código:
#include "MMD4Mecanim-MMDLit-Compatible.cginc"

// Not for redistribution without the author's express written permission
half4 _EdgeColor;
float _EdgeSize;
//float _EdgeZOffset;

inline float MMDLit_GetEdgeSize()
{
   return _EdgeSize * EDGE_SCALE;
}

inline float4 MMDLit_GetEdgeVertex(float4 vertex, float3 normal)
{
#if 0
   float edge_size = MMDLit_GetEdgeSize();
#else
   // Adjust edge_size by distance & fovY
   float r_proj_y = UNITY_MATRIX_P[1][1];
   float edge_size = abs(MMDLit_GetEdgeSize() / r_proj_y);
#endif
   return vertex + float4(normal.xyz * edge_size, 0.0);
}

inline float4 MMDLit_TransformEdgeVertex(float4 vertex)
{
#if 1
   return _UnityObjectToClipPos(vertex);
#else
   vertex = _UnityObjectToClipPos(vertex);
   vertex.z += _EdgeZOffset * vertex.w;
   return vertex;
#endif
}

Código:
// Not for redistribution without the author's express written permission
// UNITY_SHADER_NO_UPGRADE
#ifndef MMDLIT_LIGHTING_INCLUDED
#define MMDLIT_LIGHTING_INCLUDED

#include "MMD4Mecanim-MMDLit-Compatible.cginc"

#if UNITY_VERSION >= 500
#define MMDLIT_ATTEN(ATTEN_)   (ATTEN_)
#define MMDLIT_SV_TARGET      SV_Target
#else
#define MMDLIT_ATTEN(ATTEN_)   (ATTEN_ * 2)
#define MMDLIT_SV_TARGET      COLOR
#endif

#if defined(SPHEREMAP_MUL) || defined(SPHEREMAP_ADD)
#define SPHEREMAP_ON
#endif

// UnityCG.cginc
inline half3 MMDLit_DecodeLightmap(half4 color)
{
#if (defined(SHADER_API_GLES) || defined(SHADER_API_GLES3)) && defined(SHADER_API_MOBILE)
   return (2.0 * (half3)color);
#else
   // potentially faster to do the scalar multiplication
   // in parenthesis for scalar GPUs
   return (8.0 * color.a) * (half3)color;
#endif
}

// Lighting.cginc
inline half3 MMDLit_DirLightmapDiffuse(in half3x3 dirBasis, half4 color, half4 scale, half3 normal, bool surfFuncWritesNormal, out half3 scalePerBasisVector)
{
   half3 lm = MMDLit_DecodeLightmap(color);
   
   // will be compiled out (and so will the texture sample providing the value)
   // if it's not used in the lighting function, like in LightingLambert
   scalePerBasisVector = MMDLit_DecodeLightmap(scale);

   // will be compiled out when surface function does not write into o.Normal
   if (surfFuncWritesNormal)
   {
      half3 normalInRnmBasis = saturate(mul(dirBasis, normal));
      lm *= dot (normalInRnmBasis, scalePerBasisVector);
   }

   return lm;
}

// UnityCG.cginc
inline half MMDLit_Luminance( half3 c )
{
   return dot( c, half3(0.22, 0.707, 0.071) );
}

inline half MMDLit_SpecularRefl( half3 normal, half3 lightDir, half3 viewDir, half s )
{
   //return saturate(pow(saturate(dot(normal, normalize(lightDir + viewDir))), s));
   return pow(saturate(dot(normal, normalize(lightDir + viewDir))), s); // Optimized.
   // (Memo: pow(x,0) as Depends on the particular graphics processor 0 or NaN)
}

// Platform limitation. (Must be unsupported without permission.)
#if defined(SHADER_API_PSSL) || defined(SHADER_API_XBOXONE) || defined(SHADER_API_XBOX360) || defined(SHADER_API_PSP2) || defined(SHADER_API_WIIU)
#define _SHADER_API_CONSOLE
#endif

#ifdef _SHADER_API_CONSOLE
#define MMDLIT_CLIP(A_) clip((A_) - (1.0 / 255.0));
#define MMDLIT_CLIP_FAST(A_)
#else
half ___Eliminate; // Please observe terms of use. (Don't modify this code)
#define MMDLIT_CLIP(A_) clip((A_) * ___Eliminate - (1.0 / 255.0));
#define MMDLIT_CLIP_FAST(A_) MMDLIT_CLIP((A_))
#endif

#endif

Código:
// Not for redistribution without the author's express written permission
#ifndef MMDLIT_SURFACE_LIGHTING_INCLUDED
#define MMDLIT_SURFACE_LIGHTING_INCLUDED
//#include "MMD4Mecanim-MMDLit-Lighting.cginc"

#include "MMD4Mecanim-MMDLit-Surface-Tessellation.cginc"

#ifndef MMD4MECANIM_STANDARD
half4 _Color;
#endif
half4 _Specular;
half4 _Ambient;
half _Shininess;
half _ShadowLum;
half _AmbientToDiffuse;

#ifndef MMD4MECANIM_STANDARD
sampler2D _MainTex;
#endif
sampler2D _ToonTex;

half _AddLightToonCen;
half _AddLightToonMin;

half4 _ToonTone;

half4 _Emissive;

samplerCUBE _SphereCube;

#define MMDLIT_GLOBALLIGHTING      half3(0.6, 0.6, 0.6)
#define MMDLIT_CENTERAMBIENT      half3(0.5, 0.5, 0.5)
#define MMDLIT_CENTERAMBIENT_INV   half3(1.0 / 0.5, 1.0 / 0.5, 1.0 / 0.5)
#define MMDLIT_DIFFUSECLIPPING      half3(0.5, 0.5, 0.5)

// Ambient Feedback Rate from Unity.
inline half3 MMDLit_GetTempAmbientL()
{
   return max(MMDLIT_CENTERAMBIENT - (half3)_Ambient, half3(0,0,0)) * MMDLIT_CENTERAMBIENT_INV;
}

inline half3 MMDLit_GetAmbientRate()
{
   return half3(1.0, 1.0, 1.0) - MMDLit_GetTempAmbientL();
}

inline half3 MMDLit_GetTempAmbient( half3 globalAmbient )
{
   return globalAmbient * MMDLit_GetAmbientRate();
}

inline half3 MMDLit_GetTempDiffuse( half3 globalAmbient )
{
   half3 tempColor = min((half3)_Ambient + (half3)_Color * MMDLIT_GLOBALLIGHTING, half3(1,1,1));
   tempColor = max(tempColor - MMDLit_GetTempAmbient(globalAmbient), half3(0,0,0));
   #ifdef AMB2DIFF_ON // Passed in Forward Add
   tempColor *= min(globalAmbient * _AmbientToDiffuse, half3(1,1,1)); // Feedback ambient for Unity5.
   #endif
   return tempColor;
}

inline half3 MMDLit_GetTempDiffuse_NoAmbient()
{
   half3 tempColor = saturate((half3)_Ambient + (half3)_Color * MMDLIT_GLOBALLIGHTING - MMDLIT_DIFFUSECLIPPING);
   return tempColor;
}

inline void MMDLit_GetBaseColor(
   half3 albedo,
   half3 tempDiffuse,
   half3 uvw_Sphere,
   out half3 baseC,
   out half3 baseD)
{
   #ifdef SPHEREMAP_MUL
   half3 sph = (half3)texCUBE(_SphereCube, uvw_Sphere);
   baseC = albedo * sph;
   baseD = baseC * tempDiffuse; // for Diffuse only.
   #elif SPHEREMAP_ADD
   half3 sph = (half3)texCUBE(_SphereCube, uvw_Sphere);
   baseC = albedo + sph;
   baseD = albedo * tempDiffuse + sph; // for Diffuse only.
   #else
   baseC = albedo;
   baseD = albedo * tempDiffuse;
   #endif
}

inline half4 MMDLit_GetAlbedo(float2 uv_MainTex)
{
   return (half4)tex2D(_MainTex, uv_MainTex);
}

inline half MMDLit_GetToolRefl(half NdotL)
{
   return NdotL * _ToonTone.y + _ToonTone.z; // Necesally saturate.
}

inline half MMDLit_GetShadowAttenToToon(half shadowAtten)
{
   return ((shadowAtten - 0.5) * _ToonTone.x) + _ToonTone.z; // Necesally saturate.
}

inline half MMDLit_GetToonShadow(half toonRefl)
{
   half toonShadow = toonRefl * 2.0;
   return (half)saturate(toonShadow * toonShadow - 1.0);
}

inline half MMDLit_GetForwardAddStr(half toonRefl)
{
   half toonShadow = (toonRefl - _AddLightToonCen) * 2.0;
   return (half)clamp(toonShadow * toonShadow - 1.0, _AddLightToonMin, 1.0);
}

// for ForwardBase
inline half3 MMDLit_GetRamp(half NdotL, half shadowAtten)
{
   half refl = saturate(min(MMDLit_GetToolRefl(NdotL), MMDLit_GetShadowAttenToToon(shadowAtten)));

   half toonRefl = refl;

   #ifdef SELFSHADOW_ON
   refl = 0;
   #endif
   
   half3 ramp = (half3)tex2D(_ToonTex, half2(refl, refl));

   #ifdef SELFSHADOW_ON
   half toonShadow = MMDLit_GetToonShadow(toonRefl);
   ramp = lerp(ramp, half3(1.0, 1.0, 1.0), toonShadow);
   #endif

   ramp = saturate(1.0 - (1.0 - ramp) * _ShadowLum);
   return ramp;
}

// for ForwardAdd
inline half3 MMDLit_GetRamp_Add(half toonRefl, half toonShadow)
{
   half refl = saturate(toonRefl);
   
   #ifdef SELFSHADOW_ON
   refl = 0;
   #endif
   
   half3 ramp = (half3)tex2D(_ToonTex, half2(refl, refl));

   #ifdef SELFSHADOW_ON
   half3 rampSS = (1.0 - toonShadow) * ramp + toonShadow;
   ramp = rampSS;
   #endif
   
   ramp = saturate(1.0 - (1.0 - ramp) * _ShadowLum);
   return ramp;
}

// for FORWARD_BASE
inline half3 MMDLit_Lighting(
   half3 albedo,
   half3 uvw_Sphere,
   half NdotL,
   half3 normal,
   half3 lightDir,
   half3 viewDir,
   half atten,
   half shadowAtten,
   out half3 baseC,
   half3 globalAmbient)
{
   half3 ramp = MMDLit_GetRamp(NdotL, shadowAtten);
   half3 lightColor = (half3)_LightColor0 * MMDLIT_ATTEN(atten);

   half3 baseD;
   MMDLit_GetBaseColor(albedo, MMDLit_GetTempDiffuse(globalAmbient), uvw_Sphere, baseC, baseD);
   
   half3 c = baseD * lightColor * ramp;
   
   #ifdef SPECULAR_ON
   half refl = MMDLit_SpecularRefl(normal, lightDir, viewDir, _Shininess);
   c += (half3)_Specular * lightColor * refl;
   #endif

   #ifdef EMISSIVE_ON
   // AutoLuminous
   c += baseC * (half3)_Emissive;
   #endif
   return c;
}

// for FORWARD_ADD
inline half3 MMDLit_Lighting_Add(
   half3 albedo,
   half NdotL,
   half toonRefl,
   half toonShadow,
   half3 normal,
   half3 lightDir,
   half3 viewDir,
   half atten)
{
   half3 ramp = MMDLit_GetRamp_Add(toonRefl, toonShadow);
   half3 lightColor = (half3)_LightColor0 * MMDLIT_ATTEN(atten);

   half3 baseC;
   half3 baseD;
   MMDLit_GetBaseColor(albedo, MMDLit_GetTempDiffuse_NoAmbient(), half3(0.0, 0.0, 0.0), baseC, baseD);

   half3 c = baseD * lightColor * ramp;

   #ifdef SPECULAR_ON
   half refl = MMDLit_SpecularRefl(normal, lightDir, viewDir, _Shininess);
   c += (half3)_Specular * lightColor * refl;
   #endif
   
   return c;
}

inline half MMDLit_MulAtten(half atten, half shadowAtten)
{
   return atten * shadowAtten;
}

#endif // MMDLIT_SURFACE_LIGHTING_INCLUDED
AGAMENOM
AGAMENOM
Avançado
Avançado

Masculino PONTOS : 1783
REPUTAÇÃO : 15
Idade : 21
Respeito as regras : Shader não funciona no Unity URP WvDYdlf

https://paradoxicaltimegam.wixsite.com/paradoxicaltime

Ir para o topo Ir para baixo

Ir para o topo

- Tópicos semelhantes

 
Permissões neste sub-fórum
Não podes responder a tópicos