diff --git a/D3D11Engine/BaseAntTweakBar.cpp b/D3D11Engine/BaseAntTweakBar.cpp index e2c2c293..dd6c5887 100644 --- a/D3D11Engine/BaseAntTweakBar.cpp +++ b/D3D11Engine/BaseAntTweakBar.cpp @@ -104,6 +104,7 @@ 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 ); + TwAddVarRW( Bar_General, "Fog Range", TwDefineEnumFromString( "FogRangeEnum", "3, 4, 5, 6, 7, 8, 9, 10" ), &Engine::GAPI->GetRendererState().RendererSettings.FogRange, nullptr ); #if ENABLE_TESSELATION > 0 TwAddVarRW( Bar_General, "Tesselation", TW_TYPE_BOOLCPP, &Engine::GAPI->GetRendererState().RendererSettings.EnableTesselation, nullptr ); #endif diff --git a/D3D11Engine/BaseGraphicsEngine.h b/D3D11Engine/BaseGraphicsEngine.h index ae2bb202..c2ccf013 100644 --- a/D3D11Engine/BaseGraphicsEngine.h +++ b/D3D11Engine/BaseGraphicsEngine.h @@ -181,7 +181,7 @@ class BaseGraphicsEngine { virtual INT2 GetBackbufferResolution() { return GetResolution(); } /** Returns the data of the backbuffer */ - virtual void GetBackbufferData( byte** data, int& pixelsize ) {} + virtual void GetBackbufferData( byte** data, INT2& buffersize, int& pixelsize ) {} /** Draws a fullscreenquad, copying the given texture to the viewport */ virtual void DrawQuad( INT2 position, INT2 size ) {} diff --git a/D3D11Engine/D3D11GraphicsEngine.cpp b/D3D11Engine/D3D11GraphicsEngine.cpp index f3172db0..19166870 100644 --- a/D3D11Engine/D3D11GraphicsEngine.cpp +++ b/D3D11Engine/D3D11GraphicsEngine.cpp @@ -447,7 +447,7 @@ XRESULT D3D11GraphicsEngine::Init() { // Create dummy rendertarget for shadowcubes DummyShadowCubemapTexture = std::make_unique( GetDevice(), POINTLIGHT_SHADOWMAP_SIZE, POINTLIGHT_SHADOWMAP_SIZE, - DXGI_FORMAT_R8G8B8A8_UNORM, nullptr, DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_B8G8R8A8_UNORM, nullptr, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, 1, 6 ); SteamOverlay::Init(); @@ -706,7 +706,7 @@ XRESULT D3D11GraphicsEngine::OnResize( INT2 newSize ) { LogInfo() << "SwapChain: DXGI_FEATURE_PRESENT_ALLOW_TEARING = " << (m_flipWithTearing ? "Enabled" : "Disabled"); } - LogInfo() << "Creating new swapchain! (Format: DXGI_FORMAT_R8G8B8A8_UNORM)"; + LogInfo() << "Creating new swapchain! (Format: DXGI_FORMAT_B8G8R8A8_UNORM)"; if ( m_swapchainflip ) { scd.BufferCount = 2; @@ -761,7 +761,7 @@ XRESULT D3D11GraphicsEngine::OnResize( INT2 newSize ) { // Need to init AntTweakBar now that we have a working swapchain XLE( Engine::AntTweakBar->Init() ); } else { - LogInfo() << "Resizing swapchain (Format: DXGI_FORMAT_R8G8B8A8_UNORM)"; + LogInfo() << "Resizing swapchain (Format: DXGI_FORMAT_B8G8R8A8_UNORM)"; if ( dxgi_1_5 ) { //if (FAILED(SwapChain4->SetSourceSize(bbres.x, bbres.y))) { //crashes when scd.Scaling = DXGI_SCALING_STRETCH is not set; if ( FAILED( SwapChain4->ResizeBuffers( 0, bbres.x, bbres.y, DXGI_FORMAT_B8G8R8A8_UNORM, scflags ) ) ) { @@ -870,7 +870,7 @@ XRESULT D3D11GraphicsEngine::OnResize( INT2 newSize ) { GetDevice().Get(), Resolution.x, Resolution.y, DXGI_FORMAT_R16G16B16A16_FLOAT ); GBuffer0_Diffuse = std::make_unique( - GetDevice().Get(), Resolution.x, Resolution.y, DXGI_FORMAT_R8G8B8A8_UNORM ); + GetDevice().Get(), Resolution.x, Resolution.y, DXGI_FORMAT_B8G8R8A8_UNORM ); HDRBackBuffer = std::make_unique( GetDevice().Get(), Resolution.x, Resolution.y, (Engine::GAPI->GetRendererState().RendererSettings.CompressBackBuffer ? DXGI_FORMAT_R11G11B10_FLOAT : DXGI_FORMAT_R16G16B16A16_FLOAT) ); @@ -1129,14 +1129,14 @@ XRESULT D3D11GraphicsEngine::FetchDisplayModeListDXGI() { } UINT numModes = 0; - hr = output->GetDisplayModeList1( DXGI_FORMAT_R8G8B8A8_UNORM, 0, &numModes, nullptr ); + hr = output->GetDisplayModeList1( DXGI_FORMAT_B8G8R8A8_UNORM, 0, &numModes, nullptr ); if ( FAILED( hr ) || numModes == 0 ) { CachedDisplayModes.emplace_back( Resolution.x, Resolution.y ); return XR_FAILED; } std::unique_ptr displayModes = std::make_unique( numModes ); - hr = output->GetDisplayModeList1( DXGI_FORMAT_R8G8B8A8_UNORM, 0, &numModes, displayModes.get() ); + hr = output->GetDisplayModeList1( DXGI_FORMAT_B8G8R8A8_UNORM, 0, &numModes, displayModes.get() ); if ( FAILED( hr ) ) { CachedDisplayModes.emplace_back( Resolution.x, Resolution.y ); return XR_FAILED; @@ -1899,8 +1899,9 @@ XRESULT D3D11GraphicsEngine::DrawSkeletalMesh( SkeletalVobInfo* vi, if ( zCMaterial* mat = itm.first ) { zCTexture* tex; if ( ActivePS && (tex = mat->GetAniTexture()) != nullptr ) { - if ( !BindTextureNRFX( tex, (RenderingStage != DES_GHOST) ) ) + if ( !BindTextureNRFX( tex, (RenderingStage != DES_GHOST) ) ) { continue; + } } } @@ -5474,9 +5475,9 @@ void D3D11GraphicsEngine::OnUIEvent( EUIEvent uiEvent ) { } /** Returns the data of the backbuffer */ -void D3D11GraphicsEngine::GetBackbufferData( byte** data, int& pixelsize ) { - constexpr int width = 256; - byte* d = new byte[width * width * 4]; +void D3D11GraphicsEngine::GetBackbufferData( byte** data, INT2& buffersize, int& pixelsize ) { + buffersize = Resolution; + byte* d = new byte[Resolution.x * Resolution.y * 4]; // Copy HDR scene to backbuffer SetDefaultStates(); @@ -5494,13 +5495,9 @@ void D3D11GraphicsEngine::GetBackbufferData( byte** data, int& pixelsize ) { ActivePS->GetConstantBuffer()[0]->BindToPixelShader( 0 ); HRESULT hr; - - // Buffer for scaling down the image auto rt = std::make_unique( - GetDevice().Get(), width, width, DXGI_FORMAT_R8G8B8A8_UNORM ); - - // Downscale to 256x256 - PfxRenderer->CopyTextureToRTV( HDRBackBuffer->GetShaderResView(), rt->GetRenderTargetView(), INT2( width, width ), + GetDevice().Get(), buffersize.x, buffersize.y, DXGI_FORMAT_B8G8R8A8_UNORM ); + PfxRenderer->CopyTextureToRTV( HDRBackBuffer->GetShaderResView(), rt->GetRenderTargetView(), INT2( buffersize.x, buffersize.y ), true ); GetContext()->Flush(); @@ -5508,10 +5505,9 @@ void D3D11GraphicsEngine::GetBackbufferData( byte** data, int& pixelsize ) { texDesc.ArraySize = 1; texDesc.BindFlags = 0; texDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ; - texDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; - texDesc.Width = width; // Gothic transforms the backbufferdata for - // savegamethumbs to 256x256-pictures anyways - texDesc.Height = width; + texDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; + texDesc.Width = buffersize.x; + texDesc.Height = buffersize.y; texDesc.MipLevels = 1; texDesc.MiscFlags = 0; texDesc.SampleDesc.Count = 1; @@ -5532,13 +5528,15 @@ void D3D11GraphicsEngine::GetBackbufferData( byte** data, int& pixelsize ) { if ( SUCCEEDED( GetContext()->Map( texture.Get(), 0, D3D11_MAP_READ, 0, &res ) ) ) { unsigned char* dstData = reinterpret_cast(res.pData); unsigned char* srcData = reinterpret_cast(d); - UINT length = width * 4; + UINT length = buffersize.x * 4; if ( length == res.RowPitch ) { - memcpy( srcData, dstData, length * width ); + memcpy( srcData, dstData, length * buffersize.y ); } else { - if ( length > res.RowPitch ) + if ( length > res.RowPitch ) { length = res.RowPitch; - for ( int row = 0; row < width; ++row ) { + } + + for ( int row = 0; row < buffersize.y; ++row ) { memcpy( srcData, dstData, length ); srcData += length; dstData += res.RowPitch; @@ -6267,7 +6265,7 @@ void D3D11GraphicsEngine::SaveScreenshot() { // Buffer for scaling down the image auto rt = std::make_unique( - GetDevice().Get(), Resolution.x, Resolution.y, DXGI_FORMAT_R8G8B8A8_UNORM ); + GetDevice().Get(), Resolution.x, Resolution.y, DXGI_FORMAT_B8G8R8A8_UNORM ); // Downscale to 256x256 PfxRenderer->CopyTextureToRTV( HDRBackBuffer->GetShaderResView(), rt->GetRenderTargetView() ); @@ -6276,7 +6274,7 @@ void D3D11GraphicsEngine::SaveScreenshot() { texDesc.ArraySize = 1; texDesc.BindFlags = 0; texDesc.CPUAccessFlags = 0; - texDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + texDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; texDesc.Width = Resolution.x; // must be same as backbuffer texDesc.Height = Resolution.y; // must be same as backbuffer texDesc.MipLevels = 1; diff --git a/D3D11Engine/D3D11GraphicsEngine.h b/D3D11Engine/D3D11GraphicsEngine.h index 29a43b64..6b4556a6 100644 --- a/D3D11Engine/D3D11GraphicsEngine.h +++ b/D3D11Engine/D3D11GraphicsEngine.h @@ -215,7 +215,7 @@ class D3D11GraphicsEngine : public D3D11GraphicsEngineBase { INT2 GetBackbufferResolution(); /** Returns the data of the backbuffer */ - void GetBackbufferData( byte** data, int& pixelsize ); + void GetBackbufferData( byte** data, INT2& buffersize, int& pixelsize ); /** Returns the line renderer object */ BaseLineRenderer* GetLineRenderer(); diff --git a/D3D11Engine/D3D11PFX_HeightFog.cpp b/D3D11Engine/D3D11PFX_HeightFog.cpp index 4c88a773..1a3f6a5a 100644 --- a/D3D11Engine/D3D11PFX_HeightFog.cpp +++ b/D3D11Engine/D3D11PFX_HeightFog.cpp @@ -48,7 +48,7 @@ XRESULT D3D11PFX_HeightFog::Render( RenderToTextureBuffer* fxbuffer ) { float fnear = 15000.0f; float ffar = 60000.0f; - float secScale = Engine::GAPI->GetRendererState().RendererSettings.SectionDrawRadius; + float secScale = std::min( Engine::GAPI->GetRendererState().RendererSettings.SectionDrawRadius, Engine::GAPI->GetRendererState().RendererSettings.FogRange + 3 ); cb.HF_WeightZNear = std::max( 0.0f, WORLD_SECTION_SIZE * ((secScale - 0.5f) * 0.7f) - (ffar - fnear) ); // Keep distance from original fog but scale the near-fog up to section draw distance cb.HF_WeightZFar = WORLD_SECTION_SIZE * ((secScale - 0.5f) * 0.8f); diff --git a/D3D11Engine/D3D11PFX_SMAA.cpp b/D3D11Engine/D3D11PFX_SMAA.cpp index 88067de8..6c7909de 100644 --- a/D3D11Engine/D3D11PFX_SMAA.cpp +++ b/D3D11Engine/D3D11PFX_SMAA.cpp @@ -193,10 +193,10 @@ void D3D11PFX_SMAA::OnResize( const INT2& size ) { HRESULT hr = S_OK; // Create Edges- and Blend-Textures - EdgesTex = new RenderToTextureBuffer( engine->GetDevice().Get(), size.x, size.y, DXGI_FORMAT_R8G8B8A8_UNORM, &hr ); + EdgesTex = new RenderToTextureBuffer( engine->GetDevice().Get(), size.x, size.y, DXGI_FORMAT_B8G8R8A8_UNORM, &hr ); LE( hr ); - BlendTex = new RenderToTextureBuffer( engine->GetDevice().Get(), size.x, size.y, DXGI_FORMAT_R8G8B8A8_UNORM, &hr ); + BlendTex = new RenderToTextureBuffer( engine->GetDevice().Get(), size.x, size.y, DXGI_FORMAT_B8G8R8A8_UNORM, &hr ); LE( hr ); std::vector Makros; diff --git a/D3D11Engine/D3D11Texture.cpp b/D3D11Engine/D3D11Texture.cpp index cfa0ceea..9e46b248 100644 --- a/D3D11Engine/D3D11Texture.cpp +++ b/D3D11Engine/D3D11Texture.cpp @@ -147,7 +147,7 @@ UINT D3D11Texture::GetRowPitchBytes( int mip ) { if ( TextureFormat == DXGI_FORMAT_BC1_UNORM || TextureFormat == DXGI_FORMAT_BC2_UNORM || TextureFormat == DXGI_FORMAT_BC3_UNORM ) { return Toolbox::GetDDSRowPitchSize( px, TextureFormat == DXGI_FORMAT_BC1_UNORM ); - } else { // Use R8G8B8A8 + } else { // Use B8G8R8A8 return px * 4; } } @@ -160,7 +160,7 @@ UINT D3D11Texture::GetSizeInBytes( int mip ) { if ( TextureFormat == DXGI_FORMAT_BC1_UNORM || TextureFormat == DXGI_FORMAT_BC2_UNORM || TextureFormat == DXGI_FORMAT_BC3_UNORM ) { return Toolbox::GetDDSStorageRequirements( px, py, TextureFormat == DXGI_FORMAT_BC1_UNORM ); - } else { // Use R8G8B8A8 + } else { // Use B8G8R8A8 return px * py * 4; } } @@ -195,7 +195,7 @@ XRESULT D3D11Texture::CreateThumbnail() { // Create texture CD3D11_TEXTURE2D_DESC textureDesc( - DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_B8G8R8A8_UNORM, 256, 256, 1, @@ -241,7 +241,7 @@ XRESULT D3D11Texture::GenerateMipMaps() { D3D11GraphicsEngineBase* engine = reinterpret_cast(Engine::GraphicsEngine); std::unique_ptr b = std::make_unique( engine->GetDevice().Get(), TextureSize.x, TextureSize.y, - DXGI_FORMAT_R8G8B8A8_UNORM, nullptr, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, MipMapCount ); + DXGI_FORMAT_B8G8R8A8_UNORM, nullptr, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, MipMapCount ); // Copy the main image engine->GetContext()->CopySubresourceRegion( b->GetTexture().Get(), 0, 0, 0, 0, Texture.Get(), 0, nullptr ); diff --git a/D3D11Engine/D3D11Texture.h b/D3D11Engine/D3D11Texture.h index 99c832cd..c990777f 100644 --- a/D3D11Engine/D3D11Texture.h +++ b/D3D11Engine/D3D11Texture.h @@ -8,7 +8,7 @@ class D3D11Texture { /** Layec out for DXGI */ enum ETextureFormat { - TF_R8G8B8A8 = DXGI_FORMAT_R8G8B8A8_UNORM, + TF_B8G8R8A8 = DXGI_FORMAT_B8G8R8A8_UNORM, TF_DXT1 = DXGI_FORMAT_BC1_UNORM, TF_DXT3 = DXGI_FORMAT_BC2_UNORM, TF_DXT5 = DXGI_FORMAT_BC3_UNORM diff --git a/D3D11Engine/D3D7/Conversions.h b/D3D11Engine/D3D7/Conversions.h index fa5bacad..05cf0f7b 100644 --- a/D3D11Engine/D3D7/Conversions.h +++ b/D3D11Engine/D3D7/Conversions.h @@ -33,9 +33,9 @@ static void Convert565to8888(unsigned char* dst, unsigned char* src, UINT realDa unsigned char greenComponent = ((pixel_data >> 5) & 63) << 2; unsigned char blueComponent = ((pixel_data >> 11) & 31) << 3; - dst[4 * i + 2] = redComponent; + dst[4 * i + 2] = blueComponent; dst[4 * i + 1] = greenComponent; - dst[4 * i + 0] = blueComponent; + dst[4 * i + 0] = redComponent; dst[4 * i + 3] = 255; } } @@ -53,9 +53,9 @@ static void Convert1555to8888(unsigned char* dst, unsigned char* src, UINT realD unsigned char blueComponent = ((pixel_data >> 10) & 31) << 3; unsigned char alphaComponent = (pixel_data >> 15) * 0xFF; - dst[4 * i + 2] = redComponent; + dst[4 * i + 2] = blueComponent; dst[4 * i + 1] = greenComponent; - dst[4 * i + 0] = blueComponent; + dst[4 * i + 0] = redComponent; dst[4 * i + 3] = alphaComponent; } } @@ -73,9 +73,9 @@ static void Convert4444to8888(unsigned char* dst, unsigned char* src, UINT realD unsigned char blueComponent = ((pixel_data >> 8) & 15) << 4; unsigned char alphaComponent = ((pixel_data >> 12) & 15) << 4; - dst[4 * i + 2] = redComponent; + dst[4 * i + 2] = blueComponent; dst[4 * i + 1] = greenComponent; - dst[4 * i + 0] = blueComponent; + dst[4 * i + 0] = redComponent; dst[4 * i + 3] = alphaComponent; } } diff --git a/D3D11Engine/D3D7/MyDirectDraw.h b/D3D11Engine/D3D7/MyDirectDraw.h index 40fb176b..f572cc46 100644 --- a/D3D11Engine/D3D7/MyDirectDraw.h +++ b/D3D11Engine/D3D7/MyDirectDraw.h @@ -200,7 +200,7 @@ class MyDirectDraw : public IDirectDraw7 { break; } } else { - fmt = DXGI_FORMAT_R8G8B8A8_UNORM; + fmt = DXGI_FORMAT_B8G8R8A8_UNORM; bpp = 32; } diff --git a/D3D11Engine/D3D7/MyDirectDrawSurface7.cpp b/D3D11Engine/D3D7/MyDirectDrawSurface7.cpp index fe076c76..44865d5d 100644 --- a/D3D11Engine/D3D7/MyDirectDrawSurface7.cpp +++ b/D3D11Engine/D3D7/MyDirectDrawSurface7.cpp @@ -320,22 +320,23 @@ HRESULT MyDirectDrawSurface7::Lock( LPRECT lpDestRect, LPDDSURFACEDESC2 lpDDSurf { // Assume 32-bit byte* data; + INT2 buffersize; int pixelSize; reinterpret_cast(Engine::GraphicsEngine)->ResetPresentPending(); Engine::GraphicsEngine->OnStartWorldRendering(); - Engine::GraphicsEngine->GetBackbufferData( &data, pixelSize ); + Engine::GraphicsEngine->GetBackbufferData( &data, buffersize, pixelSize ); reinterpret_cast(Engine::GraphicsEngine)->ResetPresentPending(); lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount = 32; - lpDDSurfaceDesc->ddpfPixelFormat.dwRBitMask = 0x000000FF; + lpDDSurfaceDesc->ddpfPixelFormat.dwRBitMask = 0x00FF0000; lpDDSurfaceDesc->ddpfPixelFormat.dwGBitMask = 0x0000FF00; - lpDDSurfaceDesc->ddpfPixelFormat.dwBBitMask = 0x00FF0000; + lpDDSurfaceDesc->ddpfPixelFormat.dwBBitMask = 0x000000FF; lpDDSurfaceDesc->ddpfPixelFormat.dwRGBAlphaBitMask = 0x00000000; // Gothic transforms this into a 256x256 texture anyways - lpDDSurfaceDesc->lPitch = 256 * pixelSize; - lpDDSurfaceDesc->dwWidth = 256; - lpDDSurfaceDesc->dwHeight = 256; + lpDDSurfaceDesc->lPitch = buffersize.x * pixelSize; + lpDDSurfaceDesc->dwWidth = buffersize.x; + lpDDSurfaceDesc->dwHeight = buffersize.y; lpDDSurfaceDesc->lpSurface = data; LockedData = data; @@ -535,15 +536,15 @@ HRESULT MyDirectDrawSurface7::SetSurfaceDesc( LPDDSURFACEDESC2 lpDDSurfaceDesc, int bpp = redBits + greenBits + blueBits + alphaBits; // Find out format - D3D11Texture::ETextureFormat format = D3D11Texture::ETextureFormat::TF_R8G8B8A8; + D3D11Texture::ETextureFormat format = D3D11Texture::ETextureFormat::TF_B8G8R8A8; switch ( bpp ) { case 16: - format = D3D11Texture::ETextureFormat::TF_R8G8B8A8; + format = D3D11Texture::ETextureFormat::TF_B8G8R8A8; break; case 24: case 32: - format = D3D11Texture::ETextureFormat::TF_R8G8B8A8; + format = D3D11Texture::ETextureFormat::TF_B8G8R8A8; break; case 0: diff --git a/D3D11Engine/DLLMain.cpp b/D3D11Engine/DLLMain.cpp index 9f8d9fc9..a63ea182 100644 --- a/D3D11Engine/DLLMain.cpp +++ b/D3D11Engine/DLLMain.cpp @@ -217,7 +217,9 @@ int WINAPI hooked_WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR l // Remove automatic volume change of sounds regarding whether the camera is indoor or outdoor // TODO: Implement! if ( !GMPModeActive ) { + DetourTransactionBegin(); DetourAttach( &reinterpret_cast(HookedFunctions::OriginalFunctions.original_zCActiveSndAutoCalcObstruction), HookedFunctionInfo::hooked_zCActiveSndAutoCalcObstruction ); + DetourTransactionCommit(); } return originalWinMain( hInstance, hPrevInstance, lpCmdLine, nShowCmd ); } diff --git a/D3D11Engine/GOcean.cpp b/D3D11Engine/GOcean.cpp index fc5d5f4c..18339470 100644 --- a/D3D11Engine/GOcean.cpp +++ b/D3D11Engine/GOcean.cpp @@ -136,7 +136,7 @@ void GOcean::CreateFresnelMap( Microsoft::WRL::ComPtr pd3dDevice tex_desc.Width = FRESNEL_TEX_SIZE; tex_desc.MipLevels = 1; tex_desc.ArraySize = 1; - tex_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + tex_desc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; tex_desc.Usage = D3D11_USAGE_IMMUTABLE; tex_desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; tex_desc.CPUAccessFlags = 0; @@ -154,7 +154,7 @@ void GOcean::CreateFresnelMap( Microsoft::WRL::ComPtr pd3dDevice // Create shader resource D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc = {}; - srv_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + srv_desc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; srv_desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE1D; srv_desc.Texture1D.MipLevels = 1; srv_desc.Texture1D.MostDetailedMip = 0; diff --git a/D3D11Engine/GothicAPI.cpp b/D3D11Engine/GothicAPI.cpp index 40d61584..b50c53d6 100644 --- a/D3D11Engine/GothicAPI.cpp +++ b/D3D11Engine/GothicAPI.cpp @@ -1373,22 +1373,22 @@ void GothicAPI::OnVisualDeleted( zCVisual* visual ) { delete SkeletalMeshVisuals[str]; SkeletalMeshVisuals.erase( str ); } + } - zCVob* homeVob = zmodel->GetHomeVob(); - if ( homeVob && homeVob->GetVobType() == zVOB_TYPE_NSC ) { - oCNPC* npc = static_cast(homeVob); - auto it = SkeletalMeshNpcs.find( npc ); - if ( it != SkeletalMeshNpcs.end() ) { - // Find vobs using this visual - for ( SkeletalVobInfo* vobInfo : SkeletalMeshVobs ) { - if ( vobInfo->VisualInfo == it->second ) { - vobInfo->VisualInfo = nullptr; - } + zCVob* homeVob = zmodel->GetHomeVob(); + if ( homeVob && homeVob->GetVobType() == zVOB_TYPE_NSC ) { + oCNPC* npc = static_cast(homeVob); + auto it = SkeletalMeshNpcs.find( npc ); + if ( it != SkeletalMeshNpcs.end() ) { + // Find vobs using this visual + for ( SkeletalVobInfo* vobInfo : SkeletalMeshVobs ) { + if ( vobInfo->VisualInfo == it->second ) { + vobInfo->VisualInfo = nullptr; } - - delete SkeletalMeshNpcs[npc]; - SkeletalMeshNpcs.erase( npc ); } + + delete SkeletalMeshNpcs[npc]; + SkeletalMeshNpcs.erase( npc ); } } break; @@ -3944,6 +3944,7 @@ XRESULT GothicAPI::SaveMenuSettings( const std::string& file ) { WritePrivateProfileStringA( "General", "ChangeToMode", std::to_string( s.ChangeWindowPreset ).c_str(), ini.c_str() ); WritePrivateProfileStringA( "General", "AtmosphericScattering", std::to_string( s.AtmosphericScattering ? TRUE : FALSE ).c_str(), ini.c_str() ); WritePrivateProfileStringA( "General", "EnableFog", std::to_string( s.DrawFog ? TRUE : FALSE ).c_str(), ini.c_str() ); + WritePrivateProfileStringA( "General", "FogRange", std::to_string( s.FogRange ).c_str(), ini.c_str() ); WritePrivateProfileStringA( "General", "EnableHDR", std::to_string( s.EnableHDR ? TRUE : FALSE ).c_str(), ini.c_str() ); WritePrivateProfileStringA( "General", "HDRToneMap", std::to_string( s.HDRToneMap ).c_str(), ini.c_str() ); WritePrivateProfileStringA( "General", "EnableDebugLog", std::to_string( s.EnableDebugLog ? TRUE : FALSE ).c_str(), ini.c_str() ); @@ -4037,6 +4038,7 @@ XRESULT GothicAPI::LoadMenuSettings( const std::string& file ) { s.ChangeWindowPreset = GetPrivateProfileIntA( "General", "ChangeToMode", 0, ini.c_str() ); s.DrawFog = GetPrivateProfileBoolA( "General", "EnableFog", true, ini ); + s.FogRange = GetPrivateProfileIntA( "General", "FogRange", 0, ini.c_str() ); s.AtmosphericScattering = GetPrivateProfileBoolA( "General", "AtmosphericScattering", true, ini ); s.EnableHDR = GetPrivateProfileBoolA( "General", "EnableHDR", false, ini ); s.HDRToneMap = GothicRendererSettings::E_HDRToneMap( GetPrivateProfileIntA( "General", "HDRToneMap", 4, ini.c_str() ) ); diff --git a/D3D11Engine/GothicGraphicsState.h b/D3D11Engine/GothicGraphicsState.h index c42dcb02..86999ab9 100644 --- a/D3D11Engine/GothicGraphicsState.h +++ b/D3D11Engine/GothicGraphicsState.h @@ -529,6 +529,7 @@ struct GothicRendererSettings { DrawSky = true; DrawFog = true; + FogRange = 0; EnableHDR = false; HDRToneMap = E_HDRToneMap::ToneMap_Simple; ReplaceSunDirection = false; @@ -710,6 +711,7 @@ struct GothicRendererSettings { bool DrawParticleEffects; bool DrawSky; bool DrawFog; + int FogRange; bool DrawG1ForestPortals; bool EnableHDR; E_HDRToneMap HDRToneMap; diff --git a/D3D11Engine/SV_GMeshInfoView.cpp b/D3D11Engine/SV_GMeshInfoView.cpp index baf99e14..0a43e6e8 100644 --- a/D3D11Engine/SV_GMeshInfoView.cpp +++ b/D3D11Engine/SV_GMeshInfoView.cpp @@ -223,7 +223,7 @@ void SV_GMeshInfoView::SetRect( const D2D1_RECT_F& rect ) { // Create new RT delete RT; - RT = new RenderToTextureBuffer( g->GetDevice().Get(), std::max( 8, GetSize().width ), std::max( 8, GetSize().height ), DXGI_FORMAT_R8G8B8A8_UNORM ); + RT = new RenderToTextureBuffer( g->GetDevice().Get(), std::max( 8, GetSize().width ), std::max( 8, GetSize().height ), DXGI_FORMAT_B8G8R8A8_UNORM ); delete DS; DS = new RenderToDepthStencilBuffer( g->GetDevice().Get(), std::max( 8, GetSize().width ), std::max( 8, GetSize().height ), DXGI_FORMAT_R32_TYPELESS, nullptr, DXGI_FORMAT_D32_FLOAT, DXGI_FORMAT_R32_FLOAT ); diff --git a/D3D11Engine/SV_Panel.cpp b/D3D11Engine/SV_Panel.cpp index f8c2df7c..f753147c 100644 --- a/D3D11Engine/SV_Panel.cpp +++ b/D3D11Engine/SV_Panel.cpp @@ -105,7 +105,7 @@ HRESULT SV_Panel::SetD3D11TextureAsImage( ID3D11Texture2D* texture, INT2 size ) // Since D2D can't load DXTn-Textures on Windows 7, we copy it over to a smaller texture here in d3d11 // Create texture - CD3D11_TEXTURE2D_DESC textureDesc( DXGI_FORMAT_R8G8B8A8_UNORM, size.x, size.y, 1, 1, 0, D3D11_USAGE_STAGING, D3D11_CPU_ACCESS_READ, 1, 0, 0 ); + CD3D11_TEXTURE2D_DESC textureDesc( DXGI_FORMAT_B8G8R8A8_UNORM, size.x, size.y, 1, 1, 0, D3D11_USAGE_STAGING, D3D11_CPU_ACCESS_READ, 1, 0, 0 ); ComPtr staging; LE( engine->GetDevice()->CreateTexture2D( &textureDesc, nullptr, staging.ReleaseAndGetAddressOf() ) ); @@ -113,7 +113,7 @@ HRESULT SV_Panel::SetD3D11TextureAsImage( ID3D11Texture2D* texture, INT2 size ) engine->GetContext()->CopyResource( staging.Get(), texture ); D2D1_BITMAP_PROPERTIES properties; - properties = D2D1::BitmapProperties( D2D1::PixelFormat( DXGI_FORMAT_R8G8B8A8_UNORM, D2D1_ALPHA_MODE_IGNORE ), 0, 0 ); + properties = D2D1::BitmapProperties( D2D1::PixelFormat( DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_IGNORE ), 0, 0 ); // Get data out D3D11_MAPPED_SUBRESOURCE mapped; diff --git a/D3D11Engine/pch.h b/D3D11Engine/pch.h index 079f2a14..062c16ec 100644 --- a/D3D11Engine/pch.h +++ b/D3D11Engine/pch.h @@ -33,7 +33,7 @@ using namespace DirectX; #define ENABLE_TESSELATION 0 #ifndef VERSION_NUMBER -#define VERSION_NUMBER "17.8-dev11" +#define VERSION_NUMBER "17.8-dev12" #endif __declspec(selectany) const char* VERSION_NUMBER_STR = VERSION_NUMBER; diff --git a/D3D11Engine/zBinkPlayer.cpp b/D3D11Engine/zBinkPlayer.cpp index 3c17767c..4dfb778b 100644 --- a/D3D11Engine/zBinkPlayer.cpp +++ b/D3D11Engine/zBinkPlayer.cpp @@ -239,7 +239,7 @@ int __fastcall BinkPlayerPlayFrame(DWORD BinkPlayer) DWORD vidHeight = *reinterpret_cast(reinterpret_cast(video->vid) + 0x04); if(!video->texture || video->width != vidWidth || video->height != vidHeight) { - video->useBGRA = false; + video->useBGRA = true; video->width = vidWidth; video->height = vidHeight; if(video->texture) @@ -260,23 +260,15 @@ int __fastcall BinkPlayerPlayFrame(DWORD BinkPlayer) ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat); ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS; ddsd.ddpfPixelFormat.dwRGBBitCount = 32; - ddsd.ddpfPixelFormat.dwRBitMask = 0x000000FF; + ddsd.ddpfPixelFormat.dwRBitMask = 0x00FF0000; ddsd.ddpfPixelFormat.dwGBitMask = 0x0000FF00; - ddsd.ddpfPixelFormat.dwBBitMask = 0x00FF0000; + ddsd.ddpfPixelFormat.dwBBitMask = 0x000000FF; ddsd.ddpfPixelFormat.dwRGBAlphaBitMask = 0xFF000000; HRESULT hr = (*reinterpret_cast(GothicMemoryLocations::zCRndD3D::DDRAW7))->CreateSurface(&ddsd, &video->texture, nullptr); if(FAILED(hr)) { - video->useBGRA = true; - ddsd.ddpfPixelFormat.dwRBitMask = 0x00FF0000; - ddsd.ddpfPixelFormat.dwGBitMask = 0x0000FF00; - ddsd.ddpfPixelFormat.dwBBitMask = 0x000000FF; - hr = (*reinterpret_cast(GothicMemoryLocations::zCRndD3D::DDRAW7))->CreateSurface(&ddsd, &video->texture, nullptr); - if(FAILED(hr)) - { - *reinterpret_cast(BinkPlayer + GothicMemoryLocations::zCBinkPlayer::Offset_IsPlaying) = 0; - return 0; - } + *reinterpret_cast(BinkPlayer + GothicMemoryLocations::zCBinkPlayer::Offset_IsPlaying) = 0; + return 0; } video->scaleTU = 1.0f / ddsd.dwWidth; diff --git a/Launcher/ddraw.def b/Launcher/ddraw.def index 5dad6b26..ac7948ce 100644 --- a/Launcher/ddraw.def +++ b/Launcher/ddraw.def @@ -1,5 +1,6 @@ LIBRARY "ddraw" EXPORTS + IsUsingBGRATextures = FakeIsUsingBGRATextures DirectDrawCreateEx = FakeDirectDrawCreateEx AcquireDDThreadLock = FakeAcquireDDThreadLock @1 CheckFullscreen = FakeCheckFullscreen @2 diff --git a/Launcher/dllmain.cpp b/Launcher/dllmain.cpp index 4552865a..cc7f38b0 100644 --- a/Launcher/dllmain.cpp +++ b/Launcher/dllmain.cpp @@ -83,7 +83,7 @@ __declspec(naked) void FakeGDX_SetWorldAOStrength() { _asm { jmp[ddraw.GDX_SetWo __declspec(naked) void FakeGDX_OpenMessageBox() { _asm { jmp[ddraw.GDX_OpenMessageBox] } } __declspec(naked) void FakeUpdateCustomFontMultiplier() { _asm { jmp[ddraw.UpdateCustomFontMultiplier] } } - +bool FakeIsUsingBGRATextures() { return true; } extern "C" HMODULE WINAPI FakeGDX_Module() { return ddraw.dll;