2022-01-17 11:26:35 +03:00

71 lines
2.3 KiB
HLSL

//////////////////////////////////////////////////////
// MK Toon Meta Common //
// //
// Created by Michael Kremmel //
// www.michaelkremmel.de //
// Copyright © 2021 All rights reserved. //
//////////////////////////////////////////////////////
#ifndef MK_TOON_META_COMMON
#define MK_TOON_META_COMMON
#if defined(MK_URP)
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/MetaInput.hlsl"
#elif defined(MK_LWRP)
#include "Packages/com.unity.render-pipelines.lightweight/ShaderLibrary/MetaInput.hlsl"
#else
#include "UnityMetaPass.cginc"
#endif
#include "../Core.hlsl"
/////////////////////////////////////////////////////////////////////////////////////////////
// Meta Common
/////////////////////////////////////////////////////////////////////////////////////////////
struct MKMetaData
{
half3 albedo;
half3 emission;
half3 specular;
#ifdef EDITOR_VISUALIZATION
float2 vizUV;
float4 lightCoords;
#endif
};
inline float4 ComputeMetaPosition(float4 vertexPosObject, float2 staticLightmapUV, float2 dynamicLightmapUV, float4 staticLightmapST, float4 dynLightmapST)
{
#if defined(MK_URP)
return MetaVertexPosition(vertexPosObject, staticLightmapUV, dynamicLightmapUV, staticLightmapST, dynLightmapST);
#elif defined(MK_LWRP)
return MetaVertexPosition(vertexPosObject, staticLightmapUV, dynamicLightmapUV, staticLightmapST);
#else
return UnityMetaVertexPosition(vertexPosObject, staticLightmapUV, dynamicLightmapUV, staticLightmapST, dynLightmapST);
#endif
}
inline half4 ComputeMetaOutput(MKMetaData mkMetaData)
{
#if defined(MK_URP) || defined(MK_LWRP)
MetaInput metaInput;
metaInput.Albedo = mkMetaData.albedo;
metaInput.Emission = mkMetaData.emission;
metaInput.SpecularColor = mkMetaData.specular;
return MetaFragment(metaInput);
#else
UnityMetaInput untiyMetaInput;
untiyMetaInput.Albedo = mkMetaData.albedo;
untiyMetaInput.Emission = mkMetaData.emission;
untiyMetaInput.SpecularColor = mkMetaData.specular;
#ifdef EDITOR_VISUALIZATION
untiyMetaInput.VizUV = mkMetaData.vizUV;
untiyMetaInput.LightCoord = mkMetaData.lightCoords;
#endif
return UnityMetaFragment(untiyMetaInput);
#endif
}
#endif