Skip to content

Fix keywords with fbx importer #3350

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- White flashes on camera cuts on volumetric fog.
- Fixed light layer issue when performing editing on multiple lights.
- Fixed an issue where selection in a debug panel would reset when cycling through enum items.
- Fixed material keywords with fbx importer.

### Changed
- Removed the material pass probe volumes evaluation mode.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@ public void OnPreprocessMaterialDescription(MaterialDescription description, Mat

material.shader = shader;

material.SetShaderPassEnabled("DistortionVectors", false);
material.SetShaderPassEnabled("TransparentDepthPrepass", false);
material.SetShaderPassEnabled("TransparentDepthPostpass", false);
material.SetShaderPassEnabled("TransparentBackface", false);
material.SetShaderPassEnabled("MOTIONVECTORS", false);

Vector4 vectorProperty;
float floatProperty;
TexturePropertyDescription textureProperty;
Expand Down Expand Up @@ -78,17 +72,10 @@ public void OnPreprocessMaterialDescription(MaterialDescription description, Mat

if (isTransparent)
{
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
material.SetInt("_ZWrite", 0);
material.SetFloat("_BlendMode", (float)BlendMode.Alpha);
material.SetFloat("_EnableBlendModePreserveSpecularLighting", 1.0f);
material.EnableKeyword("_ALPHAPREMULTIPLY_ON");
material.EnableKeyword("_SURFACE_TYPE_TRANSPARENT");
material.EnableKeyword("_ENABLE_FOG_ON_TRANSPARENT");
material.EnableKeyword("_ALPHATEST_ON");
material.renderQueue = (int)UnityEngine.Rendering.RenderQueue.Transparent;
material.SetFloat("_SurfaceType", 1.0f);
material.SetFloat("_SurfaceType", (float)SurfaceType.Transparent);
material.SetFloat("_Cutoff", .0f);
material.SetFloat("_AlphaCutoffEnable", 1.0f);
material.SetFloat("_AlphaCutoff", .0f);
Expand All @@ -97,12 +84,12 @@ public void OnPreprocessMaterialDescription(MaterialDescription description, Mat
}
else
{
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
material.SetInt("_ZWrite", 1);
material.renderQueue = -1;
}

if (description.TryGetProperty("ReflectionFactor", out floatProperty))
material.SetFloat("_Metallic", floatProperty);

if (description.TryGetProperty("DiffuseColor", out textureProperty) && textureProperty.texture != null)
{
Color diffuseColor = new Color(1.0f, 1.0f, 1.0f, 1.0f);
Expand All @@ -125,23 +112,17 @@ public void OnPreprocessMaterialDescription(MaterialDescription description, Mat
if (description.TryGetProperty("Bump", out textureProperty) && textureProperty.texture != null)
{
SetMaterialTextureProperty("_BumpMap", material, textureProperty);
material.EnableKeyword("_NORMALMAP_TANGENT_SPACE");

if (description.TryGetProperty("BumpFactor", out floatProperty))
material.SetFloat("_BumpScale", floatProperty);
}
else if (description.TryGetProperty("NormalMap", out textureProperty) && textureProperty.texture != null)
{
SetMaterialTextureProperty("_BumpMap", material, textureProperty);
material.EnableKeyword("_NORMALMAP_TANGENT_SPACE");

if (description.TryGetProperty("BumpFactor", out floatProperty))
material.SetFloat("_BumpScale", floatProperty);
}
else
{
material.DisableKeyword("_NORMALMAP");
}

if (description.TryGetProperty("EmissiveColor", out textureProperty))
{
Expand Down Expand Up @@ -183,6 +164,8 @@ public void OnPreprocessMaterialDescription(MaterialDescription description, Mat

RemapColorCurves(description, clips, "EmissiveColor", "_EmissionColor");
RemapColorCurves(description, clips, "EmissiveColor", "_EmissiveColor");

HDShaderUtils.ResetMaterialKeywords(material);
}

static void RemapTransparencyCurves(MaterialDescription description, AnimationClip[] clips)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ static internal void SaveAssetsToDisk()
s_NeedsSavingAssets = false;
}

void OnPostprocessMaterial(Material material)
{
if (!HDShaderUtils.IsHDRPShader(material.shader, upgradable: true))
return;

HDShaderUtils.ResetMaterialKeywords(material);
}

static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
{
foreach (var asset in importedAssets)
Expand Down