2022-09-19 18:05:01 +08:00

16 lines
574 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

precision mediump float;
varying vec4 ambient;
varying vec4 diffuse;
varying vec4 specular;
varying float vFogFactor; //雾因子
void main()
{
vec4 objectColor=vec4(0.95,0.95,0.95,1.0);//物体颜色
vec4 fogColor = vec4(0.97,0.76,0.03,1.0);//雾的颜色
if(vFogFactor != 0.0){//如果雾因子为0不必计算光照
objectColor = objectColor*ambient+objectColor*specular+objectColor*diffuse;//计算光照之后物体颜色
gl_FragColor = objectColor*vFogFactor + fogColor*(1.0-vFogFactor);//物体颜色和雾颜色插值计算最终颜色
}else{
gl_FragColor=fogColor;
}
}