mirror of
https://github.com/libretro/ppsspp.git
synced 2024-11-24 16:49:50 +00:00
HW T&L : clamp lightscale
This commit is contained in:
parent
be5af6831e
commit
07a36f2384
@ -46,7 +46,7 @@ bool CanUseHardwareTransform(int prim)
|
|||||||
// prim so we can special case for RECTANGLES :(
|
// prim so we can special case for RECTANGLES :(
|
||||||
void ComputeVertexShaderID(VertexShaderID *id, int prim)
|
void ComputeVertexShaderID(VertexShaderID *id, int prim)
|
||||||
{
|
{
|
||||||
int doTexture = (gstate.textureMapEnable & 1) && !(gstate.isModeClear());
|
int doTexture = gstate.isTextureMapEnabled() && !gstate.isModeClear();
|
||||||
|
|
||||||
bool hasColor = (gstate.vertType & GE_VTYPE_COL_MASK) != 0;
|
bool hasColor = (gstate.vertType & GE_VTYPE_COL_MASK) != 0;
|
||||||
bool hasNormal = (gstate.vertType & GE_VTYPE_NRM_MASK) != 0;
|
bool hasNormal = (gstate.vertType & GE_VTYPE_NRM_MASK) != 0;
|
||||||
@ -142,8 +142,8 @@ void GenerateVertexShader(int prim, char *buffer) {
|
|||||||
WRITE(p, "#define mediump\n");
|
WRITE(p, "#define mediump\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int lmode = (gstate.lmode & 1) && (gstate.lightingEnable & 1);
|
int lmode = (gstate.lmode & 1) && gstate.isLightingEnabled();
|
||||||
int doTexture = (gstate.textureMapEnable & 1) && !(gstate.clearmode & 1);
|
int doTexture = gstate.isTextureMapEnabled() && !gstate.isModeClear();
|
||||||
|
|
||||||
bool hwXForm = CanUseHardwareTransform(prim);
|
bool hwXForm = CanUseHardwareTransform(prim);
|
||||||
bool hasColor = (gstate.vertType & GE_VTYPE_COL_MASK) != 0 || !hwXForm;
|
bool hasColor = (gstate.vertType & GE_VTYPE_COL_MASK) != 0 || !hwXForm;
|
||||||
@ -340,8 +340,7 @@ void GenerateVertexShader(int prim, char *buffer) {
|
|||||||
if (type != GE_LIGHTTYPE_DIRECTIONAL) {
|
if (type != GE_LIGHTTYPE_DIRECTIONAL) {
|
||||||
// Attenuation
|
// Attenuation
|
||||||
WRITE(p, " float distance%i = length(toLight%i);\n", i, i);
|
WRITE(p, " float distance%i = length(toLight%i);\n", i, i);
|
||||||
WRITE(p, " lightScale%i = 1.0 / dot(u_lightatt%i, vec3(1.0, distance%i, distance%i*distance%i));\n", i, i, i, i, i);
|
WRITE(p, " lightScale%i = clamp(1.0 / dot(u_lightatt%i, vec3(1.0, distance%i, distance%i*distance%i)), 0.0, 1.0);\n", i, i, i, i, i);
|
||||||
WRITE(p, " if (lightScale%i > 1.0) lightScale%i = 1.0;\n", i, i);
|
|
||||||
}
|
}
|
||||||
WRITE(p, " vec3 diffuse%i = (u_lightdiffuse%i * %s) * (max(dot%i, 0.0) * lightScale%i);\n", i, i, diffuse, i, i);
|
WRITE(p, " vec3 diffuse%i = (u_lightdiffuse%i * %s) * (max(dot%i, 0.0) * lightScale%i);\n", i, i, diffuse, i, i);
|
||||||
if (doSpecular) {
|
if (doSpecular) {
|
||||||
|
Loading…
Reference in New Issue
Block a user