Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // C# code, shaderText should be a string of the disassembled shader contents (from "psa.exe shaderFile.pso /Fc")
- // Ugly code but seems to work on every shader I tried with.
- private string UpdateShader(string shaderText)
- {
- var list = shaderText.Split(new[] { "\r\n" }, StringSplitOptions.None);
- var start = "";
- var perLight = "";
- var endLight = "";
- var end = "";
- bool inShaders = false;
- bool endL = false;
- foreach (var line in list)
- {
- if (!inShaders && !endL)
- {
- if (line.EndsWith(", c20"))
- {
- inShaders = true;
- start += "\r\n";
- }
- }
- if (inShaders)
- {
- if (!endL)
- if (line.EndsWith(", c21"))
- endL = true;
- if (endL)
- {
- endLight += line + "\r\n";
- if (line.Contains(", c6,"))
- {
- endLight += "\r\n";
- inShaders = false;
- }
- }
- else
- perLight += line + "\r\n";
- }
- else
- {
- if (!endL)
- start += line + "\r\n";
- else
- end += line + "\r\n";
- }
- }
- endLight = endLight.Replace(", c21", ", c28").Replace(", c6,", ", c13,");
- var text = perLight;
- for (int i = 2; i < 9; i++)
- {
- var posRegI = 19 + i;
- var posReg = $", c{posRegI}";
- var colRegI = 4 + i;
- var colReg = $", c{colRegI}";
- var thisTxt = perLight.Replace(", c20", posReg);
- thisTxt = thisTxt.Replace(", c5", colReg);
- thisTxt = $"\r\n// Light {i}\r\n{thisTxt}";
- text = text + thisTxt;
- }
- return start + "// Light 1\r\n" + text + "\r\n// Light 9\r\n" + endLight + end;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement