浏览代码

Added SHADER_HINT_NICE_QUALITY. Viewdirection is normalized in vertex or frag depending on the quality hint.

/2018.1
Felipe Lira 7 年前
当前提交
c06d5c5d
共有 2 个文件被更改,包括 19 次插入5 次删除
  1. 8
      ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/Core.hlsl
  2. 16
      ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/LightweightPassLit.hlsl

8
ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/Core.hlsl


#include "CoreRP/ShaderLibrary/Packing.hlsl"
#include "Input.hlsl"
#if !defined(SHADER_HINT_NICE_QUALITY)
#ifdef SHADER_API_MOBILE
#define SHADER_HINT_NICE_QUALITY 0
#else
#define SHADER_HINT_NICE_QUALITY 1
#endif
#endif
///////////////////////////////////////////////////////////////////////////////
#ifdef _NORMALMAP
#define OUTPUT_NORMAL(IN, OUT) OutputTangentToWorld(IN.tangent, IN.normal, OUT.tangent, OUT.binormal, OUT.normal)

16
ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/LightweightPassLit.hlsl


inputData.normalWS = normalize(IN.normal);
#endif
#ifdef SHADER_API_MOBILE
// viewDirection should be normalized here, but we avoid doing it as it's close enough and we save some ALU.
inputData.viewDirectionWS = IN.viewDir;
#if SHADER_HINT_NICE_QUALITY
inputData.viewDirectionWS = SafeNormalize(IN.viewDir);
inputData.viewDirectionWS = normalize(IN.viewDir);
// View direction is already normalize in vertex. Small acceptable error to save ALU.
inputData.viewDirectionWS = IN.viewDir;
#endif
inputData.shadowCoord = IN.shadowCoord;

o.posWS = TransformObjectToWorld(v.vertex.xyz);
o.clipPos = TransformWorldToHClip(o.posWS);
o.viewDir = SafeNormalize(GetCameraPositionWS() - o.posWS);
o.viewDir = GetCameraPositionWS() - o.posWS;
#if !SHADER_HINT_NICE_QUALITY
// Normalize in vertex and avoid renormalizing it in frag to save ALU.
o.viewDir = SafeNormalize(o.viewDir);
#endif
// initializes o.normal and if _NORMALMAP also o.tangent and o.binormal
OUTPUT_NORMAL(v, o);

正在加载...
取消
保存