mirror of
https://github.com/RetroDECK/Supermodel.git
synced 2025-04-10 19:15:14 +00:00
Shift fog maths to fragment shader to fix bug in virtua on.
This commit is contained in:
parent
bddc86aba9
commit
62d9584b0d
|
@ -8,9 +8,6 @@ static const char *vertexShaderR3D = R"glsl(
|
||||||
#version 120
|
#version 120
|
||||||
|
|
||||||
// uniforms
|
// uniforms
|
||||||
uniform float fogIntensity;
|
|
||||||
uniform float fogDensity;
|
|
||||||
uniform float fogStart;
|
|
||||||
uniform float modelScale;
|
uniform float modelScale;
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
|
@ -22,7 +19,6 @@ attribute vec3 inFaceNormal; // used to emulate r3d culling
|
||||||
attribute float inFixedShade;
|
attribute float inFixedShade;
|
||||||
|
|
||||||
// outputs to fragment shader
|
// outputs to fragment shader
|
||||||
varying float fsFogFactor;
|
|
||||||
varying vec3 fsViewVertex;
|
varying vec3 fsViewVertex;
|
||||||
varying vec3 fsViewNormal; // per vertex normal vector
|
varying vec3 fsViewNormal; // per vertex normal vector
|
||||||
varying vec2 fsTexCoord;
|
varying vec2 fsTexCoord;
|
||||||
|
@ -43,9 +39,6 @@ void main(void)
|
||||||
{
|
{
|
||||||
fsViewVertex = vec3(gl_ModelViewMatrix * inVertex);
|
fsViewVertex = vec3(gl_ModelViewMatrix * inVertex);
|
||||||
fsViewNormal = (mat3(gl_ModelViewMatrix) * inNormal) / modelScale;
|
fsViewNormal = (mat3(gl_ModelViewMatrix) * inNormal) / modelScale;
|
||||||
float z = -fsViewVertex.z;
|
|
||||||
fsFogFactor = fogIntensity * (fogStart + z * fogDensity);
|
|
||||||
|
|
||||||
fsDiscard = CalcBackFace(fsViewVertex);
|
fsDiscard = CalcBackFace(fsViewVertex);
|
||||||
fsColor = inColour;
|
fsColor = inColour;
|
||||||
fsTexCoord = inTexCoord;
|
fsTexCoord = inTexCoord;
|
||||||
|
@ -83,6 +76,9 @@ uniform bool intensityClamp; // some games such as daytona and
|
||||||
uniform bool specularEnabled; // specular enabled
|
uniform bool specularEnabled; // specular enabled
|
||||||
uniform float specularValue; // specular coefficient
|
uniform float specularValue; // specular coefficient
|
||||||
uniform float shininess; // specular shininess
|
uniform float shininess; // specular shininess
|
||||||
|
uniform float fogIntensity;
|
||||||
|
uniform float fogDensity;
|
||||||
|
uniform float fogStart;
|
||||||
uniform float fogAttenuation;
|
uniform float fogAttenuation;
|
||||||
uniform float fogAmbient;
|
uniform float fogAmbient;
|
||||||
uniform bool fixedShading;
|
uniform bool fixedShading;
|
||||||
|
@ -141,6 +137,14 @@ void Step15Luminous(inout vec4 colour)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float CalcFog()
|
||||||
|
{
|
||||||
|
float z = -fsViewVertex.z;
|
||||||
|
float fog = fogIntensity * clamp(fogStart + z * fogDensity, 0.0, 1.0);
|
||||||
|
|
||||||
|
return fog;
|
||||||
|
}
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec4 tex1Data;
|
vec4 tex1Data;
|
||||||
|
@ -152,7 +156,7 @@ void main()
|
||||||
discard; //emulate back face culling here
|
discard; //emulate back face culling here
|
||||||
}
|
}
|
||||||
|
|
||||||
fogData = vec4(fogColour.rgb * fogAmbient, clamp(fsFogFactor,0.0,1.0));
|
fogData = vec4(fogColour.rgb * fogAmbient, CalcFog());
|
||||||
tex1Data = vec4(1.0, 1.0, 1.0, 1.0);
|
tex1Data = vec4(1.0, 1.0, 1.0, 1.0);
|
||||||
|
|
||||||
if(textureEnabled) {
|
if(textureEnabled) {
|
||||||
|
|
Loading…
Reference in a new issue