public static bool SetMaterialParam(Material material, string property, JSONNode valueNode) { int propertyIndex; if (!CheckMaterialProperty(material, property, out propertyIndex)) { return(false); } // Set the property value bool succeed = false; ShaderUtil.ShaderPropertyType type = ShaderUtil.GetPropertyType(material.shader, propertyIndex); switch (type) { case ShaderUtil.ShaderPropertyType.TexEnv: succeed = SetMaterialTexture(material, property, valueNode); break; default: Debug.LogWarning(string.Format("{0} property exchange not implemented", type.ToString())); break; } if (!succeed) { Debug.LogWarning(string.Format("Failed to load property '{0}' value of type {1} on material {2}: {3}", property, type.ToString(), AssetDatabase.GetAssetPath(material), valueNode.Value)); } else { // Apply property changed post process ShaderInfos shaderInfos = ShadersInfos.GetShaderInfos(material.shader); if (shaderInfos.PostProcesses.ContainsKey(property)) { shaderInfos.PostProcesses[property](material, valueNode); } } return(succeed); }
public void OnGUI() { // DisplayShaderContext(EditorGUILayout.GetControlRect()); string[] strs = new[] { "数组下标0", "数组下标1", "数组下标2", }; int[] intArr = new[] { 1, 2, 3, }; //字符选择,返回选择的字符数组下标 this.index = EditorGUILayout.Popup(this.index, strs); //字符选择,返回对应的整数数组的整数值 this.index = EditorGUILayout.IntPopup(this.index, strs, intArr); Debug.Log("index:" + index); //枚举选择 this.mEnum = (EnumTest)EditorGUILayout.EnumPopup(this.mEnum); // shader 下拉列表 EditorGUILayout.LabelField("Shader下拉列表"); ShaderInfo[] shaderLists = ShaderUtil.GetAllShaderInfo(); string[] nameLists = new string[shaderLists.Length]; for (int i = 0; i < shaderLists.Length; i++) { nameLists[i] = shaderLists[i].name; } EditorGUILayout.Popup(this.index, nameLists); }
void UpdateMasterNodeShader() { var shaderData = masterRenderData?.shaderData; var masterNode = shaderData?.node as IMasterNode; if (masterNode == null) { return; } var generator = new Generator(m_Graph, shaderData?.node, GenerationMode.Preview, shaderData?.node.name); shaderData.shaderString = generator.generatedShader; if (string.IsNullOrEmpty(shaderData.shaderString)) { if (shaderData.shader != null) { ShaderUtil.ClearShaderMessages(shaderData.shader); Object.DestroyImmediate(shaderData.shader, true); shaderData.shader = null; } return; } if (shaderData.shader == null) { shaderData.shader = ShaderUtil.CreateShaderAsset(shaderData.shaderString, false); shaderData.shader.hideFlags = HideFlags.HideAndDontSave; } else { ShaderUtil.ClearCachedData(shaderData.shader); } BeginCompile(masterRenderData, shaderData.shaderString); }
void UpdateMasterNodeShader() { var shaderData = masterRenderData?.shaderData; var masterNode = shaderData?.node as IMasterNode; if (masterNode == null) { return; } List <PropertyCollector.TextureInfo> configuredTextures; shaderData.shaderString = masterNode.GetShader(GenerationMode.Preview, shaderData.node.name, out configuredTextures); if (string.IsNullOrEmpty(shaderData.shaderString)) { if (shaderData.shader != null) { ShaderUtil.ClearShaderMessages(shaderData.shader); Object.DestroyImmediate(shaderData.shader, true); shaderData.shader = null; } return; } if (shaderData.shader == null) { shaderData.shader = ShaderUtil.CreateShaderAsset(shaderData.shaderString, false); shaderData.shader.hideFlags = HideFlags.HideAndDontSave; } else { ShaderUtil.ClearCachedData(shaderData.shader); } BeginCompile(masterRenderData, shaderData.shaderString); }
private static List <Texture> GetTexturesFromRenderer(Renderer r) { var ret = new List <Texture>(); var mats = r.sharedMaterials; foreach (var mat in mats) { if (mat == null) { continue; } var s = mat.shader; int spCount = ShaderUtil.GetPropertyCount(s); for (var i = 0; i < spCount; ++i) { var pName = ShaderUtil.GetPropertyName(s, i); var pType = ShaderUtil.GetPropertyType(s, i); if (pType == ShaderUtil.ShaderPropertyType.TexEnv) { var td = ShaderUtil.GetTexDim(s, i); if (td == UnityEngine.Rendering.TextureDimension.Tex2D) { var t = mat.GetTexture(pName); if (t != null) { ret.Add(t); } } } } } return(ret); }
private static object ShaderField(string id, Shader value) { GUILayout.BeginHorizontal(); try { GUI.contentColor = Config.ValueColor; var values = ShaderUtil.GetShaders(); var valueIndex = Array.IndexOf(values, value.name); var newValueIndex = GUIComboBox.Box(valueIndex, values, id); if (newValueIndex != valueIndex) { value = Shader.Find(values[newValueIndex]); } GUI.contentColor = Color.white; } finally { GUILayout.EndHorizontal(); } return(value); }
private void DrawBodySkeleton(float coordinate, float[] projectionMatrix) { ShaderUtil.CheckGlError(TAG, "Draw body skeleton start."); GLES20.GlUseProgram(mProgram); GLES20.GlEnableVertexAttribArray(mPosition); GLES20.GlBindBuffer(GLES20.GlArrayBuffer, mVbo); // The size of the vertex attribute is 4, and each vertex has four coordinate components. GLES20.GlVertexAttribPointer( mPosition, 4, GLES20.GlFloat, false, BYTES_PER_POINT, 0); GLES20.GlUniform4f(mColor, 0.0f, 0.0f, 1.0f, 1.0f); GLES20.GlUniformMatrix4fv(mProjectionMatrix, 1, false, projectionMatrix, 0); // Set the size of the skeleton points. GLES20.GlUniform1f(mPointSize, 30.0f); GLES20.GlUniform1f(mCoordinateSystem, coordinate); GLES20.GlDrawArrays(GLES20.GlPoints, 0, mNumPoints); GLES20.GlDisableVertexAttribArray(mPosition); GLES20.GlBindBuffer(GLES20.GlArrayBuffer, 0); ShaderUtil.CheckGlError(TAG, "Draw body skeleton end."); }
private static bool CheckMaterialProperty(Material material, string property, out int propertyIndex) { propertyIndex = -1; // Check parameter validity ShaderInfos shaderInfos = ShadersInfos.GetShaderInfos(material.shader); if (shaderInfos == null || !shaderInfos.PropertiesAssociation.ContainsValue(property)) { Debug.LogWarning(string.Format("Unknown '{0}' parameter in shader {1}", property, material.shader.name)); return(false); } int propertyCount = ShaderUtil.GetPropertyCount(material.shader); for (int i = 0; i < propertyCount; ++i) { if (ShaderUtil.GetPropertyName(material.shader, i).Equals(property)) { propertyIndex = i; return(true); } } Debug.LogWarning(string.Format("Material '{0}' doesn't contain '{1}' property", AssetDatabase.GetAssetPath(material), property)); return(false); }
public override void OnImportAsset(AssetImportContext ctx) { var oldShader = AssetDatabase.LoadAssetAtPath <Shader>(ctx.assetPath); if (oldShader != null) { ShaderUtil.ClearShaderErrors(oldShader); } List <PropertyCollector.TextureInfo> configuredTextures; var text = GetShaderText <MaterialGraph>(ctx.assetPath, out configuredTextures); if (text == null) { text = errorShader; } var name = Path.GetFileNameWithoutExtension(ctx.assetPath); string shaderName = string.Format("graphs/{0}", name); text = text.Replace("Hidden/GraphErrorShader2", shaderName); var shader = ShaderUtil.CreateShaderAsset(text); EditorMaterialUtility.SetShaderDefaults( shader, configuredTextures.Where(x => x.modifiable).Select(x => x.name).ToArray(), configuredTextures.Where(x => x.modifiable).Select(x => EditorUtility.InstanceIDToObject(x.textureId) as Texture).ToArray()); EditorMaterialUtility.SetShaderNonModifiableDefaults( shader, configuredTextures.Where(x => !x.modifiable).Select(x => x.name).ToArray(), configuredTextures.Where(x => !x.modifiable).Select(x => EditorUtility.InstanceIDToObject(x.textureId) as Texture).ToArray()); ctx.AddObjectToAsset("MainAsset", shader); ctx.SetMainObject(shader); }
public void SetPropertiesFromMaterial() { InitializeSettings(); for (var i = 0; i < settings.Length; i++) { var targetMat = targetMaterials[i]; var setting = settings[i]; setting.name = targetMat.name; var s = targetMat.shader; var pCount = ShaderUtil.GetPropertyCount(s); var fPropNames = Enumerable.Range(0, pCount).Where(idx => ShaderUtil.GetPropertyType(s, idx) == ShaderUtil.ShaderPropertyType.Float).Select(idx => ShaderUtil.GetPropertyName(s, idx)).ToArray(); var cPropNames = Enumerable.Range(0, pCount).Where(idx => ShaderUtil.GetPropertyType(s, idx) == ShaderUtil.ShaderPropertyType.Color).Select(idx => ShaderUtil.GetPropertyName(s, idx)).ToArray(); var vPropNames = Enumerable.Range(0, pCount).Where(idx => ShaderUtil.GetPropertyType(s, idx) == ShaderUtil.ShaderPropertyType.Vector).Select(idx => ShaderUtil.GetPropertyName(s, idx)).ToArray(); setting.floatProperties = fPropNames.Select(name => new StringFloatPair(name, targetMat.GetFloat(name))).ToArray(); setting.colorProperties = cPropNames.Select(name => new StringColorPair(name, targetMat.GetColor(name))).ToArray(); setting.vectorProperties = vPropNames.Select(name => new StringVectorPair(name, targetMat.GetVector(name))).ToArray(); setting.texNames = Enumerable.Range(0, pCount).Where(idx => ShaderUtil.GetPropertyType(s, idx) == ShaderUtil.ShaderPropertyType.TexEnv).Select(idx => ShaderUtil.GetPropertyName(s, idx)).ToArray(); setting.filePath = GetFilePath(targetMat.name); setting.Save(); } }
public List <MaterialProperty> GetShaderProperties(Material material) { if (cache.ContainsKey(material.shader.name)) { return(cache[material.shader.name]); } var list = new List <MaterialProperty>(); Shader s = material.shader; int count = ShaderUtil.GetPropertyCount(s); for (int i = 0; i < count; i++) { list.Add(new MaterialProperty() { type = ShaderUtil.GetPropertyType(s, i), description = ShaderUtil.GetPropertyDescription(s, i), name = ShaderUtil.GetPropertyName(s, i) }); } cache[material.shader.name] = list; return(list); }
void SliceProperties(TerrainSlice terrainSlice, Material materialSlice, string applicationSavePath, string unityPathToSaveTextures) { List <string> texturePropertiesToSliceNormally = new List <string>(), texturePropertiesToSliceAbnormally = new List <string>(); for (int i = 0; i < ShaderUtil.GetPropertyCount(materialSlice.shader); i++) { ShaderUtil.ShaderPropertyType propertyType = ShaderUtil.GetPropertyType(materialSlice.shader, i); if (propertyType == ShaderUtil.ShaderPropertyType.TexEnv) { string texturePropertyName = ShaderUtil.GetPropertyName(materialSlice.shader, i); if (texturePropertyName.StartsWith("_Splat")) { texturePropertiesToSliceAbnormally.Add(texturePropertyName); } else if (!texturePropertyName.StartsWith("_CombinedNormal")) { texturePropertiesToSliceNormally.Add(texturePropertyName); } } } SliceTextureScaleAndOffset_NormalMethod(terrainSlice, materialSlice, texturePropertiesToSliceNormally); SliceTextureScaleAndOffset_AbnormalMethod(terrainSlice, materialSlice, texturePropertiesToSliceAbnormally); }
public static KeyValuePair <Material, string>[] GetReferenceMats(Texture tex) { Material[] mats = Resources.FindObjectsOfTypeAll <Material>(); List <KeyValuePair <Material, string> > result = new List <KeyValuePair <Material, string> >(); for (int i = 0; i < mats.Length; i++) { string name = mats[i].name; if (name.StartsWith("Hidden/") || name.StartsWith("PostProcess")) { continue; } if (mats[i].shader == null) { continue; } Shader shader = mats[i].shader; int count = ShaderUtil.GetPropertyCount(shader); for (int j = 0; j < count; j++) { if (ShaderUtil.GetPropertyType(shader, j) == ShaderUtil.ShaderPropertyType.TexEnv) { string texName = ShaderUtil.GetPropertyName(shader, j); Texture propertyTex = mats[i].GetTexture(texName); if (propertyTex == tex) { result.Add(new KeyValuePair <Material, string>(mats[i], texName)); } } } } return(result.ToArray()); }
// Cache properties of a given shader if it's // different from a previously given one. void CachePropertyList(Shader shader) { if (_cachedShader == shader) { return; } var temp = new List <string>(); var count = ShaderUtil.GetPropertyCount(shader); for (var i = 0; i < count; i++) { var propType = ShaderUtil.GetPropertyType(shader, i); if (propType == ShaderUtil.ShaderPropertyType.Float || propType == ShaderUtil.ShaderPropertyType.Range) { temp.Add(ShaderUtil.GetPropertyName(shader, i)); } } _propertyList = temp.ToArray(); _cachedShader = shader; }
TweenMaterial.PropertyTypes GetPropertyType(Shader s, int propertyIdx) { ShaderUtil.ShaderPropertyType t = ShaderUtil.GetPropertyType(s, propertyIdx); switch (t) { case ShaderUtil.ShaderPropertyType.Color: return(TweenMaterial.PropertyTypes.Color); case ShaderUtil.ShaderPropertyType.Float: return(TweenMaterial.PropertyTypes.Float); case ShaderUtil.ShaderPropertyType.Range: return(TweenMaterial.PropertyTypes.Float); case ShaderUtil.ShaderPropertyType.TexEnv: return(TweenMaterial.PropertyTypes.TexParam); case ShaderUtil.ShaderPropertyType.Vector: return(TweenMaterial.PropertyTypes.Vector); } return(TweenMaterial.PropertyTypes.None); }
void OnPreprocessAsset() { ShaderGraphImporter sgImporter = assetImporter as ShaderGraphImporter; if (sgImporter != null) { // Before importing, clear shader messages for any existing old shaders, if any. // This is a terrible way to do it, but currently how the shader message system works at the moment. // to workaround a bug with LoadAllAssetsAtPath(), which crashes if the asset has not yet been imported // we first call LoadAssetAtPath<>, which handles assets not yet imported by returning null if (AssetDatabase.LoadAssetAtPath <Shader>(assetPath) != null) { var oldArtifacts = AssetDatabase.LoadAllAssetsAtPath(assetPath); foreach (var artifact in oldArtifacts) { if ((artifact != null) && (artifact is Shader oldShader)) { ShaderUtil.ClearShaderMessages(oldShader); } } } } }
/// <summary> /// Draws the icon in a square rect, with a custom shader that makes the icon look better when down-scaled. /// This also handles mouseover effects, and linier color spacing. /// </summary> public void Draw(Rect rect, Texture texture) { if (Event.current.type != EventType.Repaint) { return; } if (!GUIClipInfo.VisibleRect.Contains(rect.center)) { return; } if (blurWhenDownscalingMaterial == null || blurWhenDownscalingMaterial.shader == null) { blurWhenDownscalingMaterial = new Material(ShaderUtil.CreateShaderAsset(blurWhenDownscalingShader)); } // The smaller the image, the bigger the texel size. float texelSize = Mathf.Pow(Mathf.Max((1f - rect.width / this.Active.width) * 1.866f, 0), 1.46f) / this.Active.width; blurWhenDownscalingMaterial.SetFloat("_TexelSize", texelSize); blurWhenDownscalingMaterial.SetColor("_TintColor", GUI.color); Graphics.DrawTexture(rect, texture, blurWhenDownscalingMaterial); }
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); }
public static List <TexEnv> GetTexEnvs(Shader shader) { texEnvNames.Clear(); if (shader != null) { var count = ShaderUtil.GetPropertyCount(shader); for (var i = 0; i < count; i++) { if (ShaderUtil.GetPropertyType(shader, i) == ShaderUtil.ShaderPropertyType.TexEnv) { var texEnv = default(TexEnv); texEnv.Name = ShaderUtil.GetPropertyName(shader, i); texEnv.Desc = ShaderUtil.GetPropertyDescription(shader, i); texEnvNames.Add(texEnv); } } } return(texEnvNames); }
public ShaderInfo(Shader _shader) { if (_shader == null) { throw new Exception("[ShaderUtility] Couldnt find shader with name"); } // Initialize Name = _shader.name; PropertyList = new List <ShaderProperty>(); // Iterate through properties int _propertyCount = ShaderUtil.GetPropertyCount(_shader); for (int _iter = 0; _iter < _propertyCount; _iter++) { string _propertyName = ShaderUtil.GetPropertyName(_shader, _iter); ShaderUtil.ShaderPropertyType _propertyType = ShaderUtil.GetPropertyType(_shader, _iter); ShaderProperty _newProperty = new ShaderProperty(_propertyName, _propertyType); // Add it to list PropertyList.Add(_newProperty); } }
private static HashSet <string> CollectTextureGUIDs(Material _material) { HashSet <string> textureGUIDs = new HashSet <string>(); for (int i = 0; i < ShaderUtil.GetPropertyCount(_material.shader); ++i) { if (ShaderUtil.ShaderPropertyType.TexEnv == ShaderUtil.GetPropertyType(_material.shader, i)) { Texture texture = _material.GetTexture(ShaderUtil.GetPropertyName(_material.shader, i)); if (null == texture) { continue; } string textureGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(texture)); if (!textureGUIDs.Contains(textureGUID)) { textureGUIDs.Add(textureGUID); } } } return(textureGUIDs); }
public static void CopyMaterialProperties(Material source, Material destination) { MaterialProperty[] materialProperties = MaterialEditor.GetMaterialProperties(new Material[1] { source }); for (int i = 0; i < materialProperties.Length; i++) { int nameID = Shader.PropertyToID(materialProperties[i].name); if (destination.HasProperty(nameID)) { switch (ShaderUtil.GetPropertyType(source.shader, i)) { case ShaderUtil.ShaderPropertyType.Color: destination.SetColor(nameID, source.GetColor(nameID)); break; case ShaderUtil.ShaderPropertyType.Float: destination.SetFloat(nameID, source.GetFloat(nameID)); break; case ShaderUtil.ShaderPropertyType.Range: destination.SetFloat(nameID, source.GetFloat(nameID)); break; case ShaderUtil.ShaderPropertyType.TexEnv: destination.SetTexture(nameID, source.GetTexture(nameID)); break; case ShaderUtil.ShaderPropertyType.Vector: destination.SetVector(nameID, source.GetVector(nameID)); break; } } } }
// Cache property names provided within a specified shader. static void CachePropertyNames(Shader shader) { // Exit early when the shader is same to the cached one. if (shader == _cachedShader) { return; } var temp = new List <string>(); var count = ShaderUtil.GetPropertyCount(shader); for (var i = 0; i < count; i++) { var propType = ShaderUtil.GetPropertyType(shader, i); if (propType == ShaderUtil.ShaderPropertyType.TexEnv) { temp.Add(ShaderUtil.GetPropertyName(shader, i)); } } _propertyNames = temp.ToArray(); _cachedShader = shader; }
public ShaderItemUI(Shader sh, VisualTreeAsset treeAsset, string date) { this.shader = sh; this.dateTimeStr = date; var shaderData = ShaderUtil.GetShaderData(sh); #if UNITY_2019_1_OR_NEWER || UNITY_2019_OR_NEWER element = treeAsset.CloneTree(); #else element = treeAsset.CloneTree(null); #endif element.Q <Foldout>("ShaderFold").text = sh.name; element.Q <Foldout>("ShaderFold").value = false; // shader value element.Q <ObjectField>("ShaderVal").objectType = typeof(Shader); element.Q <ObjectField>("ShaderVal").value = sh; var shaderSubShadersFold = element.Q <Foldout>("SubShaders"); shaderSubShadersFold.text = "SubShaders(" + shaderData.SubshaderCount + ")"; shaderSubShadersFold.value = false; for (int i = 0; i < shaderData.SubshaderCount; ++i) { Foldout subShaderFold = new Foldout(); var subShader = shaderData.GetSubshader(i); CreateSubShaderMenu(subShaderFold, i, subShader); shaderSubShadersFold.Add(subShaderFold); } // DumpBtn element.Q <Button>("DumpButton").clickable.clicked += () => { DumpStart(); }; }
internal void OnBakeTexture() { var graph = owner as GraphData; if (graph == null) { Debug.LogError("BakeTextureNode's owner isn't a AbstractMaterialGraph, how is it possible ?"); } // from https://github.com/Unity-Technologies/ScriptableRenderPipeline/commit/3b28421204badded8c0d14315f10c256de3345a0#diff-52bd31870846010ea070163214aac090 graph.GetShader(this, GenerationMode.Preview, "hidden/preview"); BakeShaderData shaderData = new BakeShaderData(); shaderData.ShaderString = graph.GetPreviewShader(this).shader; shaderData.Shader = ShaderUtil.CreateShaderAsset(shaderData.ShaderString); shaderData.Node = this; shaderData.Graph = graph; shaderData.HasError = false; // TODO handle shader errors shaderData.OutputIdName = "Out"; BakeTextureManager.BakeShaderIntoTexture(shaderData); }
private static List <Texture> getTextures(Material material) { string assetPath = AssetDatabase.GetAssetPath(material); if (string.IsNullOrEmpty(assetPath)) { return(null); } Shader shader = material.shader; List <Texture> materials = new List <Texture>(); for (int i = 0; i < ShaderUtil.GetPropertyCount(shader); i++) { if (ShaderUtil.GetPropertyType(shader, i) == ShaderUtil.ShaderPropertyType.TexEnv) { Texture texture = material.GetTexture(ShaderUtil.GetPropertyName(shader, i)); if (texture != null) { materials.Add(texture); } } } return(materials); }
public static string[] GetTexEnvNames(Material material) { var texEnvNames = new List <string>(); if (material != null) { var shader = material.shader; if (shader != null) { var count = ShaderUtil.GetPropertyCount(shader); for (var i = 0; i < count; i++) { if (ShaderUtil.GetPropertyType(shader, i) == ShaderUtil.ShaderPropertyType.TexEnv) { texEnvNames.Add(ShaderUtil.GetPropertyName(shader, i)); } } } } return(texEnvNames.ToArray()); }
// This runs once for every property in our shader. private void ShaderPropertyImpl(Shader shader, int propertyIndex, FeatureToggle currentToggle) { string propertyDescription = ShaderUtil.GetPropertyDescription(shader, propertyIndex); // If current toggle is null, we only want to show properties that aren't already "owned" by a toggle, // so if it is owned by another toggle, then return. if (currentToggle == null) { for (int i = 0; i < Toggles.Count; i++) { if (Regex.IsMatch(propertyDescription, Toggles[i].InspectorPropertyHideTag, RegexOptions.IgnoreCase)) { return; } } } // Only draw if we the current property is owned by the current toggle. else if (!Regex.IsMatch(propertyDescription, currentToggle.InspectorPropertyHideTag, RegexOptions.IgnoreCase)) { return; } // If we've gotten to this point, draw the shader property regulairly. ShaderProperty(shader, propertyIndex); }
void BeginCompile(PreviewRenderData renderData, string shaderStr) { using (BeginCompileMarker.Auto()) { var shaderData = renderData.shaderData; // want to ensure this so we don't get confused with multiple compile versions in flight Assert.IsTrue(shaderData.passesCompiling == 0); if (shaderData.shader == null) { shaderData.shader = ShaderUtil.CreateShaderAsset(shaderStr, false); shaderData.shader.hideFlags = HideFlags.HideAndDontSave; } else { ShaderUtil.ClearCachedData(shaderData.shader); ShaderUtil.UpdateShaderAsset(shaderData.shader, shaderStr, false); } if (shaderData.mat == null) { shaderData.mat = new Material(shaderData.shader) { hideFlags = HideFlags.HideAndDontSave }; } shaderData.passesCompiling = shaderData.mat.passCount; for (var i = 0; i < shaderData.mat.passCount; i++) { ShaderUtil.CompilePass(shaderData.mat, i); } m_NodesCompiling.Add(shaderData.node); } }
public void UpdateAsset() { if (selectedGuid != null && graphObject != null) { var path = AssetDatabase.GUIDToAssetPath(selectedGuid); if (string.IsNullOrEmpty(path) || graphObject == null) { return; } ShaderGraphAnalytics.SendShaderGraphEvent(selectedGuid, graphObject.graph); var oldShader = AssetDatabase.LoadAssetAtPath <Shader>(path); if (oldShader != null) { ShaderUtil.ClearShaderMessages(oldShader); } UpdateShaderGraphOnDisk(path); OnSaveGraph(path); } UpdateTitle(); }