static Material SetupMaterial(MicroSplatKeywords kwds, Material mat, MicroSplatBaseFeatures.DebugOutput debugOutput, bool useDebugTopo)
   {
      MicroSplatShaderGUI.MicroSplatCompiler comp = new MicroSplatShaderGUI.MicroSplatCompiler();

      List<string> keywords = new List<string>(kwds.keywords);

      RemoveKeyword(keywords, "_SNOW");
      RemoveKeyword(keywords, "_TESSDISTANCE");
      RemoveKeyword(keywords, "_WINDPARTICULATE");
      RemoveKeyword(keywords, "_SNOWPARTICULATE");
      RemoveKeyword(keywords, "_GLITTER");
      RemoveKeyword(keywords, "_SNOWGLITTER");

      keywords.Add(FeatureFromOutput(debugOutput).ToString());
      if (useDebugTopo)
      {
         keywords.Add("_DEBUG_USE_TOPOLOGY");
      }

      string shader = comp.Compile(keywords.ToArray(), "RenderBake_" + debugOutput.ToString());
      Shader s = ShaderUtil.CreateShaderAsset(shader);
      Material renderMat = new Material(mat);
      renderMat.shader = s;
      return renderMat;
   }
 static MicroSplatBaseFeatures.DefineFeature FeatureFromOutput(MicroSplatBaseFeatures.DebugOutput p)
 {
     if (p == MicroSplatBaseFeatures.DebugOutput.Albedo)
     {
         return(MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_ALBEDO);
     }
     else if (p == MicroSplatBaseFeatures.DebugOutput.AO)
     {
         return(MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_AO);
     }
     else if (p == MicroSplatBaseFeatures.DebugOutput.Emission)
     {
         return(MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_EMISSION);
     }
     else if (p == MicroSplatBaseFeatures.DebugOutput.Height)
     {
         return(MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_HEIGHT);
     }
     else if (p == MicroSplatBaseFeatures.DebugOutput.Metallic)
     {
         return(MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_METAL);
     }
     else if (p == MicroSplatBaseFeatures.DebugOutput.Normal)
     {
         return(MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_NORMAL);
     }
     else if (p == MicroSplatBaseFeatures.DebugOutput.Smoothness)
     {
         return(MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_SMOOTHNESS);
     }
     return(MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_ALBEDO);
 }
