Fixed a bug in projective texture shader.

This commit is contained in:
YunfeiBai
2018-05-03 10:46:59 -07:00
parent b032a1fd60
commit aa6b8f66e9
2 changed files with 2 additions and 2 deletions

View File

@@ -22,7 +22,7 @@ out vec4 color;
void main(void) void main(void)
{ {
vec4 projcoords = TextureMVP * vertexPos; vec4 projcoords = TextureMVP * vertexPos;
vec2 texturecoords = projcoords.xy/max(projcoords.z,0.1); vec2 texturecoords = projcoords.xy/projcoords.w;
vec4 texel = fragment.color*texture(Diffuse,texturecoords); vec4 texel = fragment.color*texture(Diffuse,texturecoords);
vec3 ct,cf; vec3 ct,cf;
float intensity,at,af; float intensity,at,af;

View File

@@ -18,7 +18,7 @@ static const char* projectiveTextureInstancingFragmentShader= \
"void main(void)\n" "void main(void)\n"
"{\n" "{\n"
" vec4 projcoords = TextureMVP * vertexPos;\n" " vec4 projcoords = TextureMVP * vertexPos;\n"
" vec2 texturecoords = projcoords.xy/max(projcoords.z,0.1);\n" " vec2 texturecoords = projcoords.xy/projcoords.w;\n"
" vec4 texel = fragment.color*texture(Diffuse,texturecoords);\n" " vec4 texel = fragment.color*texture(Diffuse,texturecoords);\n"
" vec3 ct,cf;\n" " vec3 ct,cf;\n"
" float intensity,at,af;\n" " float intensity,at,af;\n"