Проблема с GLSL не работает, как я намеревался [закрыто]JAVA

Программисты JAVA общаются здесь
Anonymous
Проблема с GLSL не работает, как я намеревался [закрыто]

Сообщение Anonymous »

Итак, мне было интересно, не воссоздано ли это?#version 420 core

uniform sampler2D texture1;
uniform sampler2D texture2;

in vec2 uv;

out vec4 fragColor;

void main(){
//fragColor = texture(texture1, uv);
fragColor = texture(texture2, uv);
}
< /code>
выглядит простым правильно, но теперь, когда я берут себя за собой // fragcolor = texture (Texture1, UV), и сохраняю остальные, я получаю текстуру1, отображаемую на экран. ПОЧЕМУ ? Мой мозг говорит, что это неправильно, разве это не должно только отображать текстуру2, потому что я переопределяю Fragcolor? IDK может кто -нибудь это объяснить? Texture_2d
и его формат. texType = samples > 1 ? GL_TEXTURE_2D_MULTISAMPLE : GL_TEXTURE_2D;

int format;
if (channels == 3) {
format = GL_RGB;
} else if (channels == 4) {
format = GL_RGBA;
} else {
throw new AspectGraphicsException("textures can't be initialized with " + channels + " channels");
}

ID = glGenTextures();

glBindTexture(texType, ID);

glTexParameteri(texType,
GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(texType,
GL_TEXTURE_MAG_FILTER, interpolation ? GL_LINEAR : GL_NEAREST);

glTexParameteri(texType, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(texType, GL_TEXTURE_WRAP_T, GL_REPEAT);

if (samples > 1) {
if (pixels == null) {
glTexImage2DMultisample(texType, samples, format,
width, height, true);
} else {
throw new AspectGraphicsException("textures with defined with pixels can't be multisampled");
}
} else {
if (pixels == null) {
glTexImage2D(texType, 0, format, width, height,
0, format, GL_UNSIGNED_BYTE, NULL);
} else {
glTexImage2D(texType, 0, format,
width, height, 0, format,
GL_UNSIGNED_BYTE, pixels);
}
}
glBindTexture(texType, 0);
< /code>
Привязывание текстуры:
textype - это просто gl_texture_2d
, а Samplername - это «Texture1» или «Texture2» (см. В шейдере GLSL)
, а Sampler просто для «Texture1»: 0 и для «Texture2»: 1 < /p>

glActiveTexture(GL_TEXTURE0 + sampler);
glBindTexture(texType, ID);
shader.uniform1i(samplerName, sampler);


Подробнее здесь: https://stackoverflow.com/questions/653 ... i-intended

Вернуться в «JAVA»