Skip to content

Commit

Permalink
Unbreak environment mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Jan 30, 2017
1 parent 0e4fb11 commit 2a231b3
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 10 deletions.
6 changes: 3 additions & 3 deletions GPU/Common/ShaderId.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ std::string VertexShaderDesc(const ShaderID &id) {

void ComputeVertexShaderID(ShaderID *id_out, u32 vertType, bool useHWTransform) {
bool doTexture = gstate.isTextureMapEnabled() && !gstate.isModeClear();
bool doTextureProjection = gstate.getUVGenMode() == GE_TEXMAP_TEXTURE_MATRIX;
bool doTextureTransform = gstate.getUVGenMode() == GE_TEXMAP_TEXTURE_MATRIX;
bool doShadeMapping = doTexture && (gstate.getUVGenMode() == GE_TEXMAP_ENVIRONMENT_MAP);
bool doFlatShading = gstate.getShadeMode() == GE_SHADE_FLAT && !gstate.isModeClear();

Expand All @@ -83,7 +83,7 @@ void ComputeVertexShaderID(ShaderID *id_out, u32 vertType, bool useHWTransform)

if (doTexture) {
id.SetBit(VS_BIT_DO_TEXTURE);
id.SetBit(VS_BIT_DO_TEXTURE_TRANSFORM, doTextureProjection);
id.SetBit(VS_BIT_DO_TEXTURE_TRANSFORM, doTextureTransform);
}

if (useHWTransform) {
Expand All @@ -94,7 +94,7 @@ void ComputeVertexShaderID(ShaderID *id_out, u32 vertType, bool useHWTransform)
id.SetBits(VS_BIT_UVGEN_MODE, 2, gstate.getUVGenMode());

// The next bits are used differently depending on UVgen mode
if (doTextureProjection) {
if (doTextureTransform) {
id.SetBits(VS_BIT_UVPROJ_MODE, 2, gstate.getUVProjMode());
} else if (doShadeMapping) {
id.SetBits(VS_BIT_LS0, 2, gstate.getUVLS0());
Expand Down
2 changes: 1 addition & 1 deletion GPU/Directx9/VertexShaderGeneratorDX9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ void GenerateVertexShaderDX9(const ShaderID &id, char *buffer) {
break;

case GE_TEXMAP_ENVIRONMENT_MAP: // Shade mapping - use dots from light sources.
WRITE(p, " Out.v_texcoord = float3(u_uvscaleoffset.xy * float2(1.0 + dot(normalize(u_lightpos%i), worldnormal), 1.0 + dot(normalize(u_lightpos%i), worldnormal)) * 0.5, 0.0);\n", ls0, ls1);
WRITE(p, " Out.v_texcoord = float3(u_uvscaleoffset.xy * float2(1.0 + dot(normalize(u_lightpos%i), worldnormal), 1.0 + dot(normalize(u_lightpos%i), worldnormal)) * 0.5, 1.0);\n", ls0, ls1);
break;

default:
Expand Down
4 changes: 0 additions & 4 deletions GPU/GLES/ShaderManagerGLES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.

// #define SHADERLOG

#if defined(_WIN32) && defined(SHADERLOG)
#include "Common/CommonWindows.h"
#endif
Expand All @@ -43,8 +41,6 @@
#include "GPU/GLES/DrawEngineGLES.h"
#include "FramebufferManagerGLES.h"

#define SHADERLOG

Shader::Shader(const char *code, uint32_t glShaderType, bool useHWTransform)
: failed_(false), useHWTransform_(useHWTransform) {
PROFILE_THIS_SCOPE("shadercomp");
Expand Down
2 changes: 1 addition & 1 deletion GPU/GLES/VertexShaderGeneratorGLES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ void GenerateVertexShader(const ShaderID &id, char *buffer) {
break;

case GE_TEXMAP_ENVIRONMENT_MAP: // Shade mapping - use dots from light sources.
WRITE(p, " v_texcoord = vec3(u_uvscaleoffset.xy * vec2(1.0 + dot(normalize(u_lightpos%i), worldnormal), 1.0 + dot(normalize(u_lightpos%i), worldnormal)) * 0.5);\n", ls0, ls1);
WRITE(p, " v_texcoord = vec3(u_uvscaleoffset.xy * vec2(1.0 + dot(normalize(u_lightpos%i), worldnormal), 1.0 + dot(normalize(u_lightpos%i), worldnormal)) * 0.5, 1.0);\n", ls0, ls1);
break;

default:
Expand Down
2 changes: 1 addition & 1 deletion GPU/Vulkan/VertexShaderGeneratorVulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ bool GenerateVulkanGLSLVertexShader(const ShaderID &id, char *buffer, bool *uses
break;

case GE_TEXMAP_ENVIRONMENT_MAP: // Shade mapping - use dots from light sources.
WRITE(p, " v_texcoord = vec3(base.uvscaleoffset.xy * vec2(1.0 + dot(normalize(light.pos[%i]), worldnormal), 1.0 + dot(normalize(light.pos[%i]), worldnormal)) * 0.5, 0.0);\n", ls0, ls1);
WRITE(p, " v_texcoord = vec3(base.uvscaleoffset.xy * vec2(1.0 + dot(normalize(light.pos[%i]), worldnormal), 1.0 + dot(normalize(light.pos[%i]), worldnormal)) * 0.5, 1.0);\n", ls0, ls1);
break;

default:
Expand Down

0 comments on commit 2a231b3

Please sign in to comment.