if (gEnvMapEnable) {
float3 s = 0;
// float r = pow(saturate(smoothstep(0.0, 80.0, cSpe.a)), 2); // Specular to reflection mapping
float r = pow(saturate(smoothstep(0.0, 80.0, 100.0)), 2); // Specular to reflection mapping, ignores "flag" in mesh
float b = (1.0-r)*0.04; // blur
float3 v = normalize(reflect(-CamW, nrmW));
s += texCUBE(EnvMapS, v);
s += texCUBE(EnvMapS, v+float3(b,b,0));
s += texCUBE(EnvMapS, v+float3(0,b,b));
s += texCUBE(EnvMapS, v+float3(b,0,b));
spec += s*(r*0.25);
}
if (gUseEmis) diff += tex2D(EmisS, frg.tex0).rgb;
// -------------------------------------------------------------------------
float3 tempColor = cTex.rgb * saturate(diff);
float3 color = 0.2 * (saturate(spec) - tempColor) + tempColor; // the multiplying factor 0.2 controls how
// intense the reflection is; 0.0=matte, 1.0=mirror
// float3 color = cTex.rgb * saturate(diff) + saturate(spec); // Standard lighting
// float3 color = 1.0f - exp(-1.0f*(cTex.rgb*diff+spec)); // "HDR" lighting
// -------------------------------------------------------------------------