@Test public void testVertAndFrag() throws Exception { final String originalVert = "#version 100\n" + "uniform float f;\n" + "uniform float g;\n" + "uniform int h;\n" + "void main() {\n" + " float b = f + g + float(h);\n" + "}\n"; final String originalFrag = "#version 100\n" + "uniform float m;\n" + "uniform float f;\n" + "uniform int t;\n" + "uniform float g;\n" + "void main() {\n" + " float b = m + f + float(t) + g;\n" + "}\n"; final String originalUniforms = "{\n" + " \"f\": {\n" + " \"args\": [\n" + " 3.0\n" + " ], \n" + " \"func\": \"glUniform1f\"\n" + " }, \n" + " \"g\": {\n" + " \"args\": [\n" + " 2.0\n" + " ], \n" + " \"func\": \"glUniform1f\"\n" + " }, \n" + " \"h\": {\n" + " \"args\": [\n" + " 10\n" + " ], \n" + " \"func\": \"glUniform1i\"\n" + " }, \n" + " \"m\": {\n" + " \"args\": [\n" + " 20.0\n" + " ], \n" + " \"func\": \"glUniform1f\"\n" + " }, \n" + " \"t\": {\n" + " \"args\": [\n" + " 3\n" + " ], \n" + " \"func\": \"glUniform1i\"\n" + " } \n" + "}"; final String expectedVert = "#version 100\n" + "uniform float v0;\n" + "uniform float v1;\n" + "uniform int v2;\n" + "void main() {\n" + " float v3 = v0 + v1 + float(v2);\n" + "}\n"; final String expectedFrag = "#version 100\n" + "uniform float v4;\n" + "uniform float v0;\n" + "uniform int v5;\n" + "uniform float v1;\n" + "void main() {\n" + " float v6 = v4 + v0 + float(v5) + v1;\n" + "}\n"; final String expectedUniforms = "{\n" + " \"v0\": {\n" + " \"args\": [\n" + " 3.0\n" + " ], \n" + " \"func\": \"glUniform1f\"\n" + " }, \n" + " \"v1\": {\n" + " \"args\": [\n" + " 2.0\n" + " ], \n" + " \"func\": \"glUniform1f\"\n" + " }, \n" + " \"v2\": {\n" + " \"args\": [\n" + " 10\n" + " ], \n" + " \"func\": \"glUniform1i\"\n" + " }, \n" + " \"v4\": {\n" + " \"args\": [\n" + " 20.0\n" + " ], \n" + " \"func\": \"glUniform1f\"\n" + " }, \n" + " \"v5\": {\n" + " \"args\": [\n" + " 3\n" + " ], \n" + " \"func\": \"glUniform1i\"\n" + " } \n" + "}"; final ShaderJob shaderJob = new GlslShaderJob(Optional.empty(), new PipelineInfo(originalUniforms), ParseHelper.parse(originalVert, ShaderKind.VERTEX), ParseHelper.parse(originalFrag, ShaderKind.FRAGMENT)); final IRandom generator = new ZeroCannedRandom(); final ShaderJob obfuscated = Obfuscator.obfuscate(shaderJob, generator); CompareAsts.assertEqualAsts(expectedVert, obfuscated.getShaders().get(0)); CompareAsts.assertEqualAsts(expectedFrag, obfuscated.getShaders().get(1)); assertEquals(new PipelineInfo(expectedUniforms).toString(), obfuscated.getPipelineInfo() .toString()); }
public static ShaderJob obfuscate( ShaderJob shaderJob, IRandom generator) { return new Obfuscator(generator).obfuscate(shaderJob); }
Obfuscator { public static ShaderJob obfuscate( ShaderJob shaderJob, IRandom generator) { return new Obfuscator(generator).obfuscate(shaderJob); } }
Obfuscator { public static ShaderJob obfuscate( ShaderJob shaderJob, IRandom generator) { return new Obfuscator(generator).obfuscate(shaderJob); } private  Obfuscator(IRandom generator); }
Obfuscator { public static ShaderJob obfuscate( ShaderJob shaderJob, IRandom generator) { return new Obfuscator(generator).obfuscate(shaderJob); } private  Obfuscator(IRandom generator); static ShaderJob obfuscate(
      ShaderJob shaderJob, IRandom generator); static void main(String[] args); }
Obfuscator { public static ShaderJob obfuscate( ShaderJob shaderJob, IRandom generator) { return new Obfuscator(generator).obfuscate(shaderJob); } private  Obfuscator(IRandom generator); static ShaderJob obfuscate(
      ShaderJob shaderJob, IRandom generator); static void main(String[] args);  }