changes to samplers
This commit is contained in:
@@ -5,6 +5,8 @@ import com.google.gson.annotations.JsonAdapter;
|
|||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectLinkedOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectLinkedOpenHashMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap;
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||||
import me.cortex.voxy.common.Logger;
|
import me.cortex.voxy.common.Logger;
|
||||||
import net.irisshaders.iris.shaderpack.ShaderPack;
|
import net.irisshaders.iris.shaderpack.ShaderPack;
|
||||||
import net.irisshaders.iris.shaderpack.include.AbsolutePackPath;
|
import net.irisshaders.iris.shaderpack.include.AbsolutePackPath;
|
||||||
@@ -39,6 +41,40 @@ public class IrisShaderPatch {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private static final class SamplerDeserializer implements JsonDeserializer<Object2ObjectLinkedOpenHashMap<String, String>> {
|
||||||
|
@Override
|
||||||
|
public Object2ObjectLinkedOpenHashMap<String, String> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||||
|
Object2ObjectLinkedOpenHashMap<String, String> ret = new Object2ObjectLinkedOpenHashMap<>();
|
||||||
|
if (json==null) return null;
|
||||||
|
try {
|
||||||
|
if (json.isJsonArray()) {
|
||||||
|
for (var entry : json.getAsJsonArray()) {
|
||||||
|
var name = entry.getAsString();
|
||||||
|
var type = "sampler2D";
|
||||||
|
if (name.matches("shadowtex")) {
|
||||||
|
type = "sampler2DShadow";
|
||||||
|
}
|
||||||
|
ret.put(name, type);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (var entry : json.getAsJsonObject().entrySet()) {
|
||||||
|
String type = "sampler2D";
|
||||||
|
if (entry.getValue().isJsonNull()) {
|
||||||
|
if (entry.getKey().matches("shadowtex")) {
|
||||||
|
type = "sampler2DShadow";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
type = entry.getValue().getAsString();
|
||||||
|
}
|
||||||
|
ret.put(entry.getKey(), type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logger.error(e);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public record BlendState(int buffer, boolean off, int sRBG, int dRGb, int sA, int dA) {
|
public record BlendState(int buffer, boolean off, int sRBG, int dRGb, int sA, int dA) {
|
||||||
public static BlendState ALL_OFF = new BlendState(-1, true, 0,0,0,0);
|
public static BlendState ALL_OFF = new BlendState(-1, true, 0,0,0,0);
|
||||||
@@ -110,7 +146,8 @@ public class IrisShaderPatch {
|
|||||||
public int[] opaqueDrawBuffers;
|
public int[] opaqueDrawBuffers;
|
||||||
public int[] translucentDrawBuffers;
|
public int[] translucentDrawBuffers;
|
||||||
public String[] uniforms;
|
public String[] uniforms;
|
||||||
public String[] samplers;
|
@JsonAdapter(SamplerDeserializer.class)
|
||||||
|
public Object2ObjectLinkedOpenHashMap<String, String> samplers;
|
||||||
public String[] opaquePatchData;
|
public String[] opaquePatchData;
|
||||||
public String[] translucentPatchData;
|
public String[] translucentPatchData;
|
||||||
@JsonAdapter(SSBODeserializer.class)
|
@JsonAdapter(SSBODeserializer.class)
|
||||||
@@ -151,7 +188,7 @@ public class IrisShaderPatch {
|
|||||||
public String[] getUniformList() {
|
public String[] getUniformList() {
|
||||||
return this.patchData.uniforms;
|
return this.patchData.uniforms;
|
||||||
}
|
}
|
||||||
public String[] getSamplerList() {
|
public Object2ObjectLinkedOpenHashMap<String, String> getSamplerSet() {
|
||||||
return this.patchData.samplers;
|
return this.patchData.samplers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -313,7 +313,8 @@ public class IrisVoxyRenderPipelineData {
|
|||||||
|
|
||||||
}
|
}
|
||||||
private static ImageSet createImageSet(IrisRenderingPipeline ipipe, IrisShaderPatch patch) {
|
private static ImageSet createImageSet(IrisRenderingPipeline ipipe, IrisShaderPatch patch) {
|
||||||
Set<String> samplerNameSet = new LinkedHashSet<>(List.of(patch.getSamplerList()));
|
var samplerDataSet = patch.getSamplerSet();
|
||||||
|
Set<String> samplerNameSet = new LinkedHashSet<>(samplerDataSet.keySet());
|
||||||
if (samplerNameSet.isEmpty()) return null;
|
if (samplerNameSet.isEmpty()) return null;
|
||||||
Set<TextureWSampler> samplerSet = new LinkedHashSet<>();
|
Set<TextureWSampler> samplerSet = new LinkedHashSet<>();
|
||||||
SamplerHolder samplerBuilder = new SamplerHolder() {
|
SamplerHolder samplerBuilder = new SamplerHolder() {
|
||||||
@@ -389,11 +390,7 @@ public class IrisVoxyRenderPipelineData {
|
|||||||
for (var entry : samplerSet) {
|
for (var entry : samplerSet) {
|
||||||
samplers[i]=entry;
|
samplers[i]=entry;
|
||||||
|
|
||||||
String samplerType = "sampler2D";
|
String samplerType = samplerDataSet.get(entry.name);
|
||||||
if (entry.name.startsWith("shadowtex")) {
|
|
||||||
samplerType = "sampler2DShadow";
|
|
||||||
}
|
|
||||||
|
|
||||||
builder.append("layout(binding=(BASE_SAMPLER_BINDING_INDEX+").append(i).append(")) uniform ").append(samplerType).append(" ").append(entry.name).append(";\n");
|
builder.append("layout(binding=(BASE_SAMPLER_BINDING_INDEX+").append(i).append(")) uniform ").append(samplerType).append(" ").append(entry.name).append(";\n");
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user