mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-08-24 19:45:37 -05:00
Separate compile-time define
This commit is contained in:
@@ -1,42 +1,6 @@
|
||||
#ifndef VRMC_MATERIALS_MTOON_DEFINE_INCLUDED
|
||||
#define VRMC_MATERIALS_MTOON_DEFINE_INCLUDED
|
||||
|
||||
// define
|
||||
static const float PI_2 = 6.28318530718;
|
||||
static const float EPS_COL = 0.00001;
|
||||
|
||||
inline half3 mtoon_linearstep(const half3 start, const half3 end, const half t)
|
||||
{
|
||||
return min(max((t - start) / (end - start), 0.0), 1.0);
|
||||
}
|
||||
|
||||
inline bool MToon_IsPerspective()
|
||||
{
|
||||
return unity_OrthoParams.w != 1.0;
|
||||
}
|
||||
|
||||
inline float3 MToon_GetWorldSpaceNormalizedViewDir(const float3 positionWS)
|
||||
{
|
||||
if (MToon_IsPerspective())
|
||||
{
|
||||
return normalize(_WorldSpaceCameraPos.xyz - positionWS);
|
||||
}
|
||||
else
|
||||
{
|
||||
return normalize(UNITY_MATRIX_V[2].xyz);
|
||||
}
|
||||
}
|
||||
|
||||
inline half3x3 MToon_GetTangentToWorld(const half3 normalWS, const half4 tangentWS)
|
||||
{
|
||||
const half3 normalizedNormalWS = normalize(normalWS);
|
||||
const half3 normalizedTangentWS = normalize(tangentWS.xyz);
|
||||
|
||||
const half3 normalizedBitangentWS = normalize(tangentWS.w * cross(normalizedNormalWS, normalizedTangentWS));
|
||||
|
||||
return half3x3(normalizedTangentWS, normalizedBitangentWS, normalizedNormalWS);
|
||||
}
|
||||
|
||||
// Compile-time constant
|
||||
inline bool MToon_IsForwardBasePass()
|
||||
{
|
||||
|
||||
@@ -2,9 +2,8 @@
|
||||
#define VRMC_MATERIALS_MTOON_FORWARD_FRAGMENT_INCLUDED
|
||||
|
||||
#include <UnityCG.cginc>
|
||||
#include <AutoLight.cginc>
|
||||
|
||||
#include "./vrmc_materials_mtoon_define.hlsl"
|
||||
#include "./vrmc_materials_mtoon_utility.hlsl"
|
||||
#include "./vrmc_materials_mtoon_input.hlsl"
|
||||
#include "./vrmc_materials_mtoon_attribute.hlsl"
|
||||
#include "./vrmc_materials_mtoon_lighting.hlsl"
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
|
||||
#include <UnityCG.cginc>
|
||||
#include <AutoLight.cginc>
|
||||
|
||||
#include "./vrmc_materials_mtoon_define.hlsl"
|
||||
#include "./vrmc_materials_mtoon_utility.hlsl"
|
||||
#include "./vrmc_materials_mtoon_input.hlsl"
|
||||
#include "./vrmc_materials_mtoon_attribute.hlsl"
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#ifndef VRMC_MATERIALS_MTOON_LIGHTING_INCLUDED
|
||||
#define VRMC_MATERIALS_MTOON_LIGHTING_INCLUDED
|
||||
|
||||
#include <UnityShaderVariables.cginc>
|
||||
#include "./vrmc_materials_mtoon_define.hlsl"
|
||||
#include "./vrmc_materials_mtoon_utility.hlsl"
|
||||
#include "./vrmc_materials_mtoon_input.hlsl"
|
||||
#include "./vrmc_materials_mtoon_unity_lighting.hlsl"
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <UnityCG.cginc>
|
||||
#include <AutoLight.cginc>
|
||||
#include <Lighting.cginc>
|
||||
#include "./vrmc_materials_mtoon_utility.hlsl"
|
||||
#include "./vrmc_materials_mtoon_input.hlsl"
|
||||
#include "./vrmc_materials_mtoon_attribute.hlsl"
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
#ifndef VRMC_MATERIALS_MTOON_UTILITY_INCLUDED
|
||||
#define VRMC_MATERIALS_MTOON_UTILITY_INCLUDED
|
||||
|
||||
#include <UnityCG.cginc>
|
||||
|
||||
// define
|
||||
static const float PI_2 = 6.28318530718;
|
||||
static const float EPS_COL = 0.00001;
|
||||
|
||||
inline half3 mtoon_linearstep(const half3 start, const half3 end, const half t)
|
||||
{
|
||||
return min(max((t - start) / (end - start), 0.0), 1.0);
|
||||
}
|
||||
|
||||
inline bool MToon_IsPerspective()
|
||||
{
|
||||
return unity_OrthoParams.w != 1.0;
|
||||
}
|
||||
|
||||
inline float3 MToon_GetWorldSpaceNormalizedViewDir(const float3 positionWS)
|
||||
{
|
||||
if (MToon_IsPerspective())
|
||||
{
|
||||
return normalize(_WorldSpaceCameraPos.xyz - positionWS);
|
||||
}
|
||||
else
|
||||
{
|
||||
return normalize(UNITY_MATRIX_V[2].xyz);
|
||||
}
|
||||
}
|
||||
|
||||
inline half3x3 MToon_GetTangentToWorld(const half3 normalWS, const half4 tangentWS)
|
||||
{
|
||||
const half3 normalizedNormalWS = normalize(normalWS);
|
||||
const half3 normalizedTangentWS = normalize(tangentWS.xyz);
|
||||
|
||||
const half3 normalizedBitangentWS = normalize(tangentWS.w * cross(normalizedNormalWS, normalizedTangentWS));
|
||||
|
||||
return half3x3(normalizedTangentWS, normalizedBitangentWS, normalizedNormalWS);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 79a73f8bac4e45498341e9b6c1ea841e
|
||||
timeCreated: 1622632833
|
||||
Reference in New Issue
Block a user