 
 uint UByte(uint _input, uint index)
 	{return (_input >> 8u*index) & 0x000000FFu;}
-
-vec4 codeTexel(uvec2 texelXY, uint textureID, uint subTexV4Idx, uint subTexV4Sub, uint subTexV4Addr, uint startCode){
+	
+CompositeTexel cMix(CompositeTexel left, CompositeTexel right, float amt){
+ CompositeTexel result;
+ result.rgba = mix(left.rgba,right.rgba,amt);
+ result.ESTuTv = mix(left.ESTuTv,right.ESTuTv,amt);
+ return result;
+}
+
+CompositeTexel codeTexel(uvec2 texelXY, uint textureID, uint subTexV4Idx, uint subTexV4Sub, uint subTexV4Addr, uint startCode){
  // Codebook
  uint	codeIdx		= UByte((texelFetch(rootBuffer,int(subTexV4Idx+subTexV4Addr))[subTexV4Sub/4u]),subTexV4Sub%4u)+startCode;
  uint	codeBkPgNum	= codeIdx / CODES_PER_CODE_PAGE;
  uvec2	codeXY		= texelXY%4u;
  vec2	subTexUVsub	= codeXY*CODE_PAGE_TEXEL_SIZE_UV;
  ivec2	codePgXY	= ivec2(codeIdx % CODE_PAGE_SIDE_WIDTH_CODES,(codeIdx / CODE_PAGE_SIDE_WIDTH_CODES)%CODE_PAGE_SIDE_WIDTH_CODES)*4+ivec2(codeXY);
- return	texelFetch(rgbaTiles,ivec3(codePgXY,codeBkPgNum),0);
+ CompositeTexel result;
+ result.rgba  = texelFetch(rgbaTiles,ivec3(codePgXY,codeBkPgNum),0);
+ result.ESTuTv= texelFetch(ESTuTvTiles,ivec3(codePgXY,codeBkPgNum),0);  
+ return	result;
  }
  
  vec4 intrinsicCodeTexel(uint textureID,vec3 norm,vec2 uv){

 	vec2	codeXY		= stXY%4u;
 	vec2	subTexUVsub	= codeXY*CODE_PAGE_TEXEL_SIZE_UV;
 	vec2	codePgXY	= vec2(codeIdx % CODE_PAGE_SIDE_WIDTH_CODES,(codeIdx / CODE_PAGE_SIDE_WIDTH_CODES)%CODE_PAGE_SIDE_WIDTH_CODES)*4+codeXY+sub;
 	cTexel				= textureLod(rgbaTiles,vec3(codePgXY*CODE_PAGE_TEXEL_SIZE_UV,codeBkPgNum),0);
 	vec4 illumination;
 	if(dot(norm.xyz,norm.xyz)>.01)illumination.rgb
 								=((clamp(-dot(sunVector,norm),0,1)*sunColor)+ambientLight);
 	return cTexel * illumination;
    }else{
     subTexV4Addr = uvec4(stv4a);
     }

uniform sampler2D		primitiveUVZWTexture;
uniform sampler2D		primitivenXnYnZTexture;
uniform sampler2DArray 	rgbaTiles;
uniform sampler2DArray	ESTuTvTiles;
uniform sampler2D		layerAccumulator;
uniform usamplerBuffer 	rootBuffer; 	//Global memory, as a set of uint vec4s.
uniform samplerCube 	cubeTexture;
