mirror of
https://github.com/RetroDECK/Supermodel.git
synced 2024-11-22 13:55:38 +00:00
convert sun angle coordinate system outside of the shader
This commit is contained in:
parent
97781108e8
commit
ec3872d108
|
@ -763,9 +763,9 @@ void CNew3D::RenderViewport(UINT32 addr)
|
|||
CalcFrustumPlanes(m_planes, vp->projectionMatrix); // we need to calc a 'projection matrix' to get the correct frustum planes for clipping
|
||||
|
||||
// Lighting (note that sun vector points toward sun -- away from vertex)
|
||||
vp->lightingParams[0] = *(float *)&vpnode[0x05]; // sun X
|
||||
vp->lightingParams[1] = *(float *)&vpnode[0x06]; // sun Y
|
||||
vp->lightingParams[2] = *(float *)&vpnode[0x04]; // sun Z
|
||||
vp->lightingParams[0] = *(float *)&vpnode[0x05]; // sun X
|
||||
vp->lightingParams[1] = -*(float *)&vpnode[0x06]; // sun Y (- to convert to ogl cordinate system)
|
||||
vp->lightingParams[2] = -*(float *)&vpnode[0x04]; // sun Z (- to convert to ogl cordinate system)
|
||||
vp->lightingParams[3] = std::max(0.f, std::min(*(float *)&vpnode[0x07], 1.0f)); // sun intensity (clamp to 0-1)
|
||||
vp->lightingParams[4] = (float)((vpnode[0x24] >> 8) & 0xFF) * (1.0f / 255.0f); // ambient intensity
|
||||
vp->lightingParams[5] = 0.0; // reserved
|
||||
|
@ -1186,9 +1186,12 @@ void CNew3D::CacheModel(Model *m, const UINT32 *data)
|
|||
else {
|
||||
if (ph.SpecularEnabled()) {
|
||||
shade = (ix & 0xFF) / 255.f; // Star wars is the only game to use unsigned fixed shaded values. It's also the only game to set the specular flag on these polys
|
||||
shade += m_vpAmbient;
|
||||
shade = std::min(shade, 1.0f);
|
||||
}
|
||||
else {
|
||||
shade = (((ix + 128) & 0xFF) / 255.f); // Step 2+ uses signed or unsigned values for lighting 0-255. Todo finish this logic
|
||||
shade = std::max(1 - m_vpAmbient, shade);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -117,8 +117,8 @@ static const char *fragmentShaderR3D =
|
|||
"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)
|
||||
"sunVector = lighting[0] * vec3(1.0, -1.0, -1.0);\n"
|
||||
// Sun angle
|
||||
"sunVector = lighting[0];\n"
|
||||
|
||||
// Compute diffuse factor for sunlight
|
||||
"sunFactor = max(dot(sunVector, fsViewNormal), 0.0);\n"
|
||||
|
|
Loading…
Reference in a new issue