|  | @@ -269,6 +269,8 @@ void tnsShaderMakeIndex(tnsShader *tns){
 | 
											
												
													
														|  |      if(tns->iTexColor>=0){glUniform1i(tns->iTexColor, 0);}
 |  |      if(tns->iTexColor>=0){glUniform1i(tns->iTexColor, 0);}
 | 
											
												
													
														|  |      if(tns->iTexColorMS>=0){glUniform1i(tns->iTexColorMS, 1);}
 |  |      if(tns->iTexColorMS>=0){glUniform1i(tns->iTexColorMS, 1);}
 | 
											
												
													
														|  |      tns->iDoOffset = glGetUniformLocation(program, "DoOffset");
 |  |      tns->iDoOffset = glGetUniformLocation(program, "DoOffset");
 | 
											
												
													
														|  | 
 |  | +    tns->iUseHalftone = glGetUniformLocation(program, "UseHalftone");
 | 
											
												
													
														|  | 
 |  | +    tns->iHalftoneSize = glGetUniformLocation(program, "HalftoneSize");
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      tns->uViewDir = glGetUniformLocation(program, "uViewDir");
 |  |      tns->uViewDir = glGetUniformLocation(program, "uViewDir");
 | 
											
												
													
														|  |      tns->uViewPos = glGetUniformLocation(program, "uViewPos");
 |  |      tns->uViewPos = glGetUniformLocation(program, "uViewPos");
 | 
											
										
											
												
													
														|  | @@ -1574,7 +1576,7 @@ int tnsDrawBatch(tnsBatch* batch, const char* OverrideCommand, real* OverrideUni
 | 
											
												
													
														|  |      if(cs->iNormal>=0){
 |  |      if(cs->iNormal>=0){
 | 
											
												
													
														|  |          if(batch->HasNormal){
 |  |          if(batch->HasNormal){
 | 
											
												
													
														|  |              glBindBuffer(GL_ARRAY_BUFFER, batch->NBO); glEnableVertexAttribArray(cs->iNormal);
 |  |              glBindBuffer(GL_ARRAY_BUFFER, batch->NBO); glEnableVertexAttribArray(cs->iNormal);
 | 
											
												
													
														|  | -            glVertexAttribPointer(cs->iNormal, batch->NormalDimension, GL_FLOAT, 0, 0, 0); tnsUniformUseNormal(cs,T->SetUseNormal);
 |  | 
 | 
											
												
													
														|  | 
 |  | +            glVertexAttribPointer(cs->iNormal, batch->NormalDimension, GL_FLOAT, 0, 0, 0); tnsUniformUseNormal(cs,T->StateUseNormal);
 | 
											
												
													
														|  |          }else{ glDisableVertexAttribArray(cs->iNormal); glVertexAttrib3f(cs->iNormal,0,0,1); tnsUniformUseNormal(cs,0); }
 |  |          }else{ glDisableVertexAttribArray(cs->iNormal); glVertexAttrib3f(cs->iNormal,0,0,1); tnsUniformUseNormal(cs,0); }
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |      if(cs->iColor>=0){
 |  |      if(cs->iColor>=0){
 | 
											
										
											
												
													
														|  | @@ -1709,24 +1711,32 @@ void tnsConfigure3DTexture(tnsTexture *t){
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  void tnsReconfigureTextureParameters(int Multisample){
 |  |  void tnsReconfigureTextureParameters(int Multisample){
 | 
											
												
													
														|  |      laListHandle* l = tKnlGetTextureList();
 |  |      laListHandle* l = tKnlGetTextureList();
 | 
											
												
													
														|  | -    for(tnsOffscreen* o=T->Offscreens.pFirst;o;o=o->Item.pNext){
 |  | 
 | 
											
												
													
														|  | -        tnsTexture* t=o->pColor[0];
 |  | 
 | 
											
												
													
														|  | -        if(t){
 |  | 
 | 
											
												
													
														|  | 
 |  | +    for(tnsOffscreen* o=T->Offscreens.pFirst;o;o=o->Item.pNext){ tnsTexture* t;
 | 
											
												
													
														|  | 
 |  | +        for(int i=0;i<4;i++){
 | 
											
												
													
														|  | 
 |  | +            t=o->pColor[i];
 | 
											
												
													
														|  | 
 |  | +            if(t){
 | 
											
												
													
														|  | 
 |  | +                t->Multisample = Multisample;
 | 
											
												
													
														|  | 
 |  | +                int recreate=0;
 | 
											
												
													
														|  | 
 |  | +                if(t->Multisample){ if(t->GLTexType==GL_TEXTURE_2D){t->GLTexType=GL_TEXTURE_2D_MULTISAMPLE; recreate=1;}}
 | 
											
												
													
														|  | 
 |  | +                else { if(t->GLTexType==GL_TEXTURE_2D_MULTISAMPLE){t->GLTexType=GL_TEXTURE_2D; recreate=1;}}
 | 
											
												
													
														|  | 
 |  | +                if(recreate){
 | 
											
												
													
														|  | 
 |  | +                    glDeleteTextures(1, &t->GLTexHandle);
 | 
											
												
													
														|  | 
 |  | +                    glGenTextures(1, &t->GLTexHandle);
 | 
											
												
													
														|  | 
 |  | +                }
 | 
											
												
													
														|  | 
 |  | +                T->TexColor=0;
 | 
											
												
													
														|  | 
 |  | +                tnsConfigure2DTexture(t);
 | 
											
												
													
														|  | 
 |  | +                tnsAttach2DOffscreenBuffer(o, GL_COLOR_ATTACHMENT0+i, t);
 | 
											
												
													
														|  | 
 |  | +            }
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +        t=o->pDepth;
 | 
											
												
													
														|  | 
 |  | +        if(t){ int recreate=0; 
 | 
											
												
													
														|  | 
 |  | +            if((!t->Multisample && Multisample)||(t->Multisample && !Multisample)){ recreate=1; }
 | 
											
												
													
														|  | 
 |  | +            if(Multisample){ t->GLTexType=GL_TEXTURE_2D_MULTISAMPLE; }else{ t->GLTexType=GL_TEXTURE_2D; }
 | 
											
												
													
														|  |              t->Multisample = Multisample;
 |  |              t->Multisample = Multisample;
 | 
											
												
													
														|  | -            int recreate=0;
 |  | 
 | 
											
												
													
														|  | -            if(t->Multisample){ if(t->GLTexType==GL_TEXTURE_2D){t->GLTexType=GL_TEXTURE_2D_MULTISAMPLE; recreate=1;}}
 |  | 
 | 
											
												
													
														|  | -            else { if(t->GLTexType==GL_TEXTURE_2D_MULTISAMPLE){t->GLTexType=GL_TEXTURE_2D; recreate=1;}}
 |  | 
 | 
											
												
													
														|  |              if(recreate){
 |  |              if(recreate){
 | 
											
												
													
														|  |                  glDeleteTextures(1, &t->GLTexHandle);
 |  |                  glDeleteTextures(1, &t->GLTexHandle);
 | 
											
												
													
														|  |                  glGenTextures(1, &t->GLTexHandle);
 |  |                  glGenTextures(1, &t->GLTexHandle);
 | 
											
												
													
														|  | -            }
 |  | 
 | 
											
												
													
														|  | -            T->TexColor=0;
 |  | 
 | 
											
												
													
														|  | -            tnsConfigure2DTexture(t);
 |  | 
 | 
											
												
													
														|  | -            tnsAttach2DOffscreenBuffer(o, GL_COLOR_ATTACHMENT0, t);
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | -        t=o->pDepth;
 |  | 
 | 
											
												
													
														|  | -        if(t){
 |  | 
 | 
											
												
													
														|  | -            t->Multisample = Multisample; T->TexColor=0;
 |  | 
 | 
											
												
													
														|  | 
 |  | +            } T->TexColor=0;
 | 
											
												
													
														|  |              tnsConfigure2DTexture(t);
 |  |              tnsConfigure2DTexture(t);
 | 
											
												
													
														|  |              tnsAttach2DOffscreenBuffer(o, GL_DEPTH_ATTACHMENT, t);
 |  |              tnsAttach2DOffscreenBuffer(o, GL_DEPTH_ATTACHMENT, t);
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
										
											
												
													
														|  | @@ -1776,9 +1786,16 @@ void tnsUseMultiplyColor(int enable){
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  void tnsUniformUseNormal(tnsShader* s, int Use){
 |  |  void tnsUniformUseNormal(tnsShader* s, int Use){
 | 
											
												
													
														|  | -    if(T->StateUseNormal!=Use){ T->StateUseNormal=Use; glUniform1i(s->iUseNormal,Use); }
 |  | 
 | 
											
												
													
														|  | 
 |  | +    if(T->SetUseNormal!=Use){ T->SetUseNormal=Use; glUniform1i(s->iUseNormal,Use); }
 | 
											
												
													
														|  | 
 |  | +}
 | 
											
												
													
														|  | 
 |  | +void tnsUseNormal(int Use){ T->StateUseNormal=Use; }
 | 
											
												
													
														|  | 
 |  | +void tnsUniformUseHalftone(tnsShader* s, real Use){
 | 
											
												
													
														|  | 
 |  | +    if(T->SetUseHalftone!=Use){ T->SetUseHalftone=Use; glUniform1f(s->iUseHalftone,Use); }
 | 
											
												
													
														|  | 
 |  | +}
 | 
											
												
													
														|  | 
 |  | +void tnsUniformHalftoneSize(tnsShader* s, real Use){
 | 
											
												
													
														|  | 
 |  | +    if(T->SetHalftoneSize!=Use){ T->SetHalftoneSize=Use; glUniform1f(s->iHalftoneSize,Use); }
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  | -void tnsUseNormal(int Use){ T->SetUseNormal=Use; }
 |  | 
 | 
											
												
													
														|  | 
 |  | +void tnsUseHalftone(real Factor){ T->StateUseHalftone=Factor; }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  void tnsActiveTexture(GLenum tex){
 |  |  void tnsActiveTexture(GLenum tex){
 | 
											
												
													
														|  |      if (T->GlTextureSets != tex) glActiveTexture(tex);
 |  |      if (T->GlTextureSets != tex) glActiveTexture(tex);
 | 
											
										
											
												
													
														|  | @@ -2220,6 +2237,7 @@ void tnsPackAs(GLenum Mode){
 | 
											
												
													
														|  |      c->MultiplyColor = T->StateMultiplyColor;
 |  |      c->MultiplyColor = T->StateMultiplyColor;
 | 
											
												
													
														|  |      c->LineWidth=T->StateLineWidth;
 |  |      c->LineWidth=T->StateLineWidth;
 | 
											
												
													
														|  |      c->PointSize=T->StatePointSize;
 |  |      c->PointSize=T->StatePointSize;
 | 
											
												
													
														|  | 
 |  | +    c->UseHalftone = T->StateUseHalftone;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      memset(nc, 0, sizeof(tnsCommand));
 |  |      memset(nc, 0, sizeof(tnsCommand));
 | 
											
												
													
														|  |      nc->VertBegin = nc->VertEnd = c->VertEnd;
 |  |      nc->VertBegin = nc->VertEnd = c->VertEnd;
 | 
											
										
											
												
													
														|  | @@ -2315,8 +2333,10 @@ void tnsFlush(){
 | 
											
												
													
														|  |              tnsUniformUseTexture(cs, 0, 0); //tnsUnbindTexture(); 
 |  |              tnsUniformUseTexture(cs, 0, 0); //tnsUnbindTexture(); 
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -        if(cs->iMultiplyColor != -1){
 |  | 
 | 
											
												
													
														|  | -            tnsUniformUseMultiplyColor(cs, c->MultiplyColor);
 |  | 
 | 
											
												
													
														|  | 
 |  | +        if(cs->iMultiplyColor != -1){ tnsUniformUseMultiplyColor(cs, c->MultiplyColor); }
 | 
											
												
													
														|  | 
 |  | +        if(cs->iUseHalftone != -1){
 | 
											
												
													
														|  | 
 |  | +            tnsUniformUseHalftone(cs, c->UseHalftone);
 | 
											
												
													
														|  | 
 |  | +            tnsUniformHalftoneSize(cs, MAIN.ViewportHalftoneSize);
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |          if (c->UseIndex){
 |  |          if (c->UseIndex){
 |