2
OpenGL 3+에서 C++을 사용하여 텍스처 툰 쉐이더를 구현하려고하는데 일주일 후 텍스쳐가없는 툰 쉐이드 만 있습니다.텍스처가있는 툰 쉐이더
정점 파일 :
#version 330
// Incoming per vertex... position and normal
in vec4 vVertex;
in vec3 vNormal;
smooth out float textureCoordinate;
uniform vec3 vLightPosition;
uniform mat4 mvpMatrix;
uniform mat4 mvMatrix;
uniform mat3 normalMatrix;
void main(void)
{
// Get surface normal in eye coordinates
vec3 vEyeNormal = normalMatrix * vNormal;
// Get vertex position in eye coordinates
vec4 vPosition4 = mvMatrix * vVertex;
vec3 vPosition3 = vPosition4.xyz/vPosition4.w;
// Get vector to light source
vec3 vLightDir = normalize(vLightPosition - vPosition3);
// Dot product gives us diffuse intensity
textureCoordinate = max(0.0, dot(vEyeNormal, vLightDir));
// Don't forget to transform the geometry!
gl_Position = mvpMatrix * vVertex;
}
조각 파일 :
//
#version 330
uniform sampler1D colorTable;
out vec4 vFragColor;
smooth in float textureCoordinate;
void main(void)
{
vFragColor = texture(colorTable, textureCoordinate);
}
사람이 나에게 텍스처 작업이 쉐이더를 얻기 위해 손을 줄 수 있습니까?
답은 thx이지만 modelTexture는 무엇입니까? vec4 vTexture0에 추가했습니다. vec2 vTexCoords를 부드럽게; 주요 vTexCoords = vTexture0.st; vec2 vTexCoords에서 매끄러운 쉐이드에 버텍스 쉐이더를 사용; 및 vFragColor = texture (colorTable, textureCoordinate) * texture (?????, vTexCoords); 작동 가능한 예제를 제공 할 수 있습니까? 고마워 – Winter