Skip to content

Commit

Permalink
Fixes & Improvements
Browse files Browse the repository at this point in the history
-Disable culling for UI drawing(LeGo script packet doesn't follow CW winding order and any Sprite it tries to draw doesn't pass the test)
-Add option to reduce light intensity for scene where are many lights that can make scene to be overexposed(e.g. old camp in Othello Mod)
-Add some quantization to skeletal meshes to reduce bandwidth
-Revert temporarily back to bind pose normals for skeletal meshes since bone accurate normals can result in some weird glitches on some modifications
  • Loading branch information
SaiyansKing committed Dec 3, 2021
1 parent 8116e90 commit 9b639ff
Show file tree
Hide file tree
Showing 12 changed files with 79 additions and 92 deletions.
11 changes: 10 additions & 1 deletion D3D11Engine/D2DSettingsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,16 @@ XRESULT D2DSettingsDialog::InitControls() {
}
rainEffectsCheckbox->SetDataToUpdate( &Engine::GAPI->GetRendererState().RendererSettings.EnableRainEffects );
rainEffectsCheckbox->SetChecked( Engine::GAPI->GetRendererState().RendererSettings.EnableRainEffects );
rainEffectsCheckbox->SetPosition( D2D1::Point2F( 170 + 160 + 20, rainEffectsCheckbox->GetPosition().y ) );

SV_Checkbox* lightCheckbox = new SV_Checkbox( MainView, MainPanel );
lightCheckbox->SetPositionAndSize( D2D1::Point2F( 10, 10 ), D2D1::SizeF( 160, 20 ) );
lightCheckbox->AlignUnder( rainEffectsCheckbox, 15 );
switch ( userLanguage ) {
case LANGUAGE_POLISH: lightCheckbox->SetCaption( L"Ogranicz Natê¿enie Œwiat³a" ); break;
default: lightCheckbox->SetCaption( L"Limit Light Intesity" ); break;
}
lightCheckbox->SetDataToUpdate( &Engine::GAPI->GetRendererState().RendererSettings.LimitLightIntesity );
lightCheckbox->SetChecked( Engine::GAPI->GetRendererState().RendererSettings.LimitLightIntesity );

