Code
const float4x4 matWorldViewProj;
const float4x4 matWorld; 
texture entSkin1; 

// Color map sampler
sampler ColorMapSampler = sampler_state 
{ 
   Texture = <entSkin1>; 

}; 
    
// Vertex Shader: 
void DiffuseVS( 
   in float4 InPos: POSITION, 
   in float3 InNormal: NORMAL, 
   in float2 InTex: TEXCOORD0, 
   out float4 OutPos: POSITION, 
   out float2 OutTex: TEXCOORD0, 
   out float3 OutNormal: TEXCOORD1) 
{ 
   OutPos = mul(InPos, matWorldViewProj); 
   OutPos /= OutPos.w;
   OutNormal = normalize(mul(InNormal, matWorld));
   OutTex = InTex; 
} 
    
// Pixel Shader: 
float4 DiffusePS( 
   in float2 InTex: TEXCOORD0, 
   in float3 InNormal: TEXCOORD1): COLOR 
{ 
   return tex2D(ColorMapSampler, InTex); 
} 
 
// Technique: 
technique AffineTechnique 
{ 
   pass P0 
   { 
      VertexShader = compile vs_2_0 DiffuseVS(); 
      PixelShader  = compile ps_2_0 DiffusePS(); 
   } 
} 


Just the most basic texture mapping, no lights, no sun, no ambient. Only difference is OutPos /= OutPos.w; line.

Explanation here: https://webglfundamentals.org/webgl/lessons/webgl-3d-perspective-correct-texturemapping.html

Last edited by Quad; 02/25/20 21:39.

3333333333