Search in sources :

Example 1 with OptionAnnotatedSource

use of net.coderbot.iris.shaderpack.option.OptionAnnotatedSource in project Iris by IrisShaders.

the class OptionDiscoverTest method testTrivialString.

private void testTrivialString(String base, String expectedOptionName, String expectedDefault, ImmutableList<String> expectedAllowed) {
    OptionAnnotatedSource source = new OptionAnnotatedSource(base);
    OptionSet options = source.getOptionSet(AbsolutePackPath.fromAbsolutePath("/<hardcoded>"), source.getBooleanDefineReferences().keySet());
    Assertions.assertEquals(options.getBooleanOptions().size(), 0, "Unexpectedly discovered a boolean option");
    if (options.getStringOptions().size() == 0) {
        Assertions.fail("No string options were discovered, diagnostics: " + source.getDiagnostics());
    }
    StringOption option = options.getStringOptions().values().iterator().next().getOption();
    Assertions.assertEquals(option.getName(), expectedOptionName);
    Assertions.assertEquals(option.getDefaultValue(), expectedDefault);
    Assertions.assertEquals(option.getAllowedValues(), expectedAllowed);
}
Also used : StringOption(net.coderbot.iris.shaderpack.option.StringOption) OptionAnnotatedSource(net.coderbot.iris.shaderpack.option.OptionAnnotatedSource) OptionSet(net.coderbot.iris.shaderpack.option.OptionSet)

Example 2 with OptionAnnotatedSource

use of net.coderbot.iris.shaderpack.option.OptionAnnotatedSource in project Iris by IrisShaders.

the class OptionDiscoverTest method testNoDiscovery.

private void testNoDiscovery(String base) {
    OptionAnnotatedSource source = new OptionAnnotatedSource(base);
    OptionSet options = source.getOptionSet(AbsolutePackPath.fromAbsolutePath("/<hardcoded>"), source.getBooleanDefineReferences().keySet());
    Assertions.assertEquals(options.getBooleanOptions().size(), 0, "Unexpectedly discovered a boolean option");
    Assertions.assertEquals(options.getStringOptions().size(), 0, "Unexpectedly discovered a string option");
}
Also used : OptionAnnotatedSource(net.coderbot.iris.shaderpack.option.OptionAnnotatedSource) OptionSet(net.coderbot.iris.shaderpack.option.OptionSet)

Example 3 with OptionAnnotatedSource

use of net.coderbot.iris.shaderpack.option.OptionAnnotatedSource in project Iris by IrisShaders.

the class OptionApplyTest method testOptions.

// @Test
// TODO: Re-enable this once we can load shader packs in tests without referencing OpenGL / LWJGL / Minecraft.
void testOptions() {
    ShaderPack shaderPack;
    // ensure that we can actually load the shader pack
    try {
        shaderPack = new ShaderPack(IrisTests.getTestShaderPackPath("options"));
    } catch (Exception e) {
        Assertions.fail("Couldn't load test shader pack options", e);
        return;
    }
    ProgramSource basic = shaderPack.getProgramSet(DimensionId.OVERWORLD).getGbuffersBasic().orElseThrow(RuntimeException::new);
    String basicVsh = basic.getVertexSource().orElseThrow(RuntimeException::new);
    String basicFsh = basic.getFragmentSource().orElseThrow(RuntimeException::new);
    OptionAnnotatedSource basicVshAnnotated = new OptionAnnotatedSource(basicVsh);
    OptionAnnotatedSource basicFshAnnotated = new OptionAnnotatedSource(basicFsh);
    // TODO: Separate includes will need more complex boolean define reference behavior
    OptionSet basicVshSet = basicVshAnnotated.getOptionSet(AbsolutePackPath.fromAbsolutePath("/basic.vsh"), basicVshAnnotated.getBooleanDefineReferences().keySet());
    OptionSet basicFshSet = basicFshAnnotated.getOptionSet(AbsolutePackPath.fromAbsolutePath("/basic.fsh"), basicFshAnnotated.getBooleanDefineReferences().keySet());
    OptionSet.Builder setBuilder = OptionSet.builder();
    setBuilder.addAll(basicVshSet);
    setBuilder.addAll(basicFshSet);
    OptionSet options = setBuilder.build();
    Map<String, String> changes = ImmutableMap.of("SHADOWS", "false", "ambientOcclusionLevel", "0.0", "shadowDistance", "64", "ANNOYING_STUFF", "true", "GODRAYS", "16");
    OptionValues values = new MutableOptionValues(options, changes);
    System.out.println(basicVshAnnotated.apply(values));
    System.out.println(basicFshAnnotated.apply(values));
    System.out.println(options);
}
Also used : MutableOptionValues(net.coderbot.iris.shaderpack.option.values.MutableOptionValues) ProgramSource(net.coderbot.iris.shaderpack.ProgramSource) MutableOptionValues(net.coderbot.iris.shaderpack.option.values.MutableOptionValues) OptionValues(net.coderbot.iris.shaderpack.option.values.OptionValues) OptionAnnotatedSource(net.coderbot.iris.shaderpack.option.OptionAnnotatedSource) OptionSet(net.coderbot.iris.shaderpack.option.OptionSet) ShaderPack(net.coderbot.iris.shaderpack.ShaderPack)

Example 4 with OptionAnnotatedSource

use of net.coderbot.iris.shaderpack.option.OptionAnnotatedSource in project Iris by IrisShaders.

the class OptionApplyTest method testTrivial.

private void testTrivial(String base, ImmutableMap<String, String> changes, String expected) {
    OptionAnnotatedSource source = new OptionAnnotatedSource(base);
    OptionSet options = source.getOptionSet(AbsolutePackPath.fromAbsolutePath("/<hardcoded>"), source.getBooleanDefineReferences().keySet());
    OptionValues values = new MutableOptionValues(options, changes);
    Assertions.assertEquals(expected, source.apply(values));
}
Also used : MutableOptionValues(net.coderbot.iris.shaderpack.option.values.MutableOptionValues) MutableOptionValues(net.coderbot.iris.shaderpack.option.values.MutableOptionValues) OptionValues(net.coderbot.iris.shaderpack.option.values.OptionValues) OptionAnnotatedSource(net.coderbot.iris.shaderpack.option.OptionAnnotatedSource) OptionSet(net.coderbot.iris.shaderpack.option.OptionSet)

Aggregations

OptionAnnotatedSource (net.coderbot.iris.shaderpack.option.OptionAnnotatedSource)4 OptionSet (net.coderbot.iris.shaderpack.option.OptionSet)4 MutableOptionValues (net.coderbot.iris.shaderpack.option.values.MutableOptionValues)2 OptionValues (net.coderbot.iris.shaderpack.option.values.OptionValues)2 ProgramSource (net.coderbot.iris.shaderpack.ProgramSource)1 ShaderPack (net.coderbot.iris.shaderpack.ShaderPack)1 StringOption (net.coderbot.iris.shaderpack.option.StringOption)1