浏览代码

Added support to reflection probes.

/Branch_batcher
Felipe Lira 8 年前
当前提交
ddbc0256
共有 4 个文件被更改,包括 15 次插入20 次删除
  1. 5
      Assets/LowEndMobilePipeline/Editor/LowendMobilePipelineMaterialEditor.cs
  2. 18
      Assets/LowEndMobilePipeline/Editor/LowendUpgraders.cs
  3. 1
      Assets/LowEndMobilePipeline/LowEndMobilePipeline.cs
  4. 11
      Assets/LowEndMobilePipeline/Shaders/LowEndMobilePipeline.shader

5
Assets/LowEndMobilePipeline/Editor/LowendMobilePipelineMaterialEditor.cs


private MaterialProperty emissionMapProp = null;
private MaterialProperty emissionColorProp = null;
private MaterialProperty reflectionMapProp = null;
private MaterialProperty reflectionColorProp = null;
private MaterialEditor m_MaterialEditor = null;

emissionMapProp = FindProperty("_EmissionMap", properties);
emissionColorProp = FindProperty("_EmissionColor", properties);
reflectionMapProp = FindProperty("_Cube", properties);
reflectionColorProp = FindProperty("_ReflectColor", properties);
reflectionSourceProp = FindProperty("_ReflectionSource", properties);
}

EditorGUILayout.Space();
ReflectionSource reflectionSource = (ReflectionSource)reflectionSourceProp.floatValue;
if (reflectionSource == ReflectionSource.Cubemap)
m_MaterialEditor.TexturePropertySingleLine(Styles.reflectionMapLabel, reflectionMapProp,
reflectionColorProp);
m_MaterialEditor.TexturePropertySingleLine(Styles.reflectionMapLabel, reflectionMapProp);
}
private void ConvertFromLegacy(Material material, string oldShaderName)

18
Assets/LowEndMobilePipeline/Editor/LowendUpgraders.cs


private static void UpdateMaterialReflectionSource(Material material)
{
SetKeyword(material, "_REFLECTION_CUBEMAP", false);
SetKeyword(material, "_REFLECTION_PROBE", false);
if (reflectionSource == ReflectionSource.NoReflection)
{
SetKeyword(material, "_CUBEMAP_REFLECTION", false);
}
else if (reflectionSource == ReflectionSource.Cubemap && material.GetTexture("_Cube"))
if (reflectionSource == ReflectionSource.Cubemap && material.GetTexture("_Cube"))
SetKeyword(material, "_CUBEMAP_REFLECTION", true);
SetKeyword(material, "_REFLECTION_CUBEMAP", true);
Debug.LogWarning("Reflection probe not implemented yet");
SetKeyword(material, "_CUBEMAP_REFLECTION", false);
}
else
{
SetKeyword(material, "_CUBEMAP_REFLECTION", false);
SetKeyword(material, "_REFLECTION_PROBE", true);
}
}

1
Assets/LowEndMobilePipeline/LowEndMobilePipeline.cs


settings.sorting.flags = SortFlags.CommonOpaque;
settings.inputFilter.SetQueuesOpaque();
settings.rendererConfiguration = RendererConfiguration.PerObjectReflectionProbes;
if (m_Asset.EnableLightmap)
settings.rendererConfiguration |= RendererConfiguration.PerObjectLightmaps;

11
Assets/LowEndMobilePipeline/Shaders/LowEndMobilePipeline.shader


[Enum(Specular Alpha,0,Albedo Alpha,1)] _SmoothnessTextureChannel("Smoothness texture channel", Float) = 0
_Cube ("Reflection Cubemap", CUBE) = "" {}
_ReflectColor("Reflection Color", Color) = (1, 1, 1, 1)
_ReflectionSource("Reflection Source", Float) = 0
[HideInInspector] _SpecSource("Specular Color Source", Float) = 0.0

#pragma shader_feature _ _SPECGLOSSMAP _SPECGLOSSMAP_BASE_ALPHA _SPECULAR_COLOR
#pragma shader_feature _NORMALMAP
#pragma shader_feature _EMISSION_MAP
#pragma shader_feature _CUBEMAP_REFLECTION
#pragma shader_feature _ _REFLECTION_CUBEMAP _REFLECTION_PROBE
#pragma multi_compile _ LIGHTMAP_ON
#pragma multi_compile _ _LIGHT_PROBES_ON

color += i.fogCoord.yzw * diffuse;
#endif
#if _CUBEMAP_REFLECTION
#if _REFLECTION_CUBEMAP
color += texCUBE(_Cube, reflectVec).rgb * _ReflectColor.rgb * specularGloss.rgb;
color += texCUBE(_Cube, reflectVec).rgb * specularGloss.rgb;
#elif defined(_REFLECTION_PROBE)
half3 reflectVec = reflect(-i.viewDir.xyz, normal);
half4 reflectionProbe = UNITY_SAMPLE_TEXCUBE(unity_SpecCube0, reflectVec);
color += reflectionProbe.rgb * (reflectionProbe.a * unity_SpecCube0_HDR.x) * specularGloss.rgb;
#endif
UNITY_APPLY_FOG(i.fogCoord, color);

正在加载...
取消
保存