Example #3
0
    static Material SetupMaterial(MicroSplatKeywords kwds, Material mat, MicroSplatBaseFeatures.DebugOutput debugOutput, bool useDebugTopo)
    {
        MicroSplatShaderGUI.MicroSplatCompiler comp = new MicroSplatShaderGUI.MicroSplatCompiler();

        List <string> keywords = new List <string>(kwds.keywords);

        RemoveKeyword(keywords, "_SNOW");
        RemoveKeyword(keywords, "_TESSDISTANCE");
        RemoveKeyword(keywords, "_WINDPARTICULATE");
        RemoveKeyword(keywords, "_SNOWPARTICULATE");
        RemoveKeyword(keywords, "_GLITTER");
        RemoveKeyword(keywords, "_SNOWGLITTER");
        RemoveKeyword(keywords, "_SPECULARFROMMETALLIC");
        RemoveKeyword(keywords, "_USESPECULARWORKFLOW");
        RemoveKeyword(keywords, "_BDRFLAMBERT");
        RemoveKeyword(keywords, "_BDRF1");
        RemoveKeyword(keywords, "_BDRF2");
        RemoveKeyword(keywords, "_BDRF3");

        keywords.Add(FeatureFromOutput(debugOutput).ToString());
        if (useDebugTopo)
        {
            keywords.Add("_DEBUG_USE_TOPOLOGY");
        }

        keywords.Add("_RENDERBAKE");

        string   shader    = comp.Compile(keywords.ToArray(), "RenderBake_" + debugOutput.ToString());
        Shader   s         = ShaderUtil.CreateShaderAsset(shader);
        Material renderMat = new Material(mat);

        renderMat.shader = s;
        renderMat.CopyPropertiesFromMaterial(mat); // because the constructor doesn't do it right in URP
        renderMat.enableInstancing = false;        // for some reason instance drawing breaks in URP
        return(renderMat);
    }
   static MicroSplatBaseFeatures.DefineFeature FeatureFromOutput(MicroSplatBaseFeatures.DebugOutput p)
   {
      if (p == MicroSplatBaseFeatures.DebugOutput.Albedo)
      {
         return MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_ALBEDO;
      }
      else if (p == MicroSplatBaseFeatures.DebugOutput.AO)
      {
         return MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_AO;
      }
      else if (p == MicroSplatBaseFeatures.DebugOutput.Emission)
      {
         return MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_EMISSION;
      }
      else if (p == MicroSplatBaseFeatures.DebugOutput.Height)
      {
         return MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_HEIGHT;
      }
      else if (p == MicroSplatBaseFeatures.DebugOutput.Metallic)
      {
         return MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_METAL;
      }
      else if (p == MicroSplatBaseFeatures.DebugOutput.Normal)
      {
         return MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_NORMAL;
      }
      else if (p == MicroSplatBaseFeatures.DebugOutput.Smoothness)
      {
         return MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_SMOOTHNESS;
      }
#if __MICROSPLAT_PROCTEX__
      else if (p == MicroSplatBaseFeatures.DebugOutput.ProceduralSplatOutput0)
      {
         return MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_SPLAT0;
      }
      else if (p == MicroSplatBaseFeatures.DebugOutput.ProceduralSplatOutput1)
      {
         return MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_SPLAT1;
      }
      else if (p == MicroSplatBaseFeatures.DebugOutput.ProceduralSplatOutput2)
      {
         return MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_SPLAT2;
      }
      else if (p == MicroSplatBaseFeatures.DebugOutput.ProceduralSplatOutput3)
      {
         return MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_SPLAT3;
      }
      else if (p == MicroSplatBaseFeatures.DebugOutput.ProceduralSplatOutput4)
      {
         return MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_SPLAT4;
      }
      else if (p == MicroSplatBaseFeatures.DebugOutput.ProceduralSplatOutput5)
      {
         return MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_SPLAT5;
      }
      else if (p == MicroSplatBaseFeatures.DebugOutput.ProceduralSplatOutput6)
      {
         return MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_SPLAT6;
      }
      else if (p == MicroSplatBaseFeatures.DebugOutput.ProceduralSplatOutput7)
      {
         return MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_SPLAT7;
      }
      else if (p == MicroSplatBaseFeatures.DebugOutput.ProceduralSplatOutput0A)
      {
         return MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_SPLAT0A;
      }
      else if (p == MicroSplatBaseFeatures.DebugOutput.ProceduralSplatOutput1A)
      {
         return MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_SPLAT1A;
      }
      else if (p == MicroSplatBaseFeatures.DebugOutput.ProceduralSplatOutput2A)
      {
         return MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_SPLAT2A;
      }
      else if (p == MicroSplatBaseFeatures.DebugOutput.ProceduralSplatOutput3A)
      {
         return MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_SPLAT3A;
      }
      else if (p == MicroSplatBaseFeatures.DebugOutput.ProceduralSplatOutput4A)
      {
         return MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_SPLAT4A;
      }
      else if (p == MicroSplatBaseFeatures.DebugOutput.ProceduralSplatOutput5A)
      {
         return MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_SPLAT5A;
      }
      else if (p == MicroSplatBaseFeatures.DebugOutput.ProceduralSplatOutput6A)
      {
         return MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_SPLAT6A;
      }
      else if (p == MicroSplatBaseFeatures.DebugOutput.ProceduralSplatOutput7A)
      {
         return MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_SPLAT7A;
      }
#endif
      return MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_ALBEDO;
   }
