Skip to content

Commit

Permalink
Merge branch 'feature/ffp' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Xottab-DUTY committed Jun 25, 2023
2 parents 663d2ba + 6be8c3c commit 38a8381
Show file tree
Hide file tree
Showing 17 changed files with 200 additions and 56 deletions.
13 changes: 11 additions & 2 deletions src/Common/OGF_GContainer_Vertices.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,11 @@ struct r1v_lmap_unpacked
r1v_lmap_unpacked& operator=(const r1v_lmap& packed)
{
P = packed.P;
N = Fcolor(packed.N).get();

Fcolor unpackedN(packed.N);
unpackedN.mul_rgb(2);
unpackedN.sub_rgb(1);
N = unpackedN.get();

Fcolor T(packed.T);
Fcolor B(packed.B);
Expand Down Expand Up @@ -188,7 +192,12 @@ struct r1v_vert_unpacked
r1v_vert_unpacked& operator=(const r1v_vert& packed)
{
P = packed.P;
N = Fcolor(packed.N).get();

Fcolor unpackedN(packed.N);
unpackedN.mul_rgb(2);
unpackedN.sub_rgb(1);
N = unpackedN.get();

C = packed.C;

Fcolor T(packed.T);
Expand Down
20 changes: 13 additions & 7 deletions src/Layers/xrRender/blenders/Blender_LaEmB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,10 @@ void CBlender_LaEmB::Compile(CBlender_Compile& C)
return;
}

if (2 == C.iElement)
switch (C.iElement)
{
if (bConstant)
compile_Lc(C);
else
compile_L(C);
}
else
case SE_R1_NORMAL_HQ:
case SE_R1_NORMAL_LQ:
{
switch (HW.Caps.raster.dwStages)
{
Expand All @@ -161,7 +157,17 @@ void CBlender_LaEmB::Compile(CBlender_Compile& C)
compile_3(C);
break;
} // switch (HW.Caps.raster.dwStages)
break;
}
case SE_R1_LMODELS:
{
if (bConstant)
compile_Lc(C);
else
compile_L(C);
break;
}
} // switch (C.iElement)
}
//
void CBlender_LaEmB::compile_2(CBlender_Compile& C)
Expand Down
18 changes: 12 additions & 6 deletions src/Layers/xrRender/blenders/Blender_Lm(EbB).cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,10 @@ void CBlender_LmEbB::CompileFFP(CBlender_Compile& C) const
compile_ED(C);
else
{
if (2 == C.iElement)
switch (C.iElement)
{
compile_L(C);
}
else
case SE_R1_NORMAL_HQ:
case SE_R1_NORMAL_LQ:
{
switch (HW.Caps.raster.dwStages)
{
Expand All @@ -75,8 +74,15 @@ void CBlender_LmEbB::CompileFFP(CBlender_Compile& C) const
default:
compile_3(C);
break;
}
} // switch (HW.Caps.raster.dwStages)
} // switch (HW.Caps.raster.dwStages)
break;
}
case SE_R1_LMODELS:
{
compile_L(C);
break;
}
} // switch (C.iElement)
}
}

Expand Down
3 changes: 0 additions & 3 deletions src/Layers/xrRender/blenders/Blender_Model_EbB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,6 @@ void CBlender_Model_EbB::CompileFFP(CBlender_Compile& C) const
C.StageEnd();
break;
}

default:
break;
} // switch (C.iElement)
}
C.PassEnd();
Expand Down
46 changes: 46 additions & 0 deletions src/Layers/xrRender/blenders/Blender_Shadow_Texture.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include "stdafx.h"

#include "Blender_Shadow_Texture.h"

#if RENDER != R_R1
#error "The blender can't be used in this renderer generation"
#endif

CBlender_ShTex::CBlender_ShTex()
{
description.CLS = B_SHADOW_TEX;
}

LPCSTR CBlender_ShTex::getComment()
{
return "INTERNAL: shadow rendering";
}

BOOL CBlender_ShTex::canBeLMAPped()
{
return FALSE;
}

void CBlender_ShTex::Compile(CBlender_Compile& C)
{
IBlender::Compile(C);
C.PassBegin();
{
C.PassSET_ZB(FALSE, FALSE);
C.PassSET_Blend_SET();
C.PassSET_LightFog(FALSE, FALSE);

// Stage0 - Base texture
C.StageBegin();
C.StageSET_Color(D3DTA_TFACTOR, D3DTOP_SELECTARG1, D3DTA_TFACTOR);
C.StageSET_Alpha(D3DTA_TFACTOR, D3DTOP_SELECTARG1, D3DTA_TFACTOR);
C.Stage_Texture("$null");
C.Stage_Matrix("$null", 0);
C.Stage_Constant("$null");
C.StageEnd();

//
C.R().SetRS(D3DRS_TEXTUREFACTOR, 0);
}
C.PassEnd();
}
12 changes: 12 additions & 0 deletions src/Layers/xrRender/blenders/Blender_Shadow_Texture.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#pragma once

