keep getting error
c5121 multiple bindings to output semantic "ATTR1"
while trying to create a shader for Minecraft with the latest version of iris and fabric.
this is my code:
#version 330 compatibility
#extension GL_ARB_separate_shader_objects : enable
out vec2 lmcoord;
out vec2 texcoord;
out vec4 glcolor;
out vec3 normal;
uniform mat4 gbufferModelViewInverse;
/* DRAWBUFFERS:012 */
layout(location = 0) out vec4 color;
layout(location = 1) out vec4 lightmapData;
layout(location = 2) out vec4 encodedNormal;
void main() {
gl_Position = ftransform();
texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
lmcoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy;
lmcoord = (lmcoord * 33.05 / 32.0) - (1.05 / 32.0);
glcolor = gl_Color;
normal = gl_NormalMatrix * gl_Normal;
normal = mat3(gbufferModelViewInverse) * normal;
lightmapData = vec4(lmcoord, 0.0, 1.0);
encodedNormal = vec4(normal * 0.5 + 0.5, 1.0);
}
has to do with lightmapData = vec4(lmcoord, 0.0, 1.0);
and layout(location = 1) out vec4 lightmapData;
because when I delete them it works just fine. I’m on windows ten with a gtx 1660ti with updated drivers.
Well, you’re writing gl_Position
. So this is a VERTEX shader.
And in the NVIDIA GLSL-to-NVASM compiler, varyings get assigned a semantic of ATTR#. For instance:
#var uint OUT.tc0 : $vout.ATTR8 : ATTR8 : -1 : 1
#var uint OUT.tc1 : $vout.ATTR9 : ATTR9 : -1 : 1
#var uint OUT.tc2 : $vout.ATTR10 : ATTR10 : -1 : 1
#var uint OUT.tc3 : $vout.ATTR11 : ATTR11 : -1 : 1
#var float4 pos : $vin.ATTR0 : ATTR0 : -1 : 1
In your VERTEX shader, you have this 1st bag of VERTEX shader outputs, where you “don’t” assign explicit binding locations (ATTR# indices):
and this 2nd bag of VERTEX shader outputs where you “do”:
Merge these lists and pick a standard. Either explicitly assign your own binding locations / attr indices (…for all VERTEX shader outputs), or let the compiler+linker handle it (for all outputs). Dualing schemes are fighting each other here.
Thank you but I am very new to shader coding and open gl so how would I go about doing that?
I suspect that you’re confusing the requirements of a vertex shader and those of a fragment shader. Why do I suspect this? Because:
-
You’re assigning to gl_Position
, which is only valid for a vertex shader.
-
The comment /* DRAWBUFFERS:012 */
, the names of the outputs, and the reference to gbufferModelViewInverse
imply that this is a fragment shader for a deferred render (which generates a “geometry buffer” aka “G-buffer”, consisting of multiple buffers containing various data used by the shading model to generate the final colour).
You’re likely to get better answers on a forum which specifically addresses the Iris mod. Realistically, you’ll need to find documentation which describes how to write shaders for that specific mod. Generic advice about writing OpenGL shaders isn’t going to be sufficient.