Example #5
0
    static MicroSplatBaseFeatures.DefineFeature FeatureFromOutput(MicroSplatBaseFeatures.DebugOutput p)
    {
        if (p == MicroSplatBaseFeatures.DebugOutput.Albedo)
        {
            return(MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_ALBEDO);
        }
        else if (p == MicroSplatBaseFeatures.DebugOutput.AO)
        {
            return(MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_AO);
        }
        else if (p == MicroSplatBaseFeatures.DebugOutput.Emission)
        {
            return(MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_EMISSION);
        }
        else if (p == MicroSplatBaseFeatures.DebugOutput.Height)
        {
            return(MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_HEIGHT);
        }
        else if (p == MicroSplatBaseFeatures.DebugOutput.Metallic)
        {
            return(MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_METAL);
        }
        else if (p == MicroSplatBaseFeatures.DebugOutput.Normal)
        {
            return(MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_NORMAL);
        }
        else if (p == MicroSplatBaseFeatures.DebugOutput.Smoothness)
        {
            return(MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_SMOOTHNESS);
        }
        else if (p == MicroSplatBaseFeatures.DebugOutput.FinalNormalTangent)
        {
            return(MicroSplatBaseFeatures.DefineFeature._DEBUG_FINALNORMALTANGENT);
        }
#if __MICROSPLAT_PROCTEX__
        else if (p == MicroSplatBaseFeatures.DebugOutput.ProceduralSplatOutput0)
        {
            return(MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_SPLAT0);
        }
        else if (p == MicroSplatBaseFeatures.DebugOutput.ProceduralSplatOutput1)
        {
            return(MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_SPLAT1);
        }
        else if (p == MicroSplatBaseFeatures.DebugOutput.ProceduralSplatOutput2)
        {
            return(MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_SPLAT2);
        }
        else if (p == MicroSplatBaseFeatures.DebugOutput.ProceduralSplatOutput3)
        {
            return(MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_SPLAT3);
        }
        else if (p == MicroSplatBaseFeatures.DebugOutput.ProceduralSplatOutput4)
        {
            return(MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_SPLAT4);
        }
        else if (p == MicroSplatBaseFeatures.DebugOutput.ProceduralSplatOutput5)
        {
            return(MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_SPLAT5);
        }
        else if (p == MicroSplatBaseFeatures.DebugOutput.ProceduralSplatOutput6)
        {
            return(MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_SPLAT6);
        }
        else if (p == MicroSplatBaseFeatures.DebugOutput.ProceduralSplatOutput7)
        {
            return(MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_SPLAT7);
        }
        else if (p == MicroSplatBaseFeatures.DebugOutput.ProceduralSplatOutput0A)
        {
            return(MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_SPLAT0A);
        }
        else if (p == MicroSplatBaseFeatures.DebugOutput.ProceduralSplatOutput1A)
        {
            return(MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_SPLAT1A);
        }
        else if (p == MicroSplatBaseFeatures.DebugOutput.ProceduralSplatOutput2A)
        {
            return(MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_SPLAT2A);
        }
        else if (p == MicroSplatBaseFeatures.DebugOutput.ProceduralSplatOutput3A)
        {
            return(MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_SPLAT3A);
        }
        else if (p == MicroSplatBaseFeatures.DebugOutput.ProceduralSplatOutput4A)
        {
            return(MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_SPLAT4A);
        }
        else if (p == MicroSplatBaseFeatures.DebugOutput.ProceduralSplatOutput5A)
        {
            return(MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_SPLAT5A);
        }
        else if (p == MicroSplatBaseFeatures.DebugOutput.ProceduralSplatOutput6A)
        {
            return(MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_SPLAT6A);
        }
        else if (p == MicroSplatBaseFeatures.DebugOutput.ProceduralSplatOutput7A)
        {
            return(MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_SPLAT7A);
        }
#endif
        return(MicroSplatBaseFeatures.DefineFeature._DEBUG_OUTPUT_ALBEDO);
    }