class CBlender_ShTex : public IBlender
{
public:
CBlender_ShTex();

LPCSTR getComment() override;
BOOL canBeLMAPped() override;

void Compile (CBlender_Compile& C) override;
};
4 changes: 0 additions & 4 deletions src/Layers/xrRender/blenders/Blender_Vertex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ void CBlender_Vertex::CompileFFP(CBlender_Compile& C) const
C.PassEnd();
break;
}

case SE_R1_LMODELS:
{
// Lighting only
Expand All @@ -133,9 +132,6 @@ void CBlender_Vertex::CompileFFP(CBlender_Compile& C) const
C.PassEnd();
break;
}

default:
break;
} // switch (C.iElement)
}
}
Expand Down
1 change: 0 additions & 1 deletion src/Layers/xrRender/blenders/Blender_Vertex_aref.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ void CBlender_Vertex_aref::CompileFFP(CBlender_Compile& C) const
C.PassEnd();
break;
}

case SE_R1_LMODELS:
{
// Lighting only
Expand Down
4 changes: 1 addition & 3 deletions src/Layers/xrRender/blenders/Blender_default_aref.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ void CBlender_default_aref::CompileFFP(CBlender_Compile& C) const
C.StageEnd();
}
C.PassEnd();
break;
}
case SE_R1_LMODELS:
{
Expand All @@ -141,9 +142,6 @@ void CBlender_default_aref::CompileFFP(CBlender_Compile& C) const
C.PassEnd();
break;
}

default:
break;
} // switch (C.iElement)
}
}
Expand Down
4 changes: 0 additions & 4 deletions src/Layers/xrRender/blenders/Blender_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ void CBlender_Tree::CompileFFP(CBlender_Compile& C) const
C.StageEnd();
break;
}

case SE_R1_LMODELS:
{
// Lighting only
Expand All @@ -105,9 +104,6 @@ void CBlender_Tree::CompileFFP(CBlender_Compile& C) const
C.StageEnd();
break;
}

default:
break;
} // switch (C.iElement)
}

Expand Down
76 changes: 53 additions & 23 deletions src/Layers/xrRender/light.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,29 +104,58 @@ class light : public IRender_Light, public SpatialBase
#endif // (RENDER==R_R2) || (RENDER==R_R3) || (RENDER==R_R4) || (RENDER==R_GL)

public:
virtual void set_type(LT type) { flags.type = type; }
virtual void set_active(bool b);
virtual bool get_active() { return flags.bActive; }
virtual void set_shadow(bool b) { flags.bShadow = b; }
virtual void set_volumetric(bool b) { flags.bVolumetric = b; }
virtual void set_volumetric_quality(float fValue) { m_volumetric_quality = fValue; }
virtual void set_volumetric_intensity(float fValue) { m_volumetric_intensity = fValue; }
virtual void set_volumetric_distance(float fValue) { m_volumetric_distance = fValue; }
virtual void set_position(const Fvector& P);
virtual void set_rotation(const Fvector& D, const Fvector& R);
virtual void set_cone(float angle);
virtual void set_range(float R);
virtual void set_virtual_size(float R) { virtual_size = R; }
virtual void set_color(const Fcolor& C) { color.set(C); }
virtual void set_color(float r, float g, float b) { color.set(r, g, b, 1); }
virtual void set_texture(LPCSTR name);
virtual void set_hud_mode(bool b) { flags.bHudMode = b; }
virtual bool get_hud_mode() { return flags.bHudMode; };
virtual void spatial_move();
virtual Fvector spatial_sector_point();

virtual IRender_Light* dcast_Light() { return this; }
void set_type(LT type) override
{
flags.type = type;
}

void set_active(bool b) override;

[[nodiscard]]
bool get_active() override { return flags.bActive; }

void set_shadow(bool b) override { flags.bShadow = b; }

void set_volumetric(bool b) override { flags.bVolumetric = b; }

void set_volumetric_quality(float fValue) override { m_volumetric_quality = fValue; }

void set_volumetric_intensity(float fValue) override { m_volumetric_intensity = fValue; }

