Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding hardware fog for the PSP. #83

Merged
merged 1 commit into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading