mirror of
https://github.com/RetroDECK/Supermodel.git
synced 2024-11-22 05:45:38 +00:00
Daytona seems to use this completely undocumented feature of the real3d pro-1000, the ability to invert texture colours. This patch fixes the colours on the cars, and the signs which should flash by alternating their colours.
This commit is contained in:
parent
cc32e0bf8e
commit
edfb521a9b
|
@ -68,6 +68,7 @@ struct Mesh
|
||||||
int format, x, y, width, height = 0;
|
int format, x, y, width, height = 0;
|
||||||
bool mirrorU = false;
|
bool mirrorU = false;
|
||||||
bool mirrorV = false;
|
bool mirrorV = false;
|
||||||
|
bool inverted = false;
|
||||||
|
|
||||||
// microtexture
|
// microtexture
|
||||||
bool microTexture = false;
|
bool microTexture = false;
|
||||||
|
|
|
@ -1004,6 +1004,7 @@ void CNew3D::SetMeshValues(SortingMesh *currentMesh, PolyHeader &ph)
|
||||||
currentMesh->mirrorU = ph.TexUMirror();
|
currentMesh->mirrorU = ph.TexUMirror();
|
||||||
currentMesh->mirrorV = ph.TexVMirror();
|
currentMesh->mirrorV = ph.TexVMirror();
|
||||||
currentMesh->microTexture = ph.MicroTexture();
|
currentMesh->microTexture = ph.MicroTexture();
|
||||||
|
currentMesh->inverted = ph.TranslatorMapOffset() == 2;
|
||||||
|
|
||||||
if (currentMesh->microTexture) {
|
if (currentMesh->microTexture) {
|
||||||
|
|
||||||
|
|
|
@ -362,6 +362,11 @@ bool PolyHeader::HighPriority()
|
||||||
return (header[6] & 0x10) > 0;
|
return (header[6] & 0x10) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int PolyHeader::TranslatorMapOffset()
|
||||||
|
{
|
||||||
|
return (header[6] >> 24) & 0x7f;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// misc
|
// misc
|
||||||
//
|
//
|
||||||
|
|
|
@ -141,6 +141,7 @@ public:
|
||||||
bool TextureAlpha();
|
bool TextureAlpha();
|
||||||
bool Luminous();
|
bool Luminous();
|
||||||
float LightModifier();
|
float LightModifier();
|
||||||
|
int TranslatorMapOffset();
|
||||||
|
|
||||||
// misc
|
// misc
|
||||||
UINT64 Hash(); // make a unique hash for sorting by state
|
UINT64 Hash(); // make a unique hash for sorting by state
|
||||||
|
|
|
@ -2,163 +2,166 @@
|
||||||
#include "Graphics/Shader.h"
|
#include "Graphics/Shader.h"
|
||||||
|
|
||||||
namespace New3D {
|
namespace New3D {
|
||||||
|
|
||||||
static const char *vertexShaderBasic =
|
static const char *vertexShaderR3D =
|
||||||
|
|
||||||
// uniforms
|
// uniforms
|
||||||
"uniform float fogIntensity;\n"
|
"uniform float fogIntensity;\n"
|
||||||
"uniform float fogDensity;\n"
|
"uniform float fogDensity;\n"
|
||||||
"uniform float fogStart;\n"
|
"uniform float fogStart;\n"
|
||||||
|
|
||||||
//outputs to fragment shader
|
//outputs to fragment shader
|
||||||
"varying float fsFogFactor;\n"
|
"varying float fsFogFactor;\n"
|
||||||
"varying vec3 fsViewVertex;\n"
|
"varying vec3 fsViewVertex;\n"
|
||||||
"varying vec3 fsViewNormal;\n" // per vertex normal vector
|
"varying vec3 fsViewNormal;\n" // per vertex normal vector
|
||||||
"varying vec4 fsColor;\n"
|
"varying vec4 fsColor;\n"
|
||||||
|
|
||||||
"void main(void)\n"
|
"void main(void)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"fsViewVertex = vec3(gl_ModelViewMatrix * gl_Vertex);\n"
|
"fsViewVertex = vec3(gl_ModelViewMatrix * gl_Vertex);\n"
|
||||||
"fsViewNormal = normalize(gl_NormalMatrix *gl_Normal);\n"
|
"fsViewNormal = normalize(gl_NormalMatrix *gl_Normal);\n"
|
||||||
"float z = length(fsViewVertex);\n"
|
"float z = length(fsViewVertex);\n"
|
||||||
"fsFogFactor = fogIntensity * clamp(fogStart + z * fogDensity, 0.0, 1.0);\n"
|
"fsFogFactor = fogIntensity * clamp(fogStart + z * fogDensity, 0.0, 1.0);\n"
|
||||||
|
|
||||||
"fsColor = gl_Color;\n"
|
"fsColor = gl_Color;\n"
|
||||||
"gl_TexCoord[0] = gl_MultiTexCoord0;\n"
|
"gl_TexCoord[0] = gl_MultiTexCoord0;\n"
|
||||||
"gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
|
"gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
static const char *fragmentShaderBasic =
|
static const char *fragmentShaderR3D =
|
||||||
|
|
||||||
"uniform sampler2D tex1;\n" // base tex
|
"uniform sampler2D tex1;\n" // base tex
|
||||||
"uniform sampler2D tex2;\n" // micro tex (optional)
|
"uniform sampler2D tex2;\n" // micro tex (optional)
|
||||||
|
|
||||||
"uniform int textureEnabled;\n"
|
"uniform bool textureEnabled;\n"
|
||||||
"uniform int microTexture;\n"
|
"uniform bool microTexture;\n"
|
||||||
"uniform float microTextureScale;\n"
|
"uniform float microTextureScale;\n"
|
||||||
"uniform vec2 baseTexSize;\n"
|
"uniform vec2 baseTexSize;\n"
|
||||||
"uniform int alphaTest;\n"
|
"uniform bool texureInverted;\n"
|
||||||
"uniform int textureAlpha;\n"
|
"uniform bool alphaTest;\n"
|
||||||
|
"uniform bool textureAlpha;\n"
|
||||||
"uniform vec3 fogColour;\n"
|
"uniform vec3 fogColour;\n"
|
||||||
"uniform vec4 spotEllipse;\n" // spotlight ellipse position: .x=X position (screen coordinates), .y=Y position, .z=half-width, .w=half-height)
|
"uniform vec4 spotEllipse;\n" // spotlight ellipse position: .x=X position (screen coordinates), .y=Y position, .z=half-width, .w=half-height)
|
||||||
"uniform vec2 spotRange;\n" // spotlight Z range: .x=start (viewspace coordinates), .y=limit
|
"uniform vec2 spotRange;\n" // spotlight Z range: .x=start (viewspace coordinates), .y=limit
|
||||||
"uniform vec3 spotColor;\n" // spotlight RGB color
|
"uniform vec3 spotColor;\n" // spotlight RGB color
|
||||||
"uniform vec3 spotFogColor;\n" // spotlight RGB color on fog
|
"uniform vec3 spotFogColor;\n" // spotlight RGB color on fog
|
||||||
"uniform vec3 lighting[2];\n" // lighting state (lighting[0] = sun direction, lighting[1].x,y = diffuse, ambient intensities from 0-1.0)
|
"uniform vec3 lighting[2];\n" // lighting state (lighting[0] = sun direction, lighting[1].x,y = diffuse, ambient intensities from 0-1.0)
|
||||||
"uniform int lightEnable;\n" // lighting enabled (1.0) or luminous (0.0), drawn at full intensity
|
"uniform bool lightEnable;\n" // lighting enabled (1.0) or luminous (0.0), drawn at full intensity
|
||||||
"uniform float specularCoefficient;\n" // specular coefficient
|
"uniform float specularCoefficient;\n" // specular coefficient
|
||||||
"uniform float shininess;\n" // specular shininess
|
"uniform float shininess;\n" // specular shininess
|
||||||
"uniform float fogAttenuation;\n"
|
"uniform float fogAttenuation;\n"
|
||||||
"uniform float fogAmbient;\n"
|
"uniform float fogAmbient;\n"
|
||||||
|
|
||||||
//interpolated inputs from vertex shader
|
//interpolated inputs from vertex shader
|
||||||
"varying float fsFogFactor;\n"
|
"varying float fsFogFactor;\n"
|
||||||
"varying vec3 fsViewVertex;\n"
|
"varying vec3 fsViewVertex;\n"
|
||||||
"varying vec3 fsViewNormal;\n" // per vertex normal vector
|
"varying vec3 fsViewNormal;\n" // per vertex normal vector
|
||||||
"varying vec4 fsColor;\n"
|
"varying vec4 fsColor;\n"
|
||||||
|
|
||||||
|
"vec4 GetTextureValue()\n"
|
||||||
|
"{\n"
|
||||||
|
"vec4 tex1Data = texture2D( tex1, gl_TexCoord[0].st);\n"
|
||||||
|
|
||||||
|
"if(texureInverted) {\n"
|
||||||
|
"tex1Data.rgb = vec3(1.0) - vec3(tex1Data.rgb);\n"
|
||||||
|
"}\n"
|
||||||
|
|
||||||
|
"if (microTexture) {\n"
|
||||||
|
"vec2 scale = baseTexSize/256.0;\n"
|
||||||
|
"vec4 tex2Data = texture2D( tex2, gl_TexCoord[0].st * scale * microTextureScale);\n"
|
||||||
|
"tex1Data = (tex1Data+tex2Data)/2.0;\n"
|
||||||
|
"}\n"
|
||||||
|
|
||||||
|
"if (alphaTest) {\n"
|
||||||
|
"if (tex1Data.a < (8.0/16.0)) {\n"
|
||||||
|
"discard;\n"
|
||||||
|
"}\n"
|
||||||
|
"}\n"
|
||||||
|
|
||||||
|
"if (textureAlpha == false) {\n"
|
||||||
|
"tex1Data.a = 1.0;\n"
|
||||||
|
"}\n"
|
||||||
|
|
||||||
|
"return tex1Data;\n"
|
||||||
|
"}"
|
||||||
|
|
||||||
"void main()\n"
|
"void main()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"vec4 tex1Data;\n"
|
"vec4 tex1Data;\n"
|
||||||
"vec4 colData;\n"
|
"vec4 colData;\n"
|
||||||
"vec4 finalData;\n"
|
"vec4 finalData;\n"
|
||||||
"vec4 fogData;\n"
|
"vec4 fogData;\n"
|
||||||
|
|
||||||
"bool discardFragment = false;\n"
|
|
||||||
|
|
||||||
"fogData = vec4(fogColour.rgb * fogAmbient, fsFogFactor);\n"
|
|
||||||
|
|
||||||
"tex1Data = vec4(1.0, 1.0, 1.0, 1.0);\n"
|
|
||||||
|
|
||||||
"if(textureEnabled==1) {\n"
|
|
||||||
|
|
||||||
"tex1Data = texture2D( tex1, gl_TexCoord[0].st);\n"
|
|
||||||
|
|
||||||
"if (microTexture==1) {\n"
|
|
||||||
"vec2 scale = baseTexSize/256.0;\n"
|
|
||||||
"vec4 tex2Data = texture2D( tex2, gl_TexCoord[0].st * scale * microTextureScale);\n"
|
|
||||||
|
|
||||||
"tex1Data = (tex1Data+tex2Data)/2.0;\n"
|
|
||||||
"}\n"
|
|
||||||
|
|
||||||
"if (alphaTest==1) {\n" // does it make any sense to do this later?
|
"fogData = vec4(fogColour.rgb * fogAmbient, fsFogFactor);\n"
|
||||||
"if (tex1Data.a < (8.0/16.0)) {\n"
|
"tex1Data = vec4(1.0, 1.0, 1.0, 1.0);\n"
|
||||||
"discardFragment = true;\n"
|
|
||||||
"}\n"
|
|
||||||
"}\n"
|
|
||||||
|
|
||||||
"if (textureAlpha == 0) {\n"
|
"if(textureEnabled) {\n"
|
||||||
"tex1Data.a = 1.0;\n"
|
"tex1Data = GetTextureValue();\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"}\n"
|
|
||||||
|
|
||||||
"colData = fsColor;\n"
|
"colData = fsColor;\n"
|
||||||
|
"finalData = tex1Data * colData;\n"
|
||||||
|
|
||||||
"finalData = tex1Data * colData;\n"
|
"if (finalData.a < (1.0/16.0)) {\n" // basically chuck out any totally transparent pixels value = 1/16 the smallest transparency level h/w supports
|
||||||
"if (finalData.a < (1.0/16.0)) {\n" // basically chuck out any totally transparent pixels value = 1/16 the smallest transparency level h/w supports
|
"discard;\n"
|
||||||
"discardFragment = true;\n"
|
"}\n"
|
||||||
"}\n"
|
|
||||||
|
|
||||||
"if (discardFragment) {\n"
|
"float ellipse;\n"
|
||||||
"discard;\n"
|
"ellipse = length((gl_FragCoord.xy - spotEllipse.xy) / spotEllipse.zw);\n"
|
||||||
"}\n"
|
"ellipse = pow(ellipse, 2.0);\n" // decay rate = square of distance from center
|
||||||
|
"ellipse = 1.0 - ellipse;\n" // invert
|
||||||
"float ellipse;\n"
|
"ellipse = max(0.0, ellipse);\n" // clamp
|
||||||
"ellipse = length((gl_FragCoord.xy - spotEllipse.xy) / spotEllipse.zw);\n"
|
|
||||||
"ellipse = pow(ellipse, 2.0);\n" // decay rate = square of distance from center
|
|
||||||
"ellipse = 1.0 - ellipse;\n" // invert
|
|
||||||
"ellipse = max(0.0, ellipse);\n" // clamp
|
|
||||||
|
|
||||||
"if (lightEnable==1) {\n"
|
|
||||||
"vec3 lightIntensity;\n"
|
|
||||||
"vec3 sunVector;\n" // sun lighting vector (as reflecting away from vertex)
|
|
||||||
"float sunFactor;\n" // sun light projection along vertex normal (0.0 to 1.0)
|
|
||||||
|
|
||||||
// Real3D -> OpenGL view space convention (TO-DO: do this outside of shader)
|
"if (lightEnable) {\n"
|
||||||
"sunVector = lighting[0] * vec3(1.0, -1.0, -1.0);\n"
|
"vec3 lightIntensity;\n"
|
||||||
|
"vec3 sunVector;\n" // sun lighting vector (as reflecting away from vertex)
|
||||||
|
"float sunFactor;\n" // sun light projection along vertex normal (0.0 to 1.0)
|
||||||
|
|
||||||
// Compute diffuse factor for sunlight
|
// Real3D -> OpenGL view space convention (TO-DO: do this outside of shader)
|
||||||
"sunFactor = max(dot(sunVector, fsViewNormal), 0.0);\n"
|
"sunVector = lighting[0] * vec3(1.0, -1.0, -1.0);\n"
|
||||||
|
|
||||||
// Total light intensity: sum of all components
|
// Compute diffuse factor for sunlight
|
||||||
"lightIntensity = vec3(sunFactor*lighting[1].x + lighting[1].y);\n" // ambient + diffuse
|
"sunFactor = max(dot(sunVector, fsViewNormal), 0.0);\n"
|
||||||
|
|
||||||
"lightIntensity = clamp(lightIntensity,0.0,1.0);\n"
|
// Total light intensity: sum of all components
|
||||||
|
"lightIntensity = vec3(sunFactor*lighting[1].x + lighting[1].y);\n" // ambient + diffuse
|
||||||
// Compute spotlight and apply lighting
|
|
||||||
"float enable, range, d;\n"
|
"lightIntensity = clamp(lightIntensity,0.0,1.0);\n"
|
||||||
"float inv_r = 1.0 / spotEllipse.z;\n" // slope of decay function
|
|
||||||
|
// Compute spotlight and apply lighting
|
||||||
"d = spotRange.x + spotRange.y + fsViewVertex.z;\n"
|
"float enable, range, d;\n"
|
||||||
"enable = step(spotRange.x + min(spotRange.y, 0.0), -fsViewVertex.z);\n"
|
"float inv_r = 1.0 / spotEllipse.z;\n" // slope of decay function
|
||||||
|
|
||||||
// inverse-linear falloff
|
"d = spotRange.x + spotRange.y + fsViewVertex.z;\n"
|
||||||
// Reference: https://imdoingitwrong.wordpress.com/2011/01/31/light-attenuation/
|
"enable = step(spotRange.x + min(spotRange.y, 0.0), -fsViewVertex.z);\n"
|
||||||
// y = 1 / (d/r + 1)^2
|
|
||||||
"range = 1.0 / pow(min(0.0, d * inv_r) - 1.0, 2.0);\n"
|
// inverse-linear falloff
|
||||||
"range = clamp(range, 0.0, 1.0);\n"
|
// Reference: https://imdoingitwrong.wordpress.com/2011/01/31/light-attenuation/
|
||||||
"range *= enable;\n"
|
// y = 1 / (d/r + 1)^2
|
||||||
|
"range = 1.0 / pow(min(0.0, d * inv_r) - 1.0, 2.0);\n"
|
||||||
"float lobeEffect = range * ellipse;\n"
|
"range = clamp(range, 0.0, 1.0);\n"
|
||||||
|
"range *= enable;\n"
|
||||||
"lightIntensity.rgb += spotColor*lobeEffect;\n"
|
|
||||||
|
"float lobeEffect = range * ellipse;\n"
|
||||||
"finalData.rgb *= lightIntensity;\n"
|
|
||||||
|
"lightIntensity.rgb += spotColor*lobeEffect;\n"
|
||||||
"if (sunFactor > 0.0 && specularCoefficient > 0.0) {\n"
|
|
||||||
"float nDotL = max(dot(fsViewNormal,sunVector),0.0);\n"
|
"finalData.rgb *= lightIntensity;\n"
|
||||||
"finalData.rgb += vec3(specularCoefficient * pow(nDotL,shininess));\n"
|
|
||||||
"}\n"
|
"if (sunFactor > 0.0 && specularCoefficient > 0.0) {\n"
|
||||||
"}\n"
|
"float nDotL = max(dot(fsViewNormal,sunVector),0.0);\n"
|
||||||
|
"finalData.rgb += vec3(specularCoefficient * pow(nDotL,shininess));\n"
|
||||||
// Spotlight on fog
|
"}\n"
|
||||||
"vec3 lSpotFogColor = spotFogColor * ellipse * fogColour.rgb;\n"
|
"}\n"
|
||||||
|
|
||||||
// Fog & spotlight applied
|
// Spotlight on fog
|
||||||
"finalData.rgb = mix(finalData.rgb, lSpotFogColor * fogAttenuation + fogData.rgb, fogData.a);\n"
|
"vec3 lSpotFogColor = spotFogColor * ellipse * fogColour.rgb;\n"
|
||||||
|
|
||||||
"gl_FragColor = finalData;\n"
|
// Fog & spotlight applied
|
||||||
"}\n";
|
"finalData.rgb = mix(finalData.rgb, lSpotFogColor * fogAttenuation + fogData.rgb, fogData.a);\n"
|
||||||
|
|
||||||
|
"gl_FragColor = finalData;\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
R3DShader::R3DShader()
|
R3DShader::R3DShader()
|
||||||
{
|
{
|
||||||
|
@ -171,13 +174,14 @@ R3DShader::R3DShader()
|
||||||
|
|
||||||
void R3DShader::Start()
|
void R3DShader::Start()
|
||||||
{
|
{
|
||||||
m_textured1 = false;
|
m_textured1 = false;
|
||||||
m_textured2 = false;
|
m_textured2 = false;
|
||||||
m_textureAlpha = false; // use alpha in texture
|
m_textureAlpha = false; // use alpha in texture
|
||||||
m_alphaTest = false; // discard fragment based on alpha (ogl does this with fixed function)
|
m_alphaTest = false; // discard fragment based on alpha (ogl does this with fixed function)
|
||||||
m_doubleSided = false;
|
m_doubleSided = false;
|
||||||
m_lightEnabled = false;
|
m_lightEnabled = false;
|
||||||
m_layered = false;
|
m_layered = false;
|
||||||
|
m_textureInverted = false;
|
||||||
|
|
||||||
m_baseTexSize[0] = 0;
|
m_baseTexSize[0] = 0;
|
||||||
m_baseTexSize[1] = 0;
|
m_baseTexSize[1] = 0;
|
||||||
|
@ -202,14 +206,14 @@ bool R3DShader::LoadShader(const char* vertexShader, const char* fragmentShader)
|
||||||
vShader = vertexShader;
|
vShader = vertexShader;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
vShader = vertexShaderBasic;
|
vShader = vertexShaderR3D;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fragmentShader) {
|
if (fragmentShader) {
|
||||||
fShader = fragmentShader;
|
fShader = fragmentShader;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fShader = fragmentShaderBasic;
|
fShader = fragmentShaderR3D;
|
||||||
}
|
}
|
||||||
|
|
||||||
success = LoadShaderProgram(&m_shaderProgram, &m_vertexShader, &m_fragmentShader, std::string(), std::string(), vShader, fShader);
|
success = LoadShaderProgram(&m_shaderProgram, &m_vertexShader, &m_fragmentShader, std::string(), std::string(), vShader, fShader);
|
||||||
|
@ -222,25 +226,26 @@ bool R3DShader::LoadShader(const char* vertexShader, const char* fragmentShader)
|
||||||
m_locAlphaTest = glGetUniformLocation(m_shaderProgram, "alphaTest");
|
m_locAlphaTest = glGetUniformLocation(m_shaderProgram, "alphaTest");
|
||||||
m_locMicroTexScale = glGetUniformLocation(m_shaderProgram, "microTextureScale");
|
m_locMicroTexScale = glGetUniformLocation(m_shaderProgram, "microTextureScale");
|
||||||
m_locBaseTexSize = glGetUniformLocation(m_shaderProgram, "baseTexSize");
|
m_locBaseTexSize = glGetUniformLocation(m_shaderProgram, "baseTexSize");
|
||||||
|
m_locTextureInverted= glGetUniformLocation(m_shaderProgram, "texureInverted");
|
||||||
|
|
||||||
m_locFogIntensity = glGetUniformLocation(m_shaderProgram, "fogIntensity");
|
m_locFogIntensity = glGetUniformLocation(m_shaderProgram, "fogIntensity");
|
||||||
m_locFogDensity = glGetUniformLocation(m_shaderProgram, "fogDensity");
|
m_locFogDensity = glGetUniformLocation(m_shaderProgram, "fogDensity");
|
||||||
m_locFogStart = glGetUniformLocation(m_shaderProgram, "fogStart");
|
m_locFogStart = glGetUniformLocation(m_shaderProgram, "fogStart");
|
||||||
m_locFogColour = glGetUniformLocation(m_shaderProgram, "fogColour");
|
m_locFogColour = glGetUniformLocation(m_shaderProgram, "fogColour");
|
||||||
m_locFogAttenuation = glGetUniformLocation(m_shaderProgram, "fogAttenuation");
|
m_locFogAttenuation = glGetUniformLocation(m_shaderProgram, "fogAttenuation");
|
||||||
m_locFogAmbient = glGetUniformLocation(m_shaderProgram, "fogAmbient");
|
m_locFogAmbient = glGetUniformLocation(m_shaderProgram, "fogAmbient");
|
||||||
|
|
||||||
m_locLighting = glGetUniformLocation(m_shaderProgram, "lighting");
|
m_locLighting = glGetUniformLocation(m_shaderProgram, "lighting");
|
||||||
m_locLightEnable = glGetUniformLocation(m_shaderProgram, "lightEnable");
|
m_locLightEnable = glGetUniformLocation(m_shaderProgram, "lightEnable");
|
||||||
m_locShininess = glGetUniformLocation(m_shaderProgram, "shininess");
|
m_locShininess = glGetUniformLocation(m_shaderProgram, "shininess");
|
||||||
m_locSpecCoefficient= glGetUniformLocation(m_shaderProgram, "specularCoefficient");
|
m_locSpecCoefficient= glGetUniformLocation(m_shaderProgram, "specularCoefficient");
|
||||||
m_locSpotEllipse = glGetUniformLocation(m_shaderProgram, "spotEllipse");
|
m_locSpotEllipse = glGetUniformLocation(m_shaderProgram, "spotEllipse");
|
||||||
m_locSpotRange = glGetUniformLocation(m_shaderProgram, "spotRange");
|
m_locSpotRange = glGetUniformLocation(m_shaderProgram, "spotRange");
|
||||||
m_locSpotColor = glGetUniformLocation(m_shaderProgram, "spotColor");
|
m_locSpotColor = glGetUniformLocation(m_shaderProgram, "spotColor");
|
||||||
m_locSpotFogColor = glGetUniformLocation(m_shaderProgram, "spotFogColor");
|
m_locSpotFogColor = glGetUniformLocation(m_shaderProgram, "spotFogColor");
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
void R3DShader::SetShader(bool enable)
|
void R3DShader::SetShader(bool enable)
|
||||||
{
|
{
|
||||||
|
@ -285,6 +290,11 @@ void R3DShader::SetMeshUniforms(const Mesh* m)
|
||||||
glUniform2fv(m_locBaseTexSize, 1, m_baseTexSize);
|
glUniform2fv(m_locBaseTexSize, 1, m_baseTexSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_dirtyMesh || m->inverted != m_textureInverted) {
|
||||||
|
glUniform1i(m_locTextureInverted, m->inverted);
|
||||||
|
m_textureInverted = m->inverted;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_dirtyMesh || m->alphaTest != m_alphaTest) {
|
if (m_dirtyMesh || m->alphaTest != m_alphaTest) {
|
||||||
glUniform1i(m_locAlphaTest, m->alphaTest);
|
glUniform1i(m_locAlphaTest, m->alphaTest);
|
||||||
m_alphaTest = m->alphaTest;
|
m_alphaTest = m->alphaTest;
|
||||||
|
@ -347,20 +357,20 @@ void R3DShader::SetMeshUniforms(const Mesh* m)
|
||||||
void R3DShader::SetViewportUniforms(const Viewport *vp)
|
void R3DShader::SetViewportUniforms(const Viewport *vp)
|
||||||
{
|
{
|
||||||
//didn't bother caching these, they don't get frequently called anyway
|
//didn't bother caching these, they don't get frequently called anyway
|
||||||
glUniform1f (m_locFogDensity, vp->fogParams[3]);
|
glUniform1f (m_locFogDensity, vp->fogParams[3]);
|
||||||
glUniform1f (m_locFogStart, vp->fogParams[4]);
|
glUniform1f (m_locFogStart, vp->fogParams[4]);
|
||||||
glUniform3fv(m_locFogColour, 1, vp->fogParams);
|
glUniform3fv(m_locFogColour, 1, vp->fogParams);
|
||||||
glUniform1f (m_locFogAttenuation, vp->fogParams[5]);
|
glUniform1f (m_locFogAttenuation, vp->fogParams[5]);
|
||||||
glUniform1f (m_locFogAmbient, vp->fogParams[6]);
|
glUniform1f (m_locFogAmbient, vp->fogParams[6]);
|
||||||
|
|
||||||
glUniform3fv(m_locLighting, 2, vp->lightingParams);
|
glUniform3fv(m_locLighting, 2, vp->lightingParams);
|
||||||
glUniform4fv(m_locSpotEllipse, 1, vp->spotEllipse);
|
glUniform4fv(m_locSpotEllipse, 1, vp->spotEllipse);
|
||||||
glUniform2fv(m_locSpotRange, 1, vp->spotRange);
|
glUniform2fv(m_locSpotRange, 1, vp->spotRange);
|
||||||
glUniform3fv(m_locSpotColor, 1, vp->spotColor);
|
glUniform3fv(m_locSpotColor, 1, vp->spotColor);
|
||||||
glUniform3fv(m_locSpotFogColor, 1, vp->spotFogColor);
|
glUniform3fv(m_locSpotFogColor, 1, vp->spotFogColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void R3DShader::SetModelStates(const Model* model)
|
void R3DShader::SetModelStates(const Model* model)
|
||||||
{
|
{
|
||||||
//==========
|
//==========
|
||||||
MatDet test;
|
MatDet test;
|
||||||
|
|
|
@ -34,6 +34,7 @@ private:
|
||||||
GLint m_locAlphaTest;
|
GLint m_locAlphaTest;
|
||||||
GLint m_locMicroTexScale;
|
GLint m_locMicroTexScale;
|
||||||
GLint m_locBaseTexSize;
|
GLint m_locBaseTexSize;
|
||||||
|
GLint m_locTextureInverted;
|
||||||
|
|
||||||
// cached mesh values
|
// cached mesh values
|
||||||
bool m_textured1;
|
bool m_textured1;
|
||||||
|
@ -48,6 +49,7 @@ private:
|
||||||
bool m_layered;
|
bool m_layered;
|
||||||
float m_microTexScale;
|
float m_microTexScale;
|
||||||
float m_baseTexSize[2];
|
float m_baseTexSize[2];
|
||||||
|
bool m_textureInverted;
|
||||||
|
|
||||||
// cached model values
|
// cached model values
|
||||||
enum class MatDet { notset, negative, positive, zero };
|
enum class MatDet { notset, negative, positive, zero };
|
||||||
|
@ -59,23 +61,23 @@ private:
|
||||||
|
|
||||||
// viewport uniform locations
|
// viewport uniform locations
|
||||||
GLint m_locFogIntensity;
|
GLint m_locFogIntensity;
|
||||||
GLint m_locFogDensity;
|
GLint m_locFogDensity;
|
||||||
GLint m_locFogStart;
|
GLint m_locFogStart;
|
||||||
GLint m_locFogColour;
|
GLint m_locFogColour;
|
||||||
GLint m_locFogAttenuation;
|
GLint m_locFogAttenuation;
|
||||||
GLint m_locFogAmbient;
|
GLint m_locFogAmbient;
|
||||||
|
|
||||||
// lighting
|
// lighting
|
||||||
GLint m_locLighting;
|
GLint m_locLighting;
|
||||||
GLint m_locLightEnable;
|
GLint m_locLightEnable;
|
||||||
GLint m_locShininess;
|
GLint m_locShininess;
|
||||||
GLint m_locSpecCoefficient;
|
GLint m_locSpecCoefficient;
|
||||||
GLint m_locSpotEllipse;
|
GLint m_locSpotEllipse;
|
||||||
GLint m_locSpotRange;
|
GLint m_locSpotRange;
|
||||||
GLint m_locSpotColor;
|
GLint m_locSpotColor;
|
||||||
GLint m_locSpotFogColor;
|
GLint m_locSpotFogColor;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // New3D
|
} // New3D
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -307,7 +307,6 @@ xcopy /D /Y "$(ProjectDir)\SDL\$(Platform)\$(Configuration)\SDL.dll" "$(TargetDi
|
||||||
<ClCompile Include="..\Src\Debugger\SupermodelDebugger.cpp" />
|
<ClCompile Include="..\Src\Debugger\SupermodelDebugger.cpp" />
|
||||||
<ClCompile Include="..\Src\Debugger\Watch.cpp" />
|
<ClCompile Include="..\Src\Debugger\Watch.cpp" />
|
||||||
<ClCompile Include="..\Src\GameLoader.cpp" />
|
<ClCompile Include="..\Src\GameLoader.cpp" />
|
||||||
<ClCompile Include="..\Src\Games.cpp" />
|
|
||||||
<ClCompile Include="..\Src\Graphics\Legacy3D\Error.cpp" />
|
<ClCompile Include="..\Src\Graphics\Legacy3D\Error.cpp" />
|
||||||
<ClCompile Include="..\Src\Graphics\Legacy3D\Legacy3D.cpp" />
|
<ClCompile Include="..\Src\Graphics\Legacy3D\Legacy3D.cpp" />
|
||||||
<ClCompile Include="..\Src\Graphics\Legacy3D\Models.cpp" />
|
<ClCompile Include="..\Src\Graphics\Legacy3D\Models.cpp" />
|
||||||
|
@ -325,7 +324,6 @@ xcopy /D /Y "$(ProjectDir)\SDL\$(Platform)\$(Configuration)\SDL.dll" "$(TargetDi
|
||||||
<ClCompile Include="..\Src\Graphics\New3D\Vec.cpp" />
|
<ClCompile Include="..\Src\Graphics\New3D\Vec.cpp" />
|
||||||
<ClCompile Include="..\Src\Graphics\Render2D.cpp" />
|
<ClCompile Include="..\Src\Graphics\Render2D.cpp" />
|
||||||
<ClCompile Include="..\Src\Graphics\Shader.cpp" />
|
<ClCompile Include="..\Src\Graphics\Shader.cpp" />
|
||||||
<ClCompile Include="..\Src\INIFile.cpp" />
|
|
||||||
<ClCompile Include="..\Src\Inputs\Input.cpp" />
|
<ClCompile Include="..\Src\Inputs\Input.cpp" />
|
||||||
<ClCompile Include="..\Src\Inputs\Inputs.cpp" />
|
<ClCompile Include="..\Src\Inputs\Inputs.cpp" />
|
||||||
<ClCompile Include="..\Src\Inputs\InputSource.cpp" />
|
<ClCompile Include="..\Src\Inputs\InputSource.cpp" />
|
||||||
|
@ -373,7 +371,6 @@ xcopy /D /Y "$(ProjectDir)\SDL\$(Platform)\$(Configuration)\SDL.dll" "$(TargetDi
|
||||||
<ExceptionHandling Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ExceptionHandling Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
</ExceptionHandling>
|
</ExceptionHandling>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\Src\ROMLoad.cpp" />
|
|
||||||
<ClCompile Include="..\Src\Sound\MPEG\audio.cpp">
|
<ClCompile Include="..\Src\Sound\MPEG\audio.cpp">
|
||||||
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(IntDir)amp_%(Filename).obj</ObjectFileName>
|
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(IntDir)amp_%(Filename).obj</ObjectFileName>
|
||||||
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(IntDir)amp_%(Filename).obj</ObjectFileName>
|
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(IntDir)amp_%(Filename).obj</ObjectFileName>
|
||||||
|
@ -534,7 +531,6 @@ xcopy /D /Y "$(ProjectDir)\SDL\$(Platform)\$(Configuration)\SDL.dll" "$(TargetDi
|
||||||
<ClInclude Include="..\Src\Debugger\SupermodelDebugger.h" />
|
<ClInclude Include="..\Src\Debugger\SupermodelDebugger.h" />
|
||||||
<ClInclude Include="..\Src\Debugger\Watch.h" />
|
<ClInclude Include="..\Src\Debugger\Watch.h" />
|
||||||
<ClInclude Include="..\Src\GameLoader.h" />
|
<ClInclude Include="..\Src\GameLoader.h" />
|
||||||
<ClInclude Include="..\Src\Games.h" />
|
|
||||||
<ClInclude Include="..\Src\Graphics\IRender3D.h" />
|
<ClInclude Include="..\Src\Graphics\IRender3D.h" />
|
||||||
<ClInclude Include="..\Src\Graphics\Legacy3D\Legacy3D.h" />
|
<ClInclude Include="..\Src\Graphics\Legacy3D\Legacy3D.h" />
|
||||||
<ClInclude Include="..\Src\Graphics\Legacy3D\Shaders3D.h" />
|
<ClInclude Include="..\Src\Graphics\Legacy3D\Shaders3D.h" />
|
||||||
|
@ -555,7 +551,6 @@ xcopy /D /Y "$(ProjectDir)\SDL\$(Platform)\$(Configuration)\SDL.dll" "$(TargetDi
|
||||||
<ClInclude Include="..\Src\Graphics\Render2D.h" />
|
<ClInclude Include="..\Src\Graphics\Render2D.h" />
|
||||||
<ClInclude Include="..\Src\Graphics\Shader.h" />
|
<ClInclude Include="..\Src\Graphics\Shader.h" />
|
||||||
<ClInclude Include="..\Src\Graphics\Shaders2D.h" />
|
<ClInclude Include="..\Src\Graphics\Shaders2D.h" />
|
||||||
<ClInclude Include="..\Src\INIFile.h" />
|
|
||||||
<ClInclude Include="..\Src\Inputs\Input.h" />
|
<ClInclude Include="..\Src\Inputs\Input.h" />
|
||||||
<ClInclude Include="..\Src\Inputs\Inputs.h" />
|
<ClInclude Include="..\Src\Inputs\Inputs.h" />
|
||||||
<ClInclude Include="..\Src\Inputs\InputSource.h" />
|
<ClInclude Include="..\Src\Inputs\InputSource.h" />
|
||||||
|
@ -591,7 +586,6 @@ xcopy /D /Y "$(ProjectDir)\SDL\$(Platform)\$(Configuration)\SDL.dll" "$(TargetDi
|
||||||
<ClInclude Include="..\Src\Pkgs\tinyxml2.h" />
|
<ClInclude Include="..\Src\Pkgs\tinyxml2.h" />
|
||||||
<ClInclude Include="..\Src\Pkgs\unzip.h" />
|
<ClInclude Include="..\Src\Pkgs\unzip.h" />
|
||||||
<ClInclude Include="..\Src\Pkgs\wglew.h" />
|
<ClInclude Include="..\Src\Pkgs\wglew.h" />
|
||||||
<ClInclude Include="..\Src\ROMLoad.h" />
|
|
||||||
<ClInclude Include="..\Src\Sound\MPEG\amp.h" />
|
<ClInclude Include="..\Src\Sound\MPEG\amp.h" />
|
||||||
<ClInclude Include="..\Src\Sound\MPEG\audio.h" />
|
<ClInclude Include="..\Src\Sound\MPEG\audio.h" />
|
||||||
<ClInclude Include="..\Src\Sound\MPEG\config.h" />
|
<ClInclude Include="..\Src\Sound\MPEG\config.h" />
|
||||||
|
|
|
@ -137,15 +137,6 @@
|
||||||
<ClCompile Include="..\Src\BlockFile.cpp">
|
<ClCompile Include="..\Src\BlockFile.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\Src\Games.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\Src\INIFile.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\Src\ROMLoad.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\Src\CPU\PowerPC\ppc.cpp">
|
<ClCompile Include="..\Src\CPU\PowerPC\ppc.cpp">
|
||||||
<Filter>Source Files\CPU\PowerPC</Filter>
|
<Filter>Source Files\CPU\PowerPC</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -490,15 +481,6 @@
|
||||||
<ClInclude Include="..\Src\BlockFile.h">
|
<ClInclude Include="..\Src\BlockFile.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\Src\Games.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\Src\INIFile.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\Src\ROMLoad.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\Src\Supermodel.h">
|
<ClInclude Include="..\Src\Supermodel.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
|
Loading…
Reference in a new issue