public BabylonShaderMaterial(string id) : base(id) { SetCustomType("BABYLON.ShaderMaterial"); shaderPath = null; options = new BabylonShaderOptions(); textures = new Dictionary <string, object>(); textureArrays = new Dictionary <string, object[]>(); floats = new Dictionary <string, object>(); floatArrays = new Dictionary <string, object[]>(); colors3 = new Dictionary <string, object>(); colors4 = new Dictionary <string, object>(); vectors2 = new Dictionary <string, object>(); vectors3 = new Dictionary <string, object>(); vectors4 = new Dictionary <string, object>(); matrices = new Dictionary <string, object>(); matrices2x2 = new Dictionary <string, object>(); matrices3x3 = new Dictionary <string, object>(); vectors3Arrays = new Dictionary <string, object[]>(); }
public BabylonShaderMaterial() { this.customType = "BABYLON.ShaderMaterial"; this.shaderPath = null; this.options = new BabylonShaderOptions(); this.textures = new Dictionary <string, object>(); this.textureArrays = new Dictionary <string, object[]>(); this.floats = new Dictionary <string, object>(); this.floatArrays = new Dictionary <string, object[]>(); this.colors3 = new Dictionary <string, object>(); this.colors4 = new Dictionary <string, object>(); this.vectors2 = new Dictionary <string, object>(); this.vectors3 = new Dictionary <string, object>(); this.vectors4 = new Dictionary <string, object>(); this.matrices = new Dictionary <string, object>(); this.matrices2x2 = new Dictionary <string, object>(); this.matrices3x3 = new Dictionary <string, object>(); this.vectors3Arrays = new Dictionary <string, object[]>(); }
public BabylonShaderMaterial() { this.customType = "BABYLON.ShaderMaterial"; this.shaderPath = null; this.options = new BabylonShaderOptions(); this.textures = new Dictionary<string, object>(); this.textureArrays = new Dictionary<string, object[]>(); this.floats = new Dictionary<string, object>(); this.floatArrays = new Dictionary<string, object[]>(); this.colors3 = new Dictionary<string, object>(); this.colors4 = new Dictionary<string, object>(); this.vectors2 = new Dictionary<string, object>(); this.vectors3 = new Dictionary<string, object>(); this.vectors4 = new Dictionary<string, object>(); this.matrices = new Dictionary<string, object>(); this.matrices2x2 = new Dictionary<string, object>(); this.matrices3x3 = new Dictionary<string, object>(); this.vectors3Arrays = new Dictionary<string, object[]>(); }
private object GetShaderPropertyValue(Shader shader) { if (shader == null || shader.name.Substring(0, 10) != "BabylonJS/") return null; string filename = AssetDatabase.GetAssetPath(shader); if (String.IsNullOrEmpty(filename)) return null; List<string> attributeList = new List<string>(); List<string> uniformList = new List<string>(); List<string> samplerList = new List<string>(); List<string> defineList = new List<string>(); var result = new Dictionary<string, object>(); string program = Tools.LoadTextAsset(filename); string basename = shader.name.Replace("BabylonJS/", "").Replace("/", "_").Replace(" ", ""); string babylonOptions = GetShaderProgramSection(basename, program, BabylonProgramSection.Babylon); string[] babylonLines = babylonOptions.Split('\n'); foreach (string babylonLine in babylonLines) { if (babylonLine.IndexOf("attributes", StringComparison.OrdinalIgnoreCase) >= 0) { string[] attributes = babylonLine.Split(':'); if (attributes != null && attributes.Length > 1) { string abuffer = attributes[1].Replace("[", "").Replace("]", "").Replace("\"", ""); if (!String.IsNullOrEmpty(abuffer)) { abuffer = abuffer.Trim(); string[] adata = abuffer.Split(','); if (adata != null && adata.Length > 0) { foreach (string aoption in adata) { string aoption_buffer = aoption.Trim(); if (!String.IsNullOrEmpty(aoption_buffer)) { attributeList.Add(aoption_buffer); } } } } } } else if (babylonLine.IndexOf("uniforms", StringComparison.OrdinalIgnoreCase) >= 0) { string[] uniforms = babylonLine.Split(':'); if (uniforms != null && uniforms.Length > 1) { string ubuffer = uniforms[1].Replace("[", "").Replace("]", "").Replace("\"", ""); if (!String.IsNullOrEmpty(ubuffer)) { ubuffer = ubuffer.Trim(); string[] udata = ubuffer.Split(','); if (udata != null && udata.Length > 0) { foreach (string uoption in udata) { string uoption_buffer = uoption.Trim(); if (!String.IsNullOrEmpty(uoption_buffer)) { uniformList.Add(uoption_buffer); } } } } } } else if (babylonLine.IndexOf("samplers", StringComparison.OrdinalIgnoreCase) >= 0) { string[] samplers = babylonLine.Split(':'); if (samplers != null && samplers.Length > 1) { string sbuffer = samplers[1].Replace("[", "").Replace("]", "").Replace("\"", ""); if (!String.IsNullOrEmpty(sbuffer)) { sbuffer = sbuffer.Trim(); string[] sdata = sbuffer.Split(','); if (sdata != null && sdata.Length > 0) { foreach (string soption in sdata) { string soption_buffer = soption.Trim(); if (!String.IsNullOrEmpty(soption_buffer)) { samplerList.Add(soption_buffer); } } } } } } else if (babylonLine.IndexOf("defines", StringComparison.OrdinalIgnoreCase) >= 0) { string[] defines = babylonLine.Split(':'); if (defines != null && defines.Length > 1) { string dbuffer = defines[1].Replace("[", "").Replace("]", "").Replace("\"", ""); if (!String.IsNullOrEmpty(dbuffer)) { dbuffer = dbuffer.Trim(); string[] ddata = dbuffer.Split(','); if (ddata != null && ddata.Length > 0) { foreach (string doption in ddata) { string doption_buffer = doption.Trim(); if (!String.IsNullOrEmpty(doption_buffer)) { defineList.Add(doption_buffer); } } } } } } } var shaderPath = new Dictionary<string, object>(); string vertexProgram = GetShaderProgramSection(basename, program, BabylonProgramSection.Vertex); shaderPath.Add("vertexElement", ("base64:" + Tools.FormatBase64(vertexProgram))); string fragmentProgram = GetShaderProgramSection(basename, program, BabylonProgramSection.Fragment); shaderPath.Add("fragmentElement", ("base64:" + Tools.FormatBase64(fragmentProgram))); result.Add("shaderPath", shaderPath); var options = new BabylonShaderOptions(); options.attributes = attributeList.ToArray(); options.uniforms = uniformList.ToArray(); options.samplers = samplerList.ToArray(); options.defines = defineList.ToArray(); var shaderOptions = new Dictionary<string, object>(); shaderOptions.Add("attributes", options.attributes); shaderOptions.Add("needAlphaBlending", false); shaderOptions.Add("needAlphaTesting", false); shaderOptions.Add("uniforms", options.uniforms); shaderOptions.Add("samplers", options.samplers); shaderOptions.Add("defines", options.defines); result.Add("shaderOptions", shaderOptions); return result; }