Skip to content

Commit b0fabf6

Browse files
committed
Add spherical shader
1 parent b516629 commit b0fabf6

8 files changed

+918
-264
lines changed

Shaderbool.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ bool ShadowPlayerB = false;
1010
bool ShadowPropB = false;
1111
bool FragmentShadowB = false;
1212
bool TerrainB = false;
13-
bool DefaultB = false;
13+
bool DefaultB = false;
14+
bool SphericalB = false;

Shaders/Default.h

+271-194
Large diffs are not rendered by default.

Shaders/Spherical.h

+614
Large diffs are not rendered by default.

atelier-sync-fix.vcxproj

+8-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseLowSettings|x64'" Label="Configuration">
3939
<ConfigurationType>DynamicLibrary</ConfigurationType>
4040
<UseDebugLibraries>false</UseDebugLibraries>
41-
<PlatformToolset>ClangCL</PlatformToolset>
41+
<PlatformToolset>v143</PlatformToolset>
4242
<WholeProgramOptimization>true</WholeProgramOptimization>
4343
<CharacterSet>Unicode</CharacterSet>
4444
<LLVMToolsVersion>17</LLVMToolsVersion>
@@ -89,6 +89,9 @@
8989
<SDLCheck>true</SDLCheck>
9090
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
9191
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
92+
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
93+
<EnableEnhancedInstructionSet>AdvancedVectorExtensions</EnableEnhancedInstructionSet>
94+
<FloatingPointModel>Fast</FloatingPointModel>
9295
</ClCompile>
9396
<Link>
9497
<EnableCOMDATFolding>true</EnableCOMDATFolding>
@@ -104,7 +107,9 @@
104107
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
105108
<ExpandAttributedSource>false</ExpandAttributedSource>
106109
<AssemblerOutput>AssemblyCode</AssemblerOutput>
107-
<AdditionalOptions>-Ofast -mavx %(AdditionalOptions)</AdditionalOptions>
110+
<EnableEnhancedInstructionSet>AdvancedVectorExtensions</EnableEnhancedInstructionSet>
111+
<FloatingPointModel>Fast</FloatingPointModel>
112+
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
108113
</ClCompile>
109114
<Link>
110115
<EnableCOMDATFolding>true</EnableCOMDATFolding>
@@ -120,6 +125,7 @@
120125
<ClInclude Include="Shaders\Particle1.h" />
121126
<ClInclude Include="Shaders\RadialBlur.h" />
122127
<ClInclude Include="Shaders\Shadow.h" />
128+
<ClInclude Include="Shaders\Spherical.h" />
123129
<ClInclude Include="Shaders\Terrain.h" />
124130
<ClInclude Include="Shaders\Tex.h" />
125131
<ClInclude Include="Shaders\VolumeFog.h" />

atelier-sync-fix.vcxproj.filters

+3
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
<ClInclude Include="Shaders\Terrain.h">
4646
<Filter>Shaders</Filter>
4747
</ClInclude>
48+
<ClInclude Include="Shaders\Spherical.h">
49+
<Filter>Shaders</Filter>
50+
</ClInclude>
4851
</ItemGroup>
4952
<ItemGroup>
5053
<None Include=".gitignore" />

build-win64.txt

-15
This file was deleted.

impl.cpp

+20-2
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,15 @@
99
#include "Shaders/Particle1.h"
1010
#include "Shaders/RadialBlur.h"
1111
#include "Shaders/Shadow.h"
12+
#include "Shaders/Spherical.h"
1213
#include "Shaders/Terrain.h"
1314
#include "Shaders/Tex.h"
1415
#include "Shaders/VolumeFog.h"
1516
#include "util.h"
1617

