浏览代码

Added helper sampler function and conversion between colorspaces.

/RenderPassXR_Sandbox
Felipe Lira 8 年前
当前提交
fb82cb32
共有 2 个文件被更改,包括 29 次插入6 次删除
  1. 2
      Assets/ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightPipeline.shader
  2. 33
      Assets/ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightPipelineCore.cginc

2
Assets/ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightPipeline.shader


half4 frag(v2f i) : SV_Target
{
half4 diffuseAlpha = tex2D(_MainTex, i.uv01.xy);
half4 diffuseAlpha = Tex2DLinearRGBA(_MainTex, i.uv01.xy);
half3 diffuse = diffuseAlpha.rgb * _Color.rgb;
half alpha = diffuseAlpha.a * _Color.a;

33
Assets/ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightPipelineCore.cginc


#define _SHADOW_CASCADES
#endif
#if (defined(UNITY_COLORSPACE_GAMMA) || SHADER_TARGET < 30) && defined(LIGHTWEIGHT_FORCE_LINEAR)
// Ideally we want an approximation of gamma curve 2.0 to save ALU on GPU but as off now it won't match the GammaToLinear conversion of props in engine
//#define LIGHTWEIGHT_GAMMA_TO_LINEAR(gammaColor) gammaColor * gammaColor
//#define LIGHTWEIGHT_LINEAR_TO_GAMMA(linColor) sqrt(color)
#define LIGHTWEIGHT_GAMMA_TO_LINEAR(sRGB) sRGB * (sRGB * (sRGB * 0.305306011h + 0.682171111h) + 0.012522878h)
#define LIGHTWEIGHT_LINEAR_TO_GAMMA(linRGB) max(1.055h * pow(max(linRGB, 0.h), 0.416666667h) - 0.055h, 0.h)
#else
#define LIGHTWEIGHT_GAMMA_TO_LINEAR(color) color
#define LIGHTWEIGHT_LINEAR_TO_GAMMA(color) color
#endif
struct LightInput
{
half4 pos;

#include "LightweightPipelineShadows.cginc"
#endif
inline half3 Tex2DLinearRGB(sampler2D s, half2 uv)
{
return LIGHTWEIGHT_GAMMA_TO_LINEAR(tex2D(s, uv).rgb);
}
inline half4 Tex2DLinearRGBA(sampler2D s, half2 uv)
{
half4 color = tex2D(s, uv);
return half4(LIGHTWEIGHT_GAMMA_TO_LINEAR(color.rgb), color.a);
}
inline void NormalMap(v2f i, out half3 normal)
{
#if _NORMALMAP

inline void SpecularGloss(half2 uv, half alpha, out half4 specularGloss)
{
#ifdef _SPECGLOSSMAP
specularGloss = tex2D(_SpecGlossMap, uv) * _SpecColor;
specularGloss = Tex2DLinearRGBA(_SpecGlossMap, uv) * _SpecColor;
specularGloss = tex2D(_SpecGlossMap, uv) * _SpecColor;
specularGloss = Tex2DLinearRGBA(_SpecGlossMap, uv) * _SpecColor;
specularGloss.a = alpha;
#else
specularGloss = _SpecColor;

inline void Emission(half2 uv, inout half3 color)
{
#ifdef _EMISSION
color += tex2D(_EmissionMap, uv) * _EmissionColor;
color += Tex2DLinearRGB(_EmissionMap, uv) * _EmissionColor;
#else
color += _EmissionColor;
#endif

{
#ifdef _ALPHABLEND_ON
return half4(color, alpha);
return LIGHTWEIGHT_LINEAR_TO_GAMMA(half4(color, alpha));
return half4(color, 1);
return half4(LIGHTWEIGHT_LINEAR_TO_GAMMA(color), 1);
#endif
}

正在加载...
取消
保存