Skip to content

Commit

Permalink
Adding hardware fog for the PSP.
Browse files Browse the repository at this point in the history
  • Loading branch information
z2442 committed Dec 5, 2024
1 parent 69c2a98 commit a9718b0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
4 changes: 3 additions & 1 deletion Source/HLEGraphics/BaseRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ class BaseRenderer
// Fog stuff
inline void SetFogMultOffs(f32 Mult, f32 Offs) { mTnL.FogMult=Mult/255.0f; mTnL.FogOffs=Offs/255.0f;}
#ifdef DAEDALUS_PSP
inline void SetFogMinMax(f32 fog_near, f32 fog_far) { sceGuFog(fog_near, fog_far, mFogColour.GetColour()); }
inline void SetFogMinMax(f32 fog_near, f32 fog_far) { mfog_near = fog_near; mfog_far = fog_far;}
inline void SetFogColour( c32 colour ) { mFogColour = colour; }
#elif defined(DAEDALUS_VITA) || defined (DAEDALUS_CTR) || defined (DAEDALUS_GL)
inline void SetFogMinMax(f32 fog_near, f32 fog_far) { glFogf(GL_FOG_START, fog_near); glFogf(GL_FOG_END, fog_far); }
Expand Down Expand Up @@ -444,6 +444,8 @@ class BaseRenderer

f32 mPrimDepth;
f32 mPrimLODFraction;
f32 mfog_near;
f32 mfog_far;

c32 mFogColour; // Blender
c32 mPrimitiveColour; // Combiner
Expand Down
15 changes: 7 additions & 8 deletions Source/SysPSP/HLEGraphics/RendererPSP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,18 +364,17 @@ inline void RendererPSP::RenderFog( DaedalusVtx * p_vertices, u32 num_vertices,
sceGuDisable(GU_TEXTURE_2D); //Blend triangle without a texture
sceGuDisable(GU_ALPHA_TEST);
sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
// Enable PSP hardware fog
sceGuEnable(GU_FOG);

u32 FogColor {mFogColour.GetColour()};

//Copy fog color to vertices
for(u32 i {} ; i < num_vertices ; i++)
{
u32 alpha {p_vertices[i].Colour.GetColour() & 0xFF000000};
p_vertices[i].Colour = (c32)(alpha | FogColor);
}
// Configure fog range and color
u32 fogColor = (mFogColour.GetColour()); // Fog color
sceGuFog(mfog_near, mfog_far, fogColor);

sceGuDrawArray( triangle_mode, render_flags, num_vertices, nullptr, p_vertices );

sceGuDisable(GU_FOG);

sceGuDepthFunc(GU_GEQUAL); //Restore default depth function
}
}
Expand Down

0 comments on commit a9718b0

Please sign in to comment.