17-
1818
namespace atfix {
1919

2020
extern "C" bool IsAMD();
21-
2221
/** Hooking-related stuff */
2322
using PFN_ID3D11Device_CreateVertexShader = HRESULT(STDMETHODCALLTYPE*) (ID3D11Device*, const void*, SIZE_T, ID3D11ClassLinkage*, ID3D11VertexShader**);
2423
using PFN_ID3D11Device_CreatePixelShader = HRESULT(STDMETHODCALLTYPE*) (ID3D11Device*, const void*, SIZE_T, ID3D11ClassLinkage*, ID3D11PixelShader**);
@@ -41,6 +40,10 @@ const DeviceProcs* getDeviceProcs(ID3D11Device* pDevice) {
4140
return &g_deviceProcs;
4241
}
4342

43+
// This game hates and crashes when other shaders
44+
// don't have a vertex shader when doing
45+
// pixel shader changes, but it's fine the other way around.
46+
4447
HRESULT STDMETHODCALLTYPE ID3D11Device_CreateVertexShader(
4548
ID3D11Device* pDevice,
4649
const void* pShaderBytecode,
@@ -155,6 +158,7 @@ HRESULT STDMETHODCALLTYPE ID3D11Device_CreatePixelShader(
155158
static constexpr std::array<uint32_t, 4> ShadowShader = { 0xbb5a2d0a, 0x29d139b7, 0x40992005, 0xf3b46588 };
156159
static constexpr std::array<uint32_t, 4> TerrainShader = { 0x74a9f538, 0x75cb0ce6, 0x3da09498, 0x7bc641bd };
157160
static constexpr std::array<uint32_t, 4> DefaultShader = { 0x5cbbb737, 0x265384da, 0x36d6d037, 0x1b052f54 };
161+
static constexpr std::array<uint32_t, 4> SphericalShader = { 0xba0db34b, 0xd2bc2581, 0x36622cd8, 0xacd2a10c };
158162

159163
const uint32_t* hash = reinterpret_cast<const uint32_t*>(reinterpret_cast<const uint8_t*>(pShaderBytecode) + 4);
160164

@@ -190,6 +194,13 @@ HRESULT STDMETHODCALLTYPE ID3D11Device_CreatePixelShader(
190194
return procs->CreatePixelShader(pDevice, SIMPLIFIED_FS_SHADOW_SHADER, sizeof(SIMPLIFIED_FS_SHADOW_SHADER), pClassLinkage, ppPixelShader);
191195

192196
}
197+
else if (std::equal(SphericalShader.begin(), SphericalShader.end(), hash)) {
198+
if (!SphericalB) {
199+
SphericalB = true;
200+
log("Spherical Map found");
201+
}
202+
return procs->CreatePixelShader(pDevice, SIMPLIFIED_FS_HIGH_SPHERICAL_SHADER, sizeof(SIMPLIFIED_FS_HIGH_SPHERICAL_SHADER), pClassLinkage, ppPixelShader);
203+
}
193204
#else
194205
else if (std::equal(TerrainShader.begin(), TerrainShader.end(), hash)) {
195206

@@ -198,6 +209,13 @@ HRESULT STDMETHODCALLTYPE ID3D11Device_CreatePixelShader(
198209
else if (std::equal(DefaultShader.begin(), DefaultShader.end(), hash)) {
199210

200211
return procs->CreatePixelShader(pDevice, SIMPLIFIED_FS_DEFAULT_SHADER, sizeof(SIMPLIFIED_FS_DEFAULT_SHADER), pClassLinkage, ppPixelShader);
212+
}
213+
else if (std::equal(SphericalShader.begin(), SphericalShader.end(), hash)) {
214+
if (!SphericalB) {
215+
SphericalB = true;
216+
log("Spherical Map found");
217+
}
218+
return procs->CreatePixelShader(pDevice, SIMPLIFIED_FS_LOW_SPHERICAL_SHADER, sizeof(SIMPLIFIED_FS_LOW_SPHERICAL_SHADER), pClassLinkage, ppPixelShader);
201219
}
202220
#endif
203221
return procs->CreatePixelShader(pDevice, pShaderBytecode, BytecodeLength, pClassLinkage, ppPixelShader);

meson.build

-50
This file was deleted.

0 commit comments

Comments
 (0)