// Mode changing label
SV_Label* modeChangingLabel = new SV_Label( MainView, MainPanel );
Expand Down
30 changes: 16 additions & 14 deletions D3D11Engine/D3D11GraphicsEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -976,11 +976,10 @@ XRESULT D3D11GraphicsEngine::OnBeginFrame() {
// Notify the shader manager
ShaderManager->OnFrameStart();

// Enable blending, in case some modifications need it
// and the ResetRenderStates won't be enough
Engine::GAPI->GetRendererState().BlendState.SetDefault();
Engine::GAPI->GetRendererState().BlendState.BlendEnabled = true;
Engine::GAPI->GetRendererState().BlendState.SetDirty();
// Disable culling for ui rendering(Sprite from LeGo needs it since it use CCW instead of CW order)
SetDefaultStates();
Engine::GAPI->GetRendererState().RasterizerState.CullMode = GothicRasterizerStateInfo::CM_CULL_NONE;
Engine::GAPI->GetRendererState().RasterizerState.SetDirty();
UpdateRenderStates();

// Bind HDR Back Buffer
Expand Down Expand Up @@ -1539,11 +1538,10 @@ XRESULT D3D11GraphicsEngine::DrawScreenFade( void* c ) {

Continue_ResetState:
if ( ResetStates ) {
// Enable blending, in case some modifications need it
// Disable culling for ui rendering(Sprite from LeGo needs it since it use CCW instead of CW order)
SetDefaultStates();
Engine::GAPI->GetRendererState().BlendState.SetDefault();
Engine::GAPI->GetRendererState().BlendState.BlendEnabled = true;
Engine::GAPI->GetRendererState().BlendState.SetDirty();
Engine::GAPI->GetRendererState().RasterizerState.CullMode = GothicRasterizerStateInfo::CM_CULL_NONE;
Engine::GAPI->GetRendererState().RasterizerState.SetDirty();
UpdateRenderStates();
}
return XR_SUCCESS;
Expand Down Expand Up @@ -2217,12 +2215,10 @@ XRESULT D3D11GraphicsEngine::OnStartWorldRendering() {
GetContext()->OMSetRenderTargets( 1, HDRBackBuffer->GetRenderTargetView().GetAddressOf(),
nullptr );

// Enable blending, in case some modifications need it
// and the ResetRenderStates won't be enough
// Disable culling for ui rendering(Sprite from LeGo needs it since it use CCW instead of CW order)
SetDefaultStates();
Engine::GAPI->GetRendererState().BlendState.SetDefault();
Engine::GAPI->GetRendererState().BlendState.BlendEnabled = true;
Engine::GAPI->GetRendererState().BlendState.SetDirty();
Engine::GAPI->GetRendererState().RasterizerState.CullMode = GothicRasterizerStateInfo::CM_CULL_NONE;
Engine::GAPI->GetRendererState().RasterizerState.SetDirty();
UpdateRenderStates();

// Save screenshot if wanted
Expand Down Expand Up @@ -4621,6 +4617,9 @@ XRESULT D3D11GraphicsEngine::DrawLighting( std::vector<VobLightInfo*>& lights )
WORLD_SECTION_SIZE );

Engine::GAPI->GetRendererState().BlendState.SetAdditiveBlending();
if ( Engine::GAPI->GetRendererState().RendererSettings.LimitLightIntesity ) {
Engine::GAPI->GetRendererState().BlendState.BlendOp = GothicBlendStateInfo::BO_BLEND_OP_MAX;
}
Engine::GAPI->GetRendererState().BlendState.SetDirty();

Engine::GAPI->GetRendererState().DepthState.DepthWriteEnabled = false;
Expand Down Expand Up @@ -4758,6 +4757,9 @@ XRESULT D3D11GraphicsEngine::DrawLighting( std::vector<VobLightInfo*>& lights )
Engine::GAPI->GetRendererState().RendererInfo.FrameDrawnLights++;
}

Engine::GAPI->GetRendererState().BlendState.BlendOp = GothicBlendStateInfo::BO_BLEND_OP_ADD;
Engine::GAPI->GetRendererState().BlendState.SetDirty();

Engine::GAPI->GetRendererState().DepthState.DepthBufferCompareFunc = GothicDepthBufferStateInfo::CF_COMPARISON_ALWAYS;
Engine::GAPI->GetRendererState().DepthState.SetDirty();

Expand Down
14 changes: 7 additions & 7 deletions D3D11Engine/D3D11VShader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ XRESULT D3D11VShader::LoadShader( const char* vertexShader, int layout, const st

const D3D11_INPUT_ELEMENT_DESC layout3[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "POSITION", 1, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "POSITION", 2, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "POSITION", 3, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "POSITION", 0, DXGI_FORMAT_R16G16B16A16_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "POSITION", 1, DXGI_FORMAT_R16G16B16A16_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "POSITION", 2, DXGI_FORMAT_R16G16B16A16_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "POSITION", 3, DXGI_FORMAT_R16G16B16A16_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "DIFFUSE", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 1, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "BONEIDS", 0, DXGI_FORMAT_R8G8B8A8_UINT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "WEIGHTS", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "WEIGHTS", 0, DXGI_FORMAT_R16G16B16A16_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
};

const D3D11_INPUT_ELEMENT_DESC layout4[] =
Expand Down
6 changes: 0 additions & 6 deletions D3D11Engine/D3D7/MyDirect3DDevice7.h
Original file line number Diff line number Diff line change
Expand Up @@ -741,12 +741,6 @@ class MyDirect3DDevice7 : public IDirect3DDevice7 {
exv[i].Color = rhw[i].color;
}

if ( Engine::GAPI->GetRendererState().RasterizerState.FrontCounterClockwise ) {
// Some mods can change winding order
Engine::GAPI->GetRendererState().RasterizerState.FrontCounterClockwise = false;
Engine::GAPI->GetRendererState().RasterizerState.SetDirty();
}

Engine::GraphicsEngine->SetActiveVertexShader( "VS_TransformedEx" );
Engine::GraphicsEngine->BindViewportInformation( "VS_TransformedEx", 0 );
break;
Expand Down
2 changes: 2 additions & 0 deletions D3D11Engine/GothicAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3828,6 +3828,7 @@ XRESULT GothicAPI::SaveMenuSettings( const std::string& file ) {
WritePrivateProfileStringA( "Display", "UIScale", std::to_string( s.GothicUIScale ).c_str(), ini.c_str() );
WritePrivateProfileStringA( "Display", "Rain", std::to_string( s.EnableRain ? TRUE : FALSE ).c_str(), ini.c_str() );
WritePrivateProfileStringA( "Display", "RainEffects", std::to_string( s.EnableRainEffects ? TRUE : FALSE ).c_str(), ini.c_str() );
WritePrivateProfileStringA( "Display", "LimitLightIntesity", std::to_string( s.LimitLightIntesity ? TRUE : FALSE ).c_str(), ini.c_str() );

WritePrivateProfileStringA( "Shadows", "EnableShadows", std::to_string( s.EnableShadows ? TRUE : FALSE ).c_str(), ini.c_str() );
WritePrivateProfileStringA( "Shadows", "EnableSoftShadows", std::to_string( s.EnableSoftShadows ? TRUE : FALSE ).c_str(), ini.c_str() );
Expand Down Expand Up @@ -3938,6 +3939,7 @@ XRESULT GothicAPI::LoadMenuSettings( const std::string& file ) {
s.GothicUIScale = GetPrivateProfileFloatA( "Display", "UIScale", 1.0f, ini );
s.EnableRain = GetPrivateProfileBoolA( "Display", "Rain", true, ini );
s.EnableRainEffects = GetPrivateProfileBoolA( "Display", "RainEffects", true, ini );
s.LimitLightIntesity = GetPrivateProfileBoolA( "Display", "LimitLightIntesity", false, ini );

s.EnableSMAA = GetPrivateProfileBoolA( "SMAA", "Enabled", false, ini );
s.SharpenFactor = GetPrivateProfileFloatA( "SMAA", "SharpenFactor", 0.30f, ini );
Expand Down
2 changes: 2 additions & 0 deletions D3D11Engine/GothicGraphicsState.h
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,7 @@ struct GothicRendererSettings {
GothicUIScale = 1.0f;
//DisableEverything();

LimitLightIntesity = false;
AllowNormalmaps = true;

AllowNumpadKeys = false;
Expand Down Expand Up @@ -786,6 +787,7 @@ struct GothicRendererSettings {
bool EnableRain;
bool EnableRainEffects;

bool LimitLightIntesity;
bool AllowNormalmaps;

bool AllowNumpadKeys;
Expand Down
16 changes: 8 additions & 8 deletions D3D11Engine/Shaders/VS_ExSkeletal.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ cbuffer BoneTransforms : register( b2 )
//--------------------------------------------------------------------------------------
struct VS_INPUT
{
float3 vPosition[4] : POSITION;
float4 vPosition[4] : POSITION;
float3 vNormal : NORMAL;
float2 vTex1 : TEXCOORD0;
float4 vDiffuse : DIFFUSE;
float3 vBindPoseNormal : TEXCOORD0;
float2 vTex1 : TEXCOORD1;
uint4 BoneIndices : BONEIDS;
float4 Weights : WEIGHTS;
};
Expand All @@ -55,10 +55,10 @@ VS_OUTPUT VSMain( VS_INPUT Input )
VS_OUTPUT Output;

float3 position = float3(0, 0, 0);
position += Input.Weights.x * mul(float4(Input.vPosition[0], 1), BT_Transforms[Input.BoneIndices.x]).xyz;
position += Input.Weights.y * mul(float4(Input.vPosition[1], 1), BT_Transforms[Input.BoneIndices.y]).xyz;
position += Input.Weights.z * mul(float4(Input.vPosition[2], 1), BT_Transforms[Input.BoneIndices.z]).xyz;
position += Input.Weights.w * mul(float4(Input.vPosition[3], 1), BT_Transforms[Input.BoneIndices.w]).xyz;
position += Input.Weights.x * mul(float4(Input.vPosition[0].xyz, 1), BT_Transforms[Input.BoneIndices.x]).xyz;
position += Input.Weights.y * mul(float4(Input.vPosition[1].xyz, 1), BT_Transforms[Input.BoneIndices.y]).xyz;
position += Input.Weights.z * mul(float4(Input.vPosition[2].xyz, 1), BT_Transforms[Input.BoneIndices.z]).xyz;
position += Input.Weights.w * mul(float4(Input.vPosition[3].xyz, 1), BT_Transforms[Input.BoneIndices.w]).xyz;

float3 normal = float3(0, 0, 0);
normal += Input.Weights.x * mul(Input.vNormal, (float3x3)BT_Transforms[Input.BoneIndices.x]);
Expand All @@ -73,7 +73,7 @@ VS_OUTPUT VSMain( VS_INPUT Input )
Output.vTexcoord2 = Input.vTex1;
Output.vTexcoord = Input.vTex1;
Output.vDiffuse = PI_ModelColor;
Output.vNormalVS = mul(normal, (float3x3)mul(M_World, M_View));
Output.vNormalVS = mul(Input.vBindPoseNormal, (float3x3)mul(M_World, M_View));
Output.vViewPosition = mul(float4(positionWorld,1),M_View).xyz;
//Output.vWorldPosition = positionWorld;

Expand Down
16 changes: 8 additions & 8 deletions D3D11Engine/Shaders/VS_ExSkeletalCube.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ cbuffer BoneTransforms : register( b2 )
//--------------------------------------------------------------------------------------
struct VS_INPUT
{
float3 vPosition[4] : POSITION;
float4 vPosition[4] : POSITION;
float3 vNormal : NORMAL;
float2 vTex1 : TEXCOORD0;
float4 vDiffuse : DIFFUSE;
float3 vBindPoseNormal : TEXCOORD0;
float2 vTex1 : TEXCOORD1;
uint4 BoneIndices : BONEIDS;
float4 Weights : WEIGHTS;
};
Expand All @@ -54,10 +54,10 @@ VS_OUTPUT VSMain( VS_INPUT Input )
VS_OUTPUT Output;

float3 position = float3(0, 0, 0);
position += Input.Weights.x * mul(float4(Input.vPosition[0], 1), BT_Transforms[Input.BoneIndices.x]).xyz;
position += Input.Weights.y * mul(float4(Input.vPosition[1], 1), BT_Transforms[Input.BoneIndices.y]).xyz;
position += Input.Weights.z * mul(float4(Input.vPosition[2], 1), BT_Transforms[Input.BoneIndices.z]).xyz;
position += Input.Weights.w * mul(float4(Input.vPosition[3], 1), BT_Transforms[Input.BoneIndices.w]).xyz;
position += Input.Weights.x * mul(float4(Input.vPosition[0].xyz, 1), BT_Transforms[Input.BoneIndices.x]).xyz;
position += Input.Weights.y * mul(float4(Input.vPosition[1].xyz, 1), BT_Transforms[Input.BoneIndices.y]).xyz;
position += Input.Weights.z * mul(float4(Input.vPosition[2].xyz, 1), BT_Transforms[Input.BoneIndices.z]).xyz;
position += Input.Weights.w * mul(float4(Input.vPosition[3].xyz, 1), BT_Transforms[Input.BoneIndices.w]).xyz;

float3 normal = float3(0, 0, 0);
normal += Input.Weights.x * mul(Input.vNormal, (float3x3)BT_Transforms[Input.BoneIndices.x]);
Expand All @@ -72,7 +72,7 @@ VS_OUTPUT VSMain( VS_INPUT Input )
Output.vTexcoord2 = Input.vTex1;
Output.vTexcoord = Input.vTex1;
Output.vDiffuse = PI_ModelColor;
Output.vNormalWS = mul(normal, (float3x3)M_World);
Output.vNormalWS = mul(Input.vBindPoseNormal, (float3x3)M_World);


return Output;
Expand Down
6 changes: 3 additions & 3 deletions D3D11Engine/VertexTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ struct BasicVertexStruct {
};

struct ExSkelVertexStruct {
float3 Position[4];
unsigned short Position[4][4];
float3 Normal;
float3 BindPoseNormal;
float2 TexCoord;
DWORD Color;
unsigned char boneIndices[4];
float weights[4];
unsigned short weights[4];
};

struct Gothic_XYZ_DIF_T1_Vertex {
Expand Down
52 changes: 9 additions & 43 deletions D3D11Engine/WorldConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,6 @@ void WorldConverter::ExtractSkeletalMeshFromVob( zCModel* model, SkeletalMeshVis

ExSkelVertexStruct vx;
//vx.Position = s->GetPositionList()->Array[i];
vx.Color = 0xFFFFFFFF;
vx.Normal = float3( 0, 0, 0 );
ZeroMemory( vx.weights, sizeof( vx.weights ) );
ZeroMemory( vx.Position, sizeof( vx.Position ) );
Expand All @@ -971,9 +970,11 @@ void WorldConverter::ExtractSkeletalMeshFromVob( zCModel* model, SkeletalMeshVis

// Get index and weight
if ( n < 4 ) {
vx.weights[n] = weightEntry.Weight;
vx.weights[n] = quantizeHalfFloat( weightEntry.Weight );
vx.boneIndices[n] = weightEntry.NodeIndex;
vx.Position[n] = weightEntry.VertexPosition;
vx.Position[n][0] = quantizeHalfFloat( weightEntry.VertexPosition.x );
vx.Position[n][1] = quantizeHalfFloat( weightEntry.VertexPosition.y );
vx.Position[n][2] = quantizeHalfFloat( weightEntry.VertexPosition.z );
}
}

Expand Down Expand Up @@ -1007,21 +1008,22 @@ void WorldConverter::ExtractSkeletalMeshFromVob( zCModel* model, SkeletalMeshVis

ExSkelVertexStruct& vx = vertices.back();
int normalPosition = static_cast<int>(wedge.position);
if ( normalPosition < nr->NumInArray )
if ( normalPosition < nr->NumInArray ) {
vx.Normal = nr->Array[normalPosition];
else
} else {
vx.Normal = wedge.normal;
}

vx.BindPoseNormal = wedge.normal;
vx.TexCoord = wedge.texUV;
vx.Color = 0xFFFFFFFF;

// Save vertexpos in bind pose, to run PNAEN on it
bindPoseVertices.emplace_back();
ExVertexStruct& pvx = bindPoseVertices.back();
pvx.Position = s->GetPositionList()->Array[wedge.position];
pvx.Normal = vx.Normal;
pvx.TexCoord = vx.TexCoord;
pvx.Color = vx.Color;
pvx.Color = 0xFFFFFFFF;
}

zCMaterial* mat = s->GetSubmesh( i )->Material;
Expand Down Expand Up @@ -1700,42 +1702,6 @@ void WorldConverter::IndexVertices( ExVertexStruct* input, unsigned int numInput
outVertices[it.second] = it.first;
}

struct CmpClassSkel // class comparing vertices in the set
{
bool operator() ( const std::pair<ExSkelVertexStruct, int>& p1, const std::pair<ExSkelVertexStruct, int>& p2 ) const {
for ( int i = 0; i < 4; i++ ) {
if ( fabs( p1.first.Position[i].x - p2.first.Position[i].x ) > eps ) return p1.first.Position[i].x < p2.first.Position[i].x;
if ( fabs( p1.first.Position[i].y - p2.first.Position[i].y ) > eps ) return p1.first.Position[i].y < p2.first.Position[i].y;
if ( fabs( p1.first.Position[i].z - p2.first.Position[i].z ) > eps ) return p1.first.Position[i].z < p2.first.Position[i].z;
}

if ( fabs( p1.first.TexCoord.x - p2.first.TexCoord.x ) > eps ) return p1.first.TexCoord.x < p2.first.TexCoord.x;
if ( fabs( p1.first.TexCoord.y - p2.first.TexCoord.y ) > eps ) return p1.first.TexCoord.y < p2.first.TexCoord.y;

return false;
}
};

void WorldConverter::IndexVertices( ExSkelVertexStruct* input, unsigned int numInputVertices, std::vector<ExSkelVertexStruct>& outVertices, std::vector<VERTEX_INDEX>& outIndices ) {
std::set<std::pair<ExSkelVertexStruct, int>, CmpClassSkel> vertices;
int index = 0;

for ( unsigned int i = 0; i < numInputVertices; i++ ) {
std::set<std::pair<ExSkelVertexStruct, int>>::iterator it = vertices.find( std::make_pair( input[i], 0/*this value doesn't matter*/ ) );
if ( it != vertices.end() ) outIndices.emplace_back( it->second );
else {
vertices.insert( std::make_pair( input[i], index ) );
outIndices.emplace_back( index++ );
}
}

// Notice that the vertices in the set are not sorted by the index
// so you'll have to rearrange them like this:
outVertices.resize( vertices.size() );
for ( auto const& it : vertices )
outVertices[it.second] = it.first;
}

/** Computes vertex normals for a mesh with face normals */
void WorldConverter::GenerateVertexNormals( std::vector<ExVertexStruct>& vertices, std::vector<VERTEX_INDEX>& indices ) {
std::vector<XMFLOAT3> normals( vertices.size(), XMFLOAT3( 0, 0, 0 ) );
Expand Down
1 change: 0 additions & 1 deletion D3D11Engine/WorldConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ class WorldConverter {

/** Indexes the given vertex array */
static void IndexVertices( ExVertexStruct* input, unsigned int numInputVertices, std::vector<ExVertexStruct>& outVertices, std::vector<VERTEX_INDEX>& outIndices );
static void IndexVertices( ExSkelVertexStruct* input, unsigned int numInputVertices, std::vector<ExSkelVertexStruct>& outVertices, std::vector<VERTEX_INDEX>& outIndices );
static void IndexVertices( ExVertexStruct* input, unsigned int numInputVertices, std::vector<ExVertexStruct>& outVertices, std::vector<unsigned int>& outIndices );

/** Marks the edges of the mesh */
Expand Down
15 changes: 14 additions & 1 deletion D3D11Engine/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#define stdext std
#endif

#define VERSION_NUMBER "17.7-dev32"
#define VERSION_NUMBER "17.7-dev33"
__declspec(selectany) const char* VERSION_NUMBER_STR = VERSION_NUMBER;

extern bool FeatureLevel10Compatibility;
Expand All @@ -53,4 +53,17 @@ void DebugWrite_i( LPCSTR lpDebugMessage, void* thisptr );
/** Computes the size in bytes of the given FVF */
int ComputeFVFSize( DWORD fvf );

inline unsigned short quantizeHalfFloat( float v )
{
union { float f; unsigned int ui; } u = { v };
unsigned int ui = u.ui;

int s = (ui >> 16) & 0x8000;
int em = ui & 0x7fffffff;

int h = (em - (112 << 23) + (1 << 12)) >> 13;
h = (em < (113 << 23)) ? 0 : h;
h = (em >= (143 << 23)) ? 0x7c00 : h;
h = (em > ( 255 << 23 )) ? 0x7e00 : h;
return (unsigned short)(s | h);
}

0 comments on commit 9b639ff

Please sign in to comment.