Skip to content

Commit

Permalink
Fix issue #89. Remove unused attributes to prevent OpenGL errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
leon-o committed Aug 5, 2024
1 parent b33183c commit 3d07f64
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@
import io.github.douira.glsl_transformer.GLSLParser;
import io.github.douira.glsl_transformer.ast.node.TranslationUnit;
import io.github.douira.glsl_transformer.ast.node.Version;
import io.github.douira.glsl_transformer.ast.node.declaration.DeclarationMember;
import io.github.douira.glsl_transformer.ast.node.declaration.FunctionDeclaration;
import io.github.douira.glsl_transformer.ast.node.abstract_node.ASTNode;
import io.github.douira.glsl_transformer.ast.node.expression.Expression;
import io.github.douira.glsl_transformer.ast.node.external_declaration.DeclarationExternalDeclaration;
import io.github.douira.glsl_transformer.ast.node.external_declaration.ExternalDeclaration;
import io.github.douira.glsl_transformer.ast.node.external_declaration.FunctionDefinition;
import io.github.douira.glsl_transformer.ast.node.statement.CompoundStatement;
import io.github.douira.glsl_transformer.ast.node.statement.Statement;
import io.github.douira.glsl_transformer.ast.query.Root;
import io.github.douira.glsl_transformer.ast.query.RootSupplier;
import io.github.douira.glsl_transformer.ast.query.index.ExternalDeclarationIndex;
Expand All @@ -25,14 +21,12 @@
import io.github.douira.glsl_transformer.ast.transform.JobParameters;
import io.github.douira.glsl_transformer.ast.transform.SingleASTTransformer;
import io.github.douira.glsl_transformer.parser.ParseShape;
import net.irisshaders.iris.pipeline.transform.transformer.CommonTransformer;
import net.irisshaders.iris.helpers.StringPair;
import net.irisshaders.iris.shaderpack.preprocessor.JcppProcessor;

import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

@SuppressWarnings("unused")
public class GlslTransformerShaderPatcher extends ShaderPatcherBase {
Expand All @@ -45,6 +39,12 @@ public class GlslTransformerShaderPatcher extends ShaderPatcherBase {
public static final AutoHintedMatcher<Expression> glTextureMatrix2 = new AutoHintedMatcher<>(
"gl_TextureMatrix[2]", ParseShape.EXPRESSION);

public static final AutoHintedMatcher<ExternalDeclaration> atTangentAttribute = new AutoHintedMatcher<>(
"attribute vec4 at_tangent;", ParseShape.EXTERNAL_DECLARATION);

public static final AutoHintedMatcher<ExternalDeclaration> mcEntityAttribute = new AutoHintedMatcher<>(
"attribute vec4 mc_Entity;", ParseShape.EXTERNAL_DECLARATION);

private static final ParseShape<GLSLParser.CompoundStatementContext, CompoundStatement> CompoundStatementShape = new ParseShape<>(
GLSLParser.CompoundStatementContext.class,
GLSLParser::compoundStatement,
Expand Down Expand Up @@ -131,8 +131,12 @@ private void transform(TranslationUnit tree, Root root, ContextParameter paramet

root.replaceExpressionMatches(transformer, new AutoHintedMatcher<>("ftransform()", ParseShape.EXPRESSION), "_flw_patched_vertex_pos");

root.processMatches(transformer, atTangentAttribute, ASTNode::detachAndDelete);
root.replaceReferenceExpressions(transformer, "at_tangent", "_flw_tangent");

root.processMatches(transformer, mcEntityAttribute, ASTNode::detachAndDelete);
root.replaceReferenceExpressions(transformer, "mc_Entity", "vec4(0)");

//root.replaceExpressionMatches(transformer, glTextureMatrix0, "mat4(1.0)");

if (boxCoordDetector.matcher(predefineContent).find()) {
Expand Down

0 comments on commit 3d07f64

Please sign in to comment.