summaryrefslogtreecommitdiff
path: root/src/rw
diff options
context:
space:
mode:
authoraap <aap@papnet.eu>2020-10-29 19:11:47 +0100
committeraap <aap@papnet.eu>2020-10-29 19:11:47 +0100
commite97366c023ee81d0feefa131ed38c77131d29f40 (patch)
treeec7f378fbb88e855caa8764da2f6186946bf60dd /src/rw
parent81e462b6770f78eab1f8241b2b0df58b91f89008 (diff)
implemented extra model flags for backface culling and alpha test from mobile
Diffstat (limited to 'src/rw')
-rw-r--r--src/rw/RwHelper.cpp24
-rw-r--r--src/rw/RwHelper.h2
-rw-r--r--src/rw/VisibilityPlugins.cpp9
3 files changed, 33 insertions, 2 deletions
diff --git a/src/rw/RwHelper.cpp b/src/rw/RwHelper.cpp
index 4b598e9b..6a7010e2 100644
--- a/src/rw/RwHelper.cpp
+++ b/src/rw/RwHelper.cpp
@@ -3,6 +3,7 @@
#endif
#include "common.h"
+#include "RwHelper.h"
#include "Timecycle.h"
#include "skeleton.h"
#include "Debug.h"
@@ -16,6 +17,7 @@ bool gPS2alphaTest = true;
#else
bool gPS2alphaTest = false;
#endif
+bool gBackfaceCulling = true;
#ifndef FINAL
static bool charsetOpen;
@@ -121,14 +123,32 @@ DefinedState(void)
#ifdef LIBRW
rw::SetRenderState(rw::ALPHATESTFUNC, rw::ALPHAGREATEREQUAL);
- rw::SetRenderState(rw::ALPHATESTREF, 3);
rw::SetRenderState(rw::GSALPHATEST, gPS2alphaTest);
#else
// D3D stuff
RwD3D8SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATER);
- RwD3D8SetRenderState(D3DRS_ALPHAREF, 2);
#endif
+ SetAlphaRef(2);
+}
+
+void
+SetAlphaRef(int ref)
+{
+#ifdef LIBRW
+ rw::SetRenderState(rw::ALPHATESTREF, ref+1);
+#else
+ RwD3D8SetRenderState(D3DRS_ALPHAREF, ref);
+#endif
+}
+
+void
+SetCullMode(uint32 mode)
+{
+ if(gBackfaceCulling)
+ RwRenderStateSet(rwRENDERSTATECULLMODE, (void*)mode);
+ else
+ RwRenderStateSet(rwRENDERSTATECULLMODE, (void*)rwCULLMODECULLNONE);
}
RwFrame*
diff --git a/src/rw/RwHelper.h b/src/rw/RwHelper.h
index eceaee07..130eb636 100644
--- a/src/rw/RwHelper.h
+++ b/src/rw/RwHelper.h
@@ -11,6 +11,8 @@ void DestroyDebugFont();
void ObrsPrintfString(const char *str, short x, short y);
void FlushObrsPrintfs();
void DefinedState(void);
+void SetAlphaRef(int ref);
+void SetCullMode(uint32 mode);
RwFrame *GetFirstChild(RwFrame *frame);
RwObject *GetFirstObject(RwFrame *frame);
RpAtomic *GetFirstAtomic(RpClump *clump);
diff --git a/src/rw/VisibilityPlugins.cpp b/src/rw/VisibilityPlugins.cpp
index b2e252a0..c47cedca 100644
--- a/src/rw/VisibilityPlugins.cpp
+++ b/src/rw/VisibilityPlugins.cpp
@@ -1,5 +1,6 @@
#include "common.h"
+#include "RwHelper.h"
#include "templates.h"
#include "Entity.h"
#include "ModelInfo.h"
@@ -158,6 +159,10 @@ CVisibilityPlugins::RenderFadingEntities(void)
if(mi->m_noZwrite)
#endif
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, FALSE);
+#ifdef EXTRA_MODEL_FLAGS
+ if(mi->m_bIsTree)
+ SetAlphaRef(128);
+#endif
if(e->bDistanceFade){
DeActivateDirectional();
@@ -168,6 +173,10 @@ CVisibilityPlugins::RenderFadingEntities(void)
}else
CRenderer::RenderOneNonRoad(e);
+#ifdef EXTRA_MODEL_FLAGS
+ if(mi->m_bIsTree)
+ SetAlphaRef(2);
+#endif
#ifdef FIX_BUGS
if(mi->GetModelType() == MITYPE_SIMPLE && mi->m_noZwrite)
#else