mirror of
https://github.com/RetroDECK/Supermodel.git
synced 2025-03-06 14:27:44 +00:00
Fixed fog in legacy 3D engine. Now computed same as new engine, with 4-bit light modifier and corrected fog mixing in shaders.
This commit is contained in:
parent
6dc35f9563
commit
a0910f96fb
|
@ -686,10 +686,8 @@ void CLegacy3D::InsertVertex(ModelCache *Cache, const Vertex *V, const Poly *P,
|
|||
if ((P->header[6]&0x00800000)) // if set, polygon is opaque
|
||||
translucence = 1.0f;
|
||||
|
||||
// Fog intensity (for luminous polygons)
|
||||
GLfloat fogIntensity = (GLfloat) ((P->header[6]>>11)&0x1F) * (1.0f/31.0f);
|
||||
if (!(P->header[6]&0x00010000)) // if not luminous, always use full fog intensity
|
||||
fogIntensity = 1.0f;
|
||||
// Fog intensity (apparently used for both luminous and shaded polygons)
|
||||
GLfloat fogIntensity = (GLfloat) ((P->header[6]>>11)&0x1F) * (1.0f/15.0f); // only 4 bits seem to actually be used?
|
||||
|
||||
/*
|
||||
* Contour processing. Any alpha value sufficiently close to 0 seems to
|
||||
|
|
|
@ -186,8 +186,8 @@ void main(void)
|
|||
// Translucency (modulates existing alpha channel for RGBA4 texels)
|
||||
fragColor.a *= fsTransLevel;
|
||||
|
||||
// Apply fog under the control of fog factor setting from polygon header
|
||||
fragColor.rgb = mix(gl_Fog.color.rgb, fragColor.rgb, fsFogFactor);
|
||||
// Apply fog
|
||||
fragColor.rgb = mix(fragColor.rgb, gl_Fog.color.rgb, fsFogFactor);
|
||||
|
||||
// Store final color
|
||||
gl_FragColor = fragColor;
|
||||
|
|
|
@ -46,7 +46,7 @@ uniform float mapSize; // texture map size (2048,4096,6144 etc)
|
|||
// Inputs from vertex shader
|
||||
varying vec4 fsSubTexture; // .x=texture X, .y=texture Y, .z=texture width, .w=texture height (all in texels)
|
||||
varying vec4 fsTexParams; // .x=texture enable (if 1, else 0), .y=use transparency (if > 0), .z=U wrap mode (1=mirror, 0=repeat), .w=V wrap mode
|
||||
varying float fsTexFormat; // T1RGB5 contour texture (if > 0)
|
||||
varying float fsTexFormat; // T1RGB5 contour texture (if > 0)
|
||||
varying float fsTexMap; // texture map number
|
||||
varying float fsTransLevel; // translucence level, 0.0 (transparent) to 1.0 (opaque)
|
||||
varying vec3 fsLightIntensity; // lighting intensity
|
||||
|
@ -231,8 +231,8 @@ void main(void)
|
|||
// Translucency (modulates existing alpha channel for RGBA4 texels)
|
||||
fragColor.a *= fsTransLevel;
|
||||
|
||||
// Apply fog under the control of fog factor setting from polygon header
|
||||
fragColor.rgb = mix(gl_Fog.color.rgb, fragColor.rgb, fsFogFactor);
|
||||
// Apply fog
|
||||
fragColor.rgb = mix(fragColor.rgb, gl_Fog.color.rgb, fsFogFactor);
|
||||
|
||||
// Store final color
|
||||
gl_FragColor = fragColor;
|
||||
|
|
|
@ -194,7 +194,7 @@ void main(void)
|
|||
|
||||
// Fog
|
||||
float z = length(viewVertex);
|
||||
fsFogFactor = clamp(1.0-fogIntensity*(gl_Fog.start+z*gl_Fog.density), 0.0, 1.0);
|
||||
fsFogFactor = fogIntensity*clamp(gl_Fog.start+z*gl_Fog.density, 0.0, 1.0);
|
||||
|
||||
// Pass viewspace Z coordinate (for spotlight)
|
||||
fsViewZ = -viewVertex.z; // convert Z from GL->Real3D convention (want +Z to be further into screen)
|
||||
|
|
|
@ -229,7 +229,7 @@ static const char vertexShaderSource[] =
|
|||
" \n"
|
||||
" // Fog\n"
|
||||
" float z = length(viewVertex);\n"
|
||||
" fsFogFactor = clamp(1.0-fogIntensity*(gl_Fog.start+z*gl_Fog.density), 0.0, 1.0);\n"
|
||||
" fsFogFactor = fogIntensity*clamp(gl_Fog.start+z*gl_Fog.density, 0.0, 1.0);\n"
|
||||
"\n"
|
||||
" // Pass viewspace Z coordinate (for spotlight)\n"
|
||||
" fsViewZ = -viewVertex.z; // convert Z from GL->Real3D convention (want +Z to be further into screen)\n"
|
||||
|
@ -436,8 +436,8 @@ static const char fragmentShaderSingleSheetSource[] =
|
|||
" // Translucency (modulates existing alpha channel for RGBA4 texels)\n"
|
||||
" fragColor.a *= fsTransLevel;\n"
|
||||
"\n"
|
||||
" // Apply fog under the control of fog factor setting from polygon header\n"
|
||||
" fragColor.rgb = mix(gl_Fog.color.rgb, fragColor.rgb, fsFogFactor);\n"
|
||||
" // Apply fog\n"
|
||||
" fragColor.rgb = mix(fragColor.rgb, gl_Fog.color.rgb, fsFogFactor);\n"
|
||||
"\n"
|
||||
" // Store final color\n"
|
||||
" gl_FragColor = fragColor;\n"
|
||||
|
@ -681,8 +681,8 @@ static const char fragmentShaderMultiSheetSource[] =
|
|||
" // Translucency (modulates existing alpha channel for RGBA4 texels)\n"
|
||||
" fragColor.a *= fsTransLevel;\n"
|
||||
"\n"
|
||||
" // Apply fog under the control of fog factor setting from polygon header\n"
|
||||
" fragColor.rgb = mix(gl_Fog.color.rgb, fragColor.rgb, fsFogFactor);\n"
|
||||
" // Apply fog\n"
|
||||
" fragColor.rgb = mix(fragColor.rgb, gl_Fog.color.rgb, fsFogFactor);\n"
|
||||
"\n"
|
||||
" // Store final color\n"
|
||||
" gl_FragColor = fragColor;\n"
|
||||
|
|
Loading…
Reference in a new issue