void set_volumetric_distance(float fValue) override { m_volumetric_distance = fValue; }

void set_position(const Fvector& P) override;

void set_rotation(const Fvector& D, const Fvector& R) override;

void set_cone(float angle) override;

void set_range(float R) override;

void set_virtual_size(float R) override { virtual_size = R; }

void set_color(const Fcolor& C) override
{
color.set(C);
}

void set_color(float r, float g, float b) override
{
color.set(r, g, b, 1);
}

void set_texture(LPCSTR name) override;

void set_hud_mode(bool b) override { flags.bHudMode = b; }
[[nodiscard]]
bool get_hud_mode() override { return flags.bHudMode; }

void spatial_move() override;
Fvector spatial_sector_point() override;

IRender_Light* dcast_Light() override { return this; }
vis_data& get_homdata();

#if (RENDER == R_R2) || (RENDER == R_R3) || (RENDER == R_R4) || (RENDER == R_GL)
void gi_generate();
void xform_calc();
Expand All @@ -136,10 +165,11 @@ class light : public IRender_Light, public SpatialBase
void set_attenuation_params(float a0, float a1, float a2, float fo);
#endif // (RENDER==R_R2) || (RENDER==R_R3) || (RENDER==R_R4) || (RENDER==R_GL)

[[nodiscard]]
float get_LOD() const;

light();
virtual ~light();
~light() override;
};

#endif // #define LAYERS_XRRENDER_LIGHT_H_INCLUDED
12 changes: 12 additions & 0 deletions src/Layers/xrRenderPC_R1/LightPPA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ void CLightR_Manager::render_point(u32 _priority)
if (L->range < 0.01f)
continue;

RImplementation.BasicStats.Lights.Begin();

// 1. Calculate light frustum
Fvector L_dir, L_up, L_right, L_pos;
Fmatrix L_view, L_project, L_combine;
Expand Down Expand Up @@ -227,6 +229,8 @@ void CLightR_Manager::render_point(u32 _priority)
dsgraph.render_graph(_priority);
if (bHUD && _priority == 0)
dsgraph.render_hud();

RImplementation.BasicStats.Lights.End();
}
// ??? grass ???
}
Expand All @@ -250,6 +254,8 @@ void CLightR_Manager::render_spot(u32 _priority)
if (lc_scale < EPS)
continue;

RImplementation.BasicStats.Lights.Begin();

// 1. Calculate light frustum
Fvector L_dir, L_up, L_right, L_pos;
Fmatrix L_view, L_project, L_combine;
Expand Down Expand Up @@ -313,6 +319,8 @@ void CLightR_Manager::render_spot(u32 _priority)
if (bHUD && _priority == 0)
dsgraph.render_hud();
//RCache.set_ClipPlanes(false, &L_combine);

RImplementation.BasicStats.Lights.End();
}
// ??? grass ???l
}
Expand Down Expand Up @@ -366,6 +374,8 @@ void CLightR_Manager::render_ffp_light(const light& L)
if (0 == triCount)
return;

RImplementation.BasicStats.Lights.Begin();

const CDB::TRI* tris = g_pGameLevel->ObjectSpace.GetStaticTris();
const Fvector* VERTS = DB->get_verts();

Expand Down Expand Up @@ -430,6 +440,8 @@ void CLightR_Manager::render_ffp_light(const light& L)
RImplementation.Vertex.Unlock(actual * 3, hGeom->vb_stride);
if (actual)
RCache.Render(D3DPT_TRIANGLELIST, vOffset, actual);

RImplementation.BasicStats.Lights.End();
}

void CLightR_Manager::render(u32 _priority)
Expand Down
8 changes: 7 additions & 1 deletion src/Layers/xrRenderPC_R1/LightProjector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,13 @@ void CLightProjector::calculate()
if (spatial->GetSpatialData().sector_id != IRender_Sector::INVALID_SECTOR_ID)
dsgraph.render_R1_box(spatial->GetSpatialData().sector_id, BB, SE_R1_LMODELS);
}
// if (spatial) RImplementation.r_dsgraph_render_subspace (spatial->spatial.sector,mCombine,v_C,FALSE);
/*if (spatial)
{
dsgraph.o.sector_id = spatial->GetSpatialData().sector_id;
dsgraph.o.xform = mCombine;
dsgraph.o.view_pos = v_C;
dsgraph.build_subspace();
}*/
}

// Blur
Expand Down
Loading

0 comments on commit 38a8381

Please sign in to comment.