From 15740faf9fe9fe4be08965098bbf2947e096aeeb Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 14 Aug 2019 22:50:43 +0800 Subject: +Unity Runtime code --- .../Camera/RenderLoops/BuiltinShaderParamUtility.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Runtime/Camera/RenderLoops/BuiltinShaderParamUtility.cpp (limited to 'Runtime/Camera/RenderLoops/BuiltinShaderParamUtility.cpp') diff --git a/Runtime/Camera/RenderLoops/BuiltinShaderParamUtility.cpp b/Runtime/Camera/RenderLoops/BuiltinShaderParamUtility.cpp new file mode 100644 index 0000000..99e5d22 --- /dev/null +++ b/Runtime/Camera/RenderLoops/BuiltinShaderParamUtility.cpp @@ -0,0 +1,19 @@ +#include "UnityPrefix.h" +#include "BuiltinShaderParamUtility.h" +#include "Runtime/GfxDevice/GfxDevice.h" +#include "Runtime/Shaders/ShaderKeywords.h" + +static ShaderKeyword gSupportedLODFadeKeyword = keywords::Create("ENABLE_LOD_FADE"); + +void SetObjectScale (GfxDevice& device, float lodFade, float invScale) +{ + device.SetInverseScale(invScale); + + /////@TODO: Figure out why inverse scale is implemented in gfxdevice, and decide if we should do the same for lodFade? + device.GetBuiltinParamValues().SetInstanceVectorParam(kShaderInstanceVecScale, Vector4f(0,0,lodFade, invScale)); + + if (lodFade == LOD_FADE_DISABLED) + g_ShaderKeywords.Disable(gSupportedLODFadeKeyword); + else + g_ShaderKeywords.Enable(gSupportedLODFadeKeyword); +} -- cgit v1.1-26-g67d0