Skip to content

Commit

Permalink
Merge branch 'SaiyansKing_master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	D3D11Engine/GothicAPI.cpp
#	D3D11Engine/pch.h
  • Loading branch information
kirides committed Feb 13, 2022
2 parents 8012b41 + 43edbb0 commit 8a74726
Show file tree
Hide file tree
Showing 64 changed files with 969 additions and 822 deletions.
4 changes: 4 additions & 0 deletions D3D11Engine/BaseAntTweakBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ XRESULT BaseAntTweakBar::Init() {
TwAddVarRW( Bar_General, "Draw ParticleEffects", TW_TYPE_BOOLCPP, &Engine::GAPI->GetRendererState().RendererSettings.DrawParticleEffects, nullptr );
//TwAddVarRW(Bar_General, "Draw Sky", TW_TYPE_BOOLCPP, &Engine::GAPI->GetRendererState().RendererSettings.DrawSky, nullptr);
TwAddVarRW( Bar_General, "Draw Fog", TW_TYPE_BOOLCPP, &Engine::GAPI->GetRendererState().RendererSettings.DrawFog, nullptr );
#if ENABLE_TESSELATION > 0
TwAddVarRW( Bar_General, "Tesselation", TW_TYPE_BOOLCPP, &Engine::GAPI->GetRendererState().RendererSettings.EnableTesselation, nullptr );
#endif

TwAddVarRW( Bar_General, "HDR", TW_TYPE_BOOLCPP, &Engine::GAPI->GetRendererState().RendererSettings.EnableHDR, nullptr );
TwEnumVal hdrToneMapValues[] = { {0, "ToneMap_jafEq4"}, {1, "Uncharted2Tonemap"}, {2, "ACESFilmTonemap"}, {3, "PerceptualQuantizerTonemap"}, {4, "ToneMap_Simple"}, {5, "ACESFittedTonemap"} };
Expand All @@ -129,8 +131,10 @@ XRESULT BaseAntTweakBar::Init() {
TwAddVarRW( Bar_General, "Sort RenderQueue", TW_TYPE_BOOLCPP, &Engine::GAPI->GetRendererState().RendererSettings.SortRenderQueue, nullptr );
TwAddVarRW( Bar_General, "Draw Threaded", TW_TYPE_BOOLCPP, &Engine::GAPI->GetRendererState().RendererSettings.DrawThreaded, nullptr );

#if ENABLE_TESSELATION > 0
TwAddVarRW( Bar_General, "AllowWorldMeshTesselation", TW_TYPE_BOOLCPP, &Engine::GAPI->GetRendererState().RendererSettings.AllowWorldMeshTesselation, nullptr );
TwAddVarRW( Bar_General, "TesselationFrustumCulling", TW_TYPE_BOOLCPP, &Engine::GAPI->GetRendererState().RendererSettings.TesselationFrustumCulling, nullptr );
#endif
TwAddVarRW( Bar_General, "AtmosphericScattering", TW_TYPE_BOOLCPP, &Engine::GAPI->GetRendererState().RendererSettings.AtmosphericScattering, nullptr );
TwAddVarRW( Bar_General, "SkeletalVertexNormals", TW_TYPE_BOOLCPP, &Engine::GAPI->GetRendererState().RendererSettings.ShowSkeletalVertexNormals, nullptr );

Expand Down
3 changes: 2 additions & 1 deletion D3D11Engine/BaseGraphicsEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ class BaseGraphicsEngine {
public:
enum EUIEvent {
UI_OpenSettings,
UI_OpenEditor
UI_OpenEditor,
UI_ClosedSettings,
};

BaseGraphicsEngine() { };
Expand Down
20 changes: 4 additions & 16 deletions D3D11Engine/BaseLineRenderer.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once
#include "pch.h"

#pragma pack (push, 1)
#pragma pack (push, 1)
struct LineVertex {
LineVertex() {}
LineVertex( const DirectX::XMFLOAT3& position, DWORD color = 0xFFFFFFFF ) {
Expand All @@ -24,17 +24,7 @@ struct LineVertex {
float4 Position;
float4 Color;
};
#pragma pack (pop)

struct ScreenSpaceLine {
ScreenSpaceLine() {}
ScreenSpaceLine( const DirectX::XMFLOAT3& position, DWORD color = 0xFFFFFFFF ) {
Position = position;
Color = color;
}
DirectX::XMFLOAT3 Position;
DWORD Color;
};
#pragma pack (pop)

class BaseLineRenderer {
public:
Expand All @@ -43,13 +33,11 @@ class BaseLineRenderer {

/** Adds a line to the list */
virtual XRESULT AddLine( const LineVertex& v1, const LineVertex& v2 ) = 0;
virtual XRESULT AddLineDeferred( const ScreenSpaceLine& v1, const ScreenSpaceLine& v2 ) = 0;
virtual XRESULT AddLineScreenSpace( const LineVertex& v1, const LineVertex& v2 ) = 0;

/** Flushes the cached lines */
virtual XRESULT Flush() = 0;

/** Calculates the world-position from screen position and draws the lines */
virtual XRESULT FlushDeferredLines() = 0;
virtual XRESULT FlushScreenSpace() = 0;

/** Clears the line cache */
virtual XRESULT ClearCache() = 0;
Expand Down
22 changes: 18 additions & 4 deletions D3D11Engine/D2DEditorView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,7 @@ void D2DEditorView::UpdateSelectionPanel() {
mi = nullptr;

// Get settings from MI, if possible
#if ENABLE_TESSELATION > 0
if ( mi ) {
SelectedTexDisplacementSlider->GetSlider()->SetValue( mi->TextureTesselationSettings.buffer.VT_DisplacementStrength );
SelectedMeshRoundnessSlider->GetSlider()->SetValue( mi->TextureTesselationSettings.buffer.VT_Roundness );
Expand All @@ -875,6 +876,11 @@ void D2DEditorView::UpdateSelectionPanel() {
SelectedMeshRoundnessSlider->GetSlider()->SetValue( info->TesselationSettings.buffer.VT_Roundness );
SelectedMeshTessAmountSlider->GetSlider()->SetValue( info->TesselationSettings.buffer.VT_TesselationFactor );
}
#else
SelectedTexDisplacementSlider->GetSlider()->SetValue( 0.f );
SelectedMeshRoundnessSlider->GetSlider()->SetValue( 0.f );
SelectedMeshTessAmountSlider->GetSlider()->SetValue( 0.f );
#endif
}
}

Expand Down Expand Up @@ -1084,8 +1090,10 @@ bool D2DEditorView::OnWindowMessage( HWND hWnd, unsigned int msg, WPARAM wParam,
MaterialInfo* info = Engine::GAPI->GetMaterialInfoFrom( Selection.SelectedMaterial->GetTexture() );

if ( info ) {
#if ENABLE_TESSELATION > 0
// Set the offline-tesselation factor
info->TextureTesselationSettings.buffer.VT_TesselationFactor = 2;
#endif

// Overwrite shader
info->TesselationShaderPair = "PNAEN_Tesselation";
Expand Down Expand Up @@ -1335,12 +1343,15 @@ void D2DEditorView::TextureSettingsSliderChanged( SV_Slider* sender, void* userd
} else if ( sender == v->SelectedTexSpecPowerSlider->GetSlider() ) {
info->buffer.SpecularPower = sender->GetValue();
} else if ( sender == v->SelectedTexDisplacementSlider->GetSlider() && v->Selection.SelectedMesh ) {
#if ENABLE_TESSELATION > 0
WorldMeshInfo* mesh = (WorldMeshInfo*)v->Selection.SelectedMesh; // TODO: Make this nicer
mesh->TesselationSettings.buffer.VT_DisplacementStrength = sender->GetValue();
mesh->TesselationSettings.UpdateConstantbuffer();

info->TextureTesselationSettings.buffer.VT_DisplacementStrength = sender->GetValue();
#endif
} else if ( sender == v->SelectedMeshTessAmountSlider->GetSlider() && v->Selection.SelectedMesh ) {
#if ENABLE_TESSELATION > 0
WorldMeshInfo* mesh = (WorldMeshInfo*)v->Selection.SelectedMesh; // TODO: Make this nicer

if ( !mesh->MeshIndexBufferPNAEN ) {
Expand All @@ -1352,12 +1363,15 @@ void D2DEditorView::TextureSettingsSliderChanged( SV_Slider* sender, void* userd
mesh->TesselationSettings.UpdateConstantbuffer();

info->TextureTesselationSettings.buffer.VT_TesselationFactor = sender->GetValue();
#endif
} else if ( sender == v->SelectedMeshRoundnessSlider->GetSlider() && v->Selection.SelectedMesh ) {
#if ENABLE_TESSELATION > 0
WorldMeshInfo* mesh = (WorldMeshInfo*)v->Selection.SelectedMesh; // TODO: Make this nicer
mesh->TesselationSettings.buffer.VT_Roundness = sender->GetValue();
mesh->TesselationSettings.UpdateConstantbuffer();

info->TextureTesselationSettings.buffer.VT_Roundness = sender->GetValue();
#endif
}

/*else if (sender == v->SelectedTexSpecModulationSlider->GetSlider())
Expand All @@ -1367,7 +1381,9 @@ void D2DEditorView::TextureSettingsSliderChanged( SV_Slider* sender, void* userd

// Update and save the info
info->UpdateConstantbuffer();
#if ENABLE_TESSELATION > 0
info->TextureTesselationSettings.UpdateConstantbuffer();
#endif
info->WriteToFile( v->Selection.SelectedMaterial->GetTexture()->GetNameWithoutExt() );
}
}
Expand All @@ -1386,6 +1402,7 @@ void D2DEditorView::SmoothMesh( WorldMeshInfo* mesh, bool tesselate ) {
mesh->Indices.clear();
MeshModifier::DropTexcoords(vxOld, ixOld, mesh->Vertices, mesh->Indices);*/

#if ENABLE_TESSELATION > 0
// Tesselate if the outcome would still be in 16-bit range
if ( tesselate && mesh->Vertices.size() + (mesh->Indices.size() / 3) < 0x0000FFFF ) {
std::vector<ExVertexStruct> meshTess;
Expand All @@ -1395,7 +1412,6 @@ void D2DEditorView::SmoothMesh( WorldMeshInfo* mesh, bool tesselate ) {
vx[1] = mesh->Vertices[mesh->Indices[i + 1]];
vx[2] = mesh->Vertices[mesh->Indices[i + 2]];


std::vector<ExVertexStruct> triTess;
WorldConverter::TesselateTriangle( vx, triTess, 1 );

Expand All @@ -1405,8 +1421,6 @@ void D2DEditorView::SmoothMesh( WorldMeshInfo* mesh, bool tesselate ) {
}
}



mesh->Vertices.clear();
mesh->Indices.clear();

Expand All @@ -1423,7 +1437,6 @@ void D2DEditorView::SmoothMesh( WorldMeshInfo* mesh, bool tesselate ) {
return;
}


// Cleanup
SAFE_DELETE(mesh->MeshVertexBuffer);
SAFE_DELETE(mesh->MeshIndexBuffer);
Expand All @@ -1442,6 +1455,7 @@ void D2DEditorView::SmoothMesh( WorldMeshInfo* mesh, bool tesselate ) {
mesh->TesselationSettings.buffer.VT_TesselationFactor = 2.0f;
mesh->TesselationSettings.buffer.VT_DisplacementStrength = 0.5f;
mesh->TesselationSettings.UpdateConstantbuffer();
#endif

// Mark dirty
mesh->SaveInfo = true;
Expand Down
3 changes: 3 additions & 0 deletions D3D11Engine/D2DSettingsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -718,4 +718,7 @@ void D2DSettingsDialog::SetHidden( bool hidden ) {
OnOpenedSettings(); // Changed visibility from hidden to non-hidden

D2DDialog::SetHidden( hidden );
if ( hidden ) {
Engine::GraphicsEngine->OnUIEvent( BaseGraphicsEngine::EUIEvent::UI_ClosedSettings );
}
}
16 changes: 16 additions & 0 deletions D3D11Engine/D2DVobSettingsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,14 @@ void D2DVobSettingsDialog::SliderDragged( SV_Slider* sender, void* userdata ) {
if ( !d->Vob )
return;

#if ENABLE_TESSELATION > 0
VisualTesselationSettings* ts = nullptr;
if ( d->Vob )
ts = &d->Vob->VisualInfo->TesselationInfo;
#endif

if ( sender == d->DisplacementStrengthSetting->GetSlider() ) {
#if ENABLE_TESSELATION > 0
float oldValue = ts->buffer.VT_DisplacementStrength;
ts->buffer.VT_DisplacementStrength = sender->GetValue();

Expand All @@ -123,24 +126,31 @@ void D2DVobSettingsDialog::SliderDragged( SV_Slider* sender, void* userdata ) {
d->Vob->VisualInfo->CreatePNAENInfo( true );
}
}
#endif
} else if ( sender == d->RoundnessSetting->GetSlider() ) {
#if ENABLE_TESSELATION > 0
ts->buffer.VT_Roundness = sender->GetValue();
#endif
} else if ( sender == d->TesselationFactorSetting->GetSlider() ) {
#if ENABLE_TESSELATION > 0
ts->buffer.VT_TesselationFactor = sender->GetValue();

if ( ts->buffer.VT_TesselationFactor > 0.0f ) {
if ( d->Vob )
d->Vob->VisualInfo->CreatePNAENInfo( ts->buffer.VT_DisplacementStrength > 0.0f ); // This only creates missing infos
}
#endif
} else if ( sender == d->RenderMode->GetSlider() ) {
d->MeshView->SetRenderMode( (SV_GMeshInfoView::ERenderMode)(int)(sender->GetValue() + 0.5f) );
}

#if ENABLE_TESSELATION > 0
// Save changes
d->Vob->VisualInfo->SaveMeshVisualInfo( d->Vob->VisualInfo->VisualName );

// Update everything
ts->UpdateConstantbuffer();
#endif
d->MeshView->UpdateView();
}

Expand All @@ -165,9 +175,15 @@ void D2DVobSettingsDialog::SetVobInfo( BaseVobInfo* vob ) {
}
}

#if ENABLE_TESSELATION > 0
RoundnessSetting->GetSlider()->SetValue( vob->VisualInfo->TesselationInfo.buffer.VT_Roundness );
TesselationFactorSetting->GetSlider()->SetValue( vob->VisualInfo->TesselationInfo.buffer.VT_TesselationFactor );
DisplacementStrengthSetting->GetSlider()->SetValue( vob->VisualInfo->TesselationInfo.buffer.VT_DisplacementStrength );
#else
RoundnessSetting->GetSlider()->SetValue( 0.f );
TesselationFactorSetting->GetSlider()->SetValue( 0.f );
DisplacementStrengthSetting->GetSlider()->SetValue( 0.f );
#endif

Vob = vob;

Expand Down
Loading

0 comments on commit 8a74726

Please sign in to comment.