浏览代码

Added support to bumpmap scale.

/Add-support-for-light-specular-color-tint
Felipe Lira 7 年前
当前提交
c06f7217
共有 3 个文件被更改,包括 34 次插入2 次删除
  1. 7
      ScriptableRenderPipeline/LightweightPipeline/Editor/ShaderGUI/LightweightStandardGUI.cs
  2. 26
      ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightCore.cginc
  3. 3
      ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightPassLit.cginc

7
ScriptableRenderPipeline/LightweightPipeline/Editor/ShaderGUI/LightweightStandardGUI.cs


public static GUIContent detailMaskText = new GUIContent("Detail Mask", "Mask for Secondary Maps (A)");
public static GUIContent detailAlbedoText = new GUIContent("Detail Albedo x2", "Albedo (RGB) multiplied by 2");
public static GUIContent detailNormalMapText = new GUIContent("Normal Map", "Normal Map");
public static GUIContent bumpScaleNotSupported = new GUIContent("Bump scale is not supported on mobile platforms");
public static GUIContent fixNow = new GUIContent("Fix now");
public static string primaryMapsText = "Main Maps";
public static string secondaryMapsText = "Secondary Maps";

void DoNormalArea()
{
m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, bumpMap);
m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, bumpMap, bumpMap.textureValue != null ? bumpScale : null);
if (bumpScale.floatValue != 1 && UnityEditorInternal.InternalEditorUtility.IsMobilePlatform(EditorUserBuildSettings.activeBuildTarget))
if (m_MaterialEditor.HelpBoxWithButton(Styles.bumpScaleNotSupported, Styles.fixNow))
bumpScale.floatValue = 1;
}
void DoAlbedoArea(Material material)

26
ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightCore.cginc


return inVec * rsqrt(dp3);
}
half3 UnpackNormalScale(half4 packednormal, half bumpScale)
{
#if defined(UNITY_NO_DXT5nm)
half3 normal = packednormal.xyz * 2 - 1;
#if (SHADER_TARGET >= 30)
// SM2.0: instruction count limitation
// SM2.0: normal scaler is not supported
normal.xy *= bumpScale;
#endif
return normal;
#else
// This do the trick
packednormal.x *= packednormal.w;
half3 normal;
normal.xy = (packednormal.xy * 2 - 1);
#if (SHADER_TARGET >= 30)
// SM2.0: instruction count limitation
// SM2.0: normal scaler is not supported
normal.xy *= bumpScale;
#endif
normal.z = sqrt(1.0 - saturate(dot(normal.xy, normal.xy)));
return normal;
#endif
}
half3 EvaluateSHPerVertex(half3 normalWS)
{
#if defined(EVALUATE_SH_VERTEX)

3
ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightPassLit.cginc


sampler2D _MetallicGlossMap;
half4 _SpecColor;
sampler2D _SpecGlossMap;
half _BumpScale;
sampler2D _BumpMap;
half _OcclusionStrength;
sampler2D _OcclusionMap;

half3 Normal(float2 uv)
{
#if _NORMALMAP
return UnpackNormal(tex2D(_BumpMap, uv));
return UnpackNormalScale(tex2D(_BumpMap, uv), _BumpScale);
#else
return half3(0.0h, 0.0h, 1.0h);
#endif

正在加载...
取消
保存