Set the perspective projection for projective texture mapping. Change the demo to two bears with the same view projection matrix for the camera and the projector.

This commit is contained in:
yunfeibai
2018-02-20 18:32:09 -08:00
parent ef0ae4935b
commit 5494aa72fa
6 changed files with 53 additions and 58 deletions

View File

@@ -9,7 +9,7 @@ static const char* projectiveTextureInstancingVertexShader= \
"layout (location = 4) in vec3 vertexnormal;\n"
"layout (location = 5) in vec4 instance_color;\n"
"layout (location = 6) in vec3 instance_scale;\n"
"uniform mat4 DepthBiasModelViewProjectionMatrix;\n"
"uniform mat4 TextureMVP;\n"
"uniform mat4 MVP;\n"
"uniform vec3 lightPosIn;\n"
"uniform vec3 cameraPositionIn;\n"
@@ -80,7 +80,7 @@ static const char* projectiveTextureInstancingVertexShader= \
" vec4 vertexLoc = MVP* vec4((instance_position+localcoord).xyz,1);\n"
" gl_Position = vertexLoc;\n"
" fragment.color = instance_color;\n"
" vec4 projcoords = DepthBiasModelViewProjectionMatrix * vec4((instance_position+localcoord).xyz,1);\n"
" vert.texcoord = projcoords.xy;\n"
" vec4 projcoords = TextureMVP * vec4((instance_position+localcoord).xyz,1);\n"
" vert.texcoord = projcoords.xy/projcoords.z;\n"
"}\n"
;