public static void Render(FMAT material) { if (CustomCategory.Count == 0) { Init(); } ShaderInfo shaderInfo = null; if (material.MaterialAsset is BfshaRenderer) { shaderInfo = ((BfshaRenderer)material.MaterialAsset).GLShaderInfo; } if (shaderInfo != null) { ImGui.Checkbox("Display Only Used Uniforms From Shader", ref limitUniformsUsedByShaderCode); } if (OriginalValues.Count == 0) { foreach (var param in material.ShaderParams) { OriginalValues.Add(param.Key, param.Value.DataValue); } } LoadHeaders(); if (ImGui.BeginChild("PARAM_LIST")) { int index = 0; foreach (var param in material.ShaderParams.Values) { if (limitUniformsUsedByShaderCode && shaderInfo != null && !shaderInfo.UsedVertexStageUniforms.Contains(param.Name) && !shaderInfo.UsedPixelStageUniforms.Contains(param.Name)) { continue; } if (material.AnimatedParams.ContainsKey(param.Name)) { ImGui.PushStyleColor(ImGuiCol.FrameBg, new Vector4(0, 0.5f, 0, 1)); LoadParamColumns(material.AnimatedParams[param.Name], index++, true); ImGui.PopStyleColor(); } else { LoadParamColumns(param, index++); } } } ImGui.EndChild(); }
public void OnLoad(GX2VertexShader vertexShader, GX2PixelShader pixelShader) { ShaderInfo = CafeShaderDecoder.LoadShaderProgram(vertexShader.DataBytes, pixelShader.DataBytes); VertexShaderSource = System.IO.File.ReadAllText(ShaderInfo.VertPath); FragShaderSource = System.IO.File.ReadAllText(ShaderInfo.FragPath); if (VertexShaderSource == null) { VertexShaderSource = ""; } if (FragShaderSource == null) { FragShaderSource = ""; } }
static ShaderInfo DecodeSharcBinary(string directory, List <ShaderStage> stages) { var vertextage = stages.FirstOrDefault(x => x.Command == "-v"); var pixelStage = stages.FirstOrDefault(x => x.Command == "-p"); ShaderInfo info = new ShaderInfo(); info.VertPath = $"{directory}/{vertextage.Name}{vertextage.Extension}"; info.FragPath = $"{directory}/{pixelStage.Name}{pixelStage.Extension}"; if (File.Exists(info.VertPath) && File.Exists(info.FragPath)) { return(info); } string ex = ConvertStages(stages); for (int i = 0; i < stages.Count; i++) { string outputFilePath = $"{directory}/{stages[i].Name}{stages[i].Extension}"; if (!File.Exists(outputFilePath)) { ConvertGLSL($"{directory}/{stages[i].Name}", outputFilePath, stages[i].Extension); string updatedShaderData = RenameBuffers(File.ReadAllText(outputFilePath), stages[i].Command); File.WriteAllText(outputFilePath, updatedShaderData); } } //Cleanup foreach (var stage in stages) { if (File.Exists($"GFD/{stage.Name}")) { File.Delete($"GFD/{stage.Name}"); } if (File.Exists($"GFD/{stage.Name}{stage.Extension}.spv")) { File.Delete($"GFD/{stage.Name}{stage.Extension}.spv"); } } return(info); }