LINUX.ORG.RU

[openGL]Не понимаю, как 1 матрица может заменить 2?

 


0

1

OpenGL super bible 5th edition

The Default Light Shader

This shader creates the illusion of a single diffuse light source located at the eye position. Essentially, it makes things look shaded and lit. Uniforms needed are the modelview matrix, the projection matrix, and the color value to use as the base color. Required attributes are GLT_ATTRIBUTE_VERTEX and GLT_ATTRIBUTE_NORMAL. Most lighting shaders require the normal matrix as a uniform. This shader derives the normal matrix from the modelview matrix—convenient, but not terribly efficient. Bear that in mind for performance-sensitive applications.

GLShaderManager::UseStockShader(GLT_SHADER_DEFAULT_LIGHT, GLfloat mvMatrix[16], GLfloat pMatrix[16], GLfloat vColor[4]);

Texture Replace Shader

This shader transforms geometry by the given modelview projection matrix and uses the texture bound to the texture unit specified in nTextureUnit. Fragment colors are taken directly from the texture sample. Attributes used are GLT_ATTRIBUTE_VERTEX and GLT_ATTRIBUTE_TEXTURE0.

GLShaderManager::UseStockShader(GLT_SHADER_TEXTURE_REPLACE, GLfloat mvpMatrix[16], GLint nTextureUnit);

В первом случае в шейдер передаются 2 матрицы 4х4, во втором одна, и при этом сразу и modelview, и projection. Как такое может быть? Или на самом деле это только видовая? Если что, о шейдерах пока представление только на уровне «что они делают и зачем»

★★★★

Ответ на: комментарий от Raving_Zealot

Это понятно. а почему тогда всюду не передавать произведение? Что теряется при умножении?

wingear ★★★★
() автор топика
Ответ на: комментарий от wingear

Если я правильно понимаю вопрос, то обработка нормалей требует 2 матриц. Для самих вершин, да, достаточно 1.

Kirakishou
()
Ответ на: комментарий от wingear

В первом случае modelview матрица нужна для трансформации нормалей.
Собственно, в 0-ом посте все написано.

Raving_Zealot ★★
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.