Skip to content

Commit d7b7cd5

Browse files
authored
Merge pull request #27 from Deamon87/development
Update for 10.1
2 parents 882db52 + d8e8f81 commit d7b7cd5

File tree

11 files changed

+129
-94
lines changed

11 files changed

+129
-94
lines changed

src/main.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ static LONG WINAPI windows_exception_handler(EXCEPTION_POINTERS * ExceptionInfo)
323323
double currentFrame;
324324
double lastFrame;
325325

326-
int main(){
326+
int main(int argc, char *argv[]) {
327327
// std::ofstream out("log.txt");
328328
// std::streambuf *coutbuf = std::cout.rdbuf(); //save old buf
329329
// std::cout.rdbuf(out.rdbuf()); //redirect std::cout to out.txt!
@@ -352,8 +352,12 @@ int main(){
352352
#endif
353353

354354
// std::string rendererName = "ogl2";
355-
// std::string rendererName = "ogl3";
356-
std::string rendererName = "vulkan";
355+
std::string rendererName = "ogl3";
356+
// std::string rendererName = "vulkan";
357+
358+
if (argc > 1 && std::string(argv[1]) == "-vulkan") {
359+
rendererName = "vulkan";
360+
}
357361

358362
//FOR OGL
359363

src/ui/FrontendUI.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -715,8 +715,8 @@ void FrontendUI::showQuickLinksDialog() {
715715
std::vector<int> replacementTextureFDids = {};
716716

717717
ImGui::Begin("Quick Links", &showQuickLinks);
718-
if (ImGui::Button("nightborne model", ImVec2(-1, 0))) {
719-
openM2SceneByfdid(1810676, replacementTextureFDids);
718+
if (ImGui::Button("Primal enchant", ImVec2(-1, 0))) {
719+
openM2SceneByfdid(4636728, replacementTextureFDids);
720720
}
721721
if (ImGui::Button("Tomb of sargares hall", ImVec2(-1, 0))) {
722722
openMapByIdAndWDTId(1676, 1532459, 6289, -801, 3028);

src/ui/childWindow/databaseUpdateWorkflow/DatabaseUpdateWorkflow.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "../../../../3rdparty/DBImporter/fileReaders/DBD/DBDFileStorage.h"
1212
#include "../../../../3rdparty/DBImporter/exporters/sqlite/CSQLLiteExporter.h"
1313
#include "../../../../3rdparty/DBImporter/importers/WDC3/WDC3Importer.h"
14+
#include "../../../../3rdparty/DBImporter/fileReaders/WDC4/DB2Ver4.h"
1415

1516
struct RequiredTableStruct {
1617
int fileDataId;
@@ -195,7 +196,13 @@ void DatabaseUpdateWorkflow::db2UpdateLogic() {
195196
std::shared_ptr<CSQLLiteExporter> csqlLiteExporter = std::make_shared<CSQLLiteExporter>("export.db3");
196197

197198
addTableLambda = [fileDBDStorage, csqlLiteExporter](std::string tableName, std::shared_ptr<Db2File> db2File) -> bool {
198-
std::shared_ptr<WDC3::DB2Base> db2Base = std::make_shared<WDC3::DB2Base>();
199+
std::shared_ptr<WDC3::DB2Ver3> db2Base = nullptr;
200+
if (*(uint32_t *)db2File->getContent()->data() == '4CDW') {
201+
db2Base = std::make_shared<WDC4::DB2Ver4>();
202+
} else {
203+
db2Base = std::make_shared<WDC3::DB2Ver3>();
204+
}
205+
199206
db2Base->process(db2File->getContent(), "");
200207

201208
DBDFile::BuildConfig *buildConfig = nullptr;

wowViewerLib/shaders/glsl/common/commonFunctions.glsl

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
vec2 posToTexCoord(vec3 cameraPoint, vec3 normal){
2-
// vec3 normPos = -normalize(cameraPoint.xyz);
3-
// vec3 normPos = cameraPoint.xyz;
4-
// vec3 reflection = reflect(normPos, normal);
5-
// return (normalize(vec3(reflection.r, reflection.g, reflection.b + 1.0)).rg * 0.5) + vec2(0.5);
6-
7-
vec3 normPos_495 = normalize(cameraPoint.xyz);
8-
vec3 temp_500 = (normPos_495 - (normal * (2.0 * dot(normPos_495, normal))));
9-
vec3 temp_657 = vec3(temp_500.x, temp_500.y, (temp_500.z + 1.0));
1+
vec2 posToTexCoord(const vec3 vertexPosInView, const vec3 normal){
2+
//Blizz seems to have vertex in view space as vector from "vertex to eye", while in this implementation, it's
3+
//vector from "eye to vertex". So the minus here is not needed
4+
//vec3 viewVecNormalized = -normalize(cameraPoint.xyz);
5+
vec3 viewVecNormalized = normalize(vertexPosInView.xyz);
6+
vec3 reflection = reflect(viewVecNormalized, normalize(normal));
7+
vec3 temp_657 = vec3(reflection.x, reflection.y, (reflection.z + 1.0));
108

119
return ((normalize(temp_657).xy * 0.5) + vec2(0.5));
1210
}
@@ -24,3 +22,29 @@ mat3 blizzTranspose(mat4 value) {
2422
);
2523
}
2624

25+
26+
#ifdef FRAGMENT_SHADER
27+
//From: https://pdfslide.tips/technology/shaderx5-26normalmappingwithoutprecomputedtangents-130318-1.html?page=14
28+
mat3 contangent_frame(vec3 N, vec3 p, vec2 uv)
29+
{
30+
// Get edge vectors of the pixel triangle
31+
vec3 dp1 = dFdx(p);
32+
vec3 dp2 = dFdy(p);
33+
vec2 duv1 = dFdx(uv);
34+
vec2 duv2 = dFdy(uv);
35+
// Solve the linear system
36+
vec3 dp2perp = cross(dp2, N);
37+
vec3 dp1perp = cross(N, dp1);
38+
vec3 T = dp2perp * duv1.x + dp1perp * duv2.x;
39+
vec3 B = dp2perp * duv1.y + dp1perp * duv2.y;
40+
// Construct a scale-invariant frame
41+
float invmax = inversesqrt(max(dot(T,T), dot(B,B)));
42+
return mat3(T * invmax, B * invmax, N);
43+
}
44+
#else
45+
//Temp implementation.
46+
//TODO: add implementation for raytracing case
47+
mat3 contangent_frame(vec3 N, vec3 p, vec2 uv) {
48+
return mat3(1.0);
49+
}
50+
#endif

wowViewerLib/shaders/glsl/vulkan/m2ParticleShader.frag

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ layout(std140, binding=4) uniform meshWideBlockPS {
2727
};
2828

2929
layout(set=1,binding=5) uniform sampler2D uTexture;
30+
3031
layout(set=1,binding=6) uniform sampler2D uTexture2;
3132
layout(set=1,binding=7) uniform sampler2D uTexture3;
3233

wowViewerLib/shaders/glsl/vulkan/wmoShader.frag

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
precision highp float;
55
precision highp int;
66

7+
#define FRAGMENT_SHADER
8+
79
#include "../common/commonLightFunctions.glsl"
810
#include "../common/commonFogFunctions.glsl"
911
#include "../common/commonFunctions.glsl"
@@ -159,7 +161,7 @@ void main() {
159161
finalOpacity = tex.a;
160162
} else if (uPixelShader == 7) { //MapObjTwoLayerEnvMetal
161163

162-
vec4 colorMix = mix(tex, tex2, vColor2.a);
164+
vec4 colorMix = mix(tex, tex2, 1.0 - vColor2.a);
163165

164166
matDiffuse = colorMix.rgb ;
165167
emissive = (colorMix.rgb * colorMix.a) * tex3.rgb * distFade;
@@ -243,22 +245,14 @@ void main() {
243245
finalOpacity = tex.a;
244246
} if (uPixelShader == 19) { //MapObjParallax
245247
vec4 tex_6 = texture(uTexture6, vTexCoord2).rgba;
246-
vec3 crossDy = cross(dFdy(vPosition.xyz), vNormal);
247-
vec3 crossDx = cross(vNormal, dFdx(vPosition.xyz));
248-
vec2 dTexCoord2Dx = dFdx(vTexCoord2);
249-
vec2 dTexCoord2Dy = dFdy(vTexCoord2);
250-
251-
vec3 sum1 = dTexCoord2Dy.x * crossDx + dTexCoord2Dx.x * crossDy;
252-
vec3 sum2 = dTexCoord2Dy.y * crossDx + dTexCoord2Dx.y * crossDy;
253248

254-
float maxInverseDot = inversesqrt(max(dot(sum1,sum1), dot(sum2, sum2)));
255-
float cosAlpha = dot(normalize(vPosition.xyz), vNormal);
249+
mat3 TBN = contangent_frame(vNormal.xyz, -vPosition.xyz, vTexCoord2);
256250

257-
float dot1 = dot(maxInverseDot * sum1, normalize(vPosition.xyz)) / cosAlpha;
258-
float dot2 = dot(maxInverseDot * sum2, normalize(vPosition.xyz)) / cosAlpha;
251+
float cosAlpha = dot(normalize(vPosition.xyz), vNormal.xyz);
252+
vec2 dotResult = (TBN * (normalize(-vPosition.xyz) / cosAlpha)).xy;
259253

260-
vec4 tex_4 = texture(uTexture4, vTexCoord2 - (vec2(dot1, dot2)* tex_6.r * 0.25)).rgba;
261-
vec4 tex_5 = texture(uTexture5, vTexCoord3 - (vec2(dot1, dot2)* tex_6.r * 0.25)).rgba;
254+
vec4 tex_4 = texture(uTexture4, vTexCoord2 - (dotResult * tex_6.r * 0.25)).rgba;
255+
vec4 tex_5 = texture(uTexture5, vTexCoord3 - (dotResult * tex_6.r * 0.25)).rgba;
262256
vec4 tex_3 = texture(uTexture3, vTexCoord2).rgba;
263257

264258
vec3 mix1 = tex_5.rgb + tex_4.rgb * tex_4.a;

wowViewerLib/src/engine/objects/ViewsObjects.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ void GeneralView::setM2Lights(std::shared_ptr<M2Object> &m2Object) {
7676
m2Object->setUseLocalLighting(false);
7777
}
7878

79-
static std::array<GBufferBinding, 3> DrawPortalBindings = {
79+
static std::array<GBufferBinding, 1> DrawPortalBindings = {
8080
{+drawPortalShader::Attribute::aPosition, 3, GBindingType::GFLOAT, false, 12, 0 }, // 0
8181
//24
8282
};

wowViewerLib/src/engine/shader/ShaderDefinitions.h

Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -625,36 +625,36 @@ const std::unordered_map<std::string, std::unordered_map<int, std::vector<field
625625
{"m2Shader", {
626626
{
627627
0, {
628-
{"_210_scene_uLookAtMat", true, 0, 4, 4, 0},
629-
{"_210_scene_uPMatrix", true, 64, 4, 4, 0},
630-
{"_210_scene_uViewUp", true, 128, 1, 4, 0},
631-
{"_210_scene_uInteriorSunDir", true, 144, 1, 4, 0},
632-
{"_210_scene_extLight_uExteriorAmbientColor", true, 160, 1, 4, 0},
633-
{"_210_scene_extLight_uExteriorHorizontAmbientColor", true, 176, 1, 4, 0},
634-
{"_210_scene_extLight_uExteriorGroundAmbientColor", true, 192, 1, 4, 0},
635-
{"_210_scene_extLight_uExteriorDirectColor", true, 208, 1, 4, 0},
636-
{"_210_scene_extLight_uExteriorDirectColorDir", true, 224, 1, 4, 0},
637-
{"_210_scene_extLight_adtSpecMult", true, 240, 1, 4, 0},
638-
{"_210_fogData_densityParams", true, 256, 1, 4, 0},
639-
{"_210_fogData_heightPlane", true, 272, 1, 4, 0},
640-
{"_210_fogData_color_and_heightRate", true, 288, 1, 4, 0},
641-
{"_210_fogData_heightDensity_and_endColor", true, 304, 1, 4, 0},
642-
{"_210_fogData_sunAngle_and_sunColor", true, 320, 1, 4, 0},
643-
{"_210_fogData_heightColor_and_endFogDistance", true, 336, 1, 4, 0},
644-
{"_210_fogData_sunPercentage", true, 352, 1, 4, 0},
628+
{"_203_scene_uLookAtMat", true, 0, 4, 4, 0},
629+
{"_203_scene_uPMatrix", true, 64, 4, 4, 0},
630+
{"_203_scene_uViewUp", true, 128, 1, 4, 0},
631+
{"_203_scene_uInteriorSunDir", true, 144, 1, 4, 0},
632+
{"_203_scene_extLight_uExteriorAmbientColor", true, 160, 1, 4, 0},
633+
{"_203_scene_extLight_uExteriorHorizontAmbientColor", true, 176, 1, 4, 0},
634+
{"_203_scene_extLight_uExteriorGroundAmbientColor", true, 192, 1, 4, 0},
635+
{"_203_scene_extLight_uExteriorDirectColor", true, 208, 1, 4, 0},
636+
{"_203_scene_extLight_uExteriorDirectColorDir", true, 224, 1, 4, 0},
637+
{"_203_scene_extLight_adtSpecMult", true, 240, 1, 4, 0},
638+
{"_203_fogData_densityParams", true, 256, 1, 4, 0},
639+
{"_203_fogData_heightPlane", true, 272, 1, 4, 0},
640+
{"_203_fogData_color_and_heightRate", true, 288, 1, 4, 0},
641+
{"_203_fogData_heightDensity_and_endColor", true, 304, 1, 4, 0},
642+
{"_203_fogData_sunAngle_and_sunColor", true, 320, 1, 4, 0},
643+
{"_203_fogData_heightColor_and_endFogDistance", true, 336, 1, 4, 0},
644+
{"_203_fogData_sunPercentage", true, 352, 1, 4, 0},
645645
}
646646
},
647647
{
648648
2, {
649-
{"_200_vertexShader_IsAffectedByLight", false, 0, 1, 4, 0},
650-
{"_200_color_Transparency", true, 16, 1, 4, 0},
651-
{"_200_uTextMat[0]", true, 32, 4, 4, 2},
649+
{"_193_vertexShader_IsAffectedByLight", false, 0, 1, 4, 0},
650+
{"_193_color_Transparency", true, 16, 1, 4, 0},
651+
{"_193_uTextMat[0]", true, 32, 4, 4, 2},
652652
}
653653
},
654654
{
655655
1, {
656-
{"_100_uPlacementMat", true, 0, 4, 4, 0},
657-
{"_100_uBoneMatrixes[0]", true, 64, 4, 4, 220},
656+
{"_93_uPlacementMat", true, 0, 4, 4, 0},
657+
{"_93_uBoneMatrixes[0]", true, 64, 4, 4, 220},
658658
}
659659
},
660660
}},
@@ -671,33 +671,33 @@ const std::unordered_map<std::string, std::unordered_map<int, std::vector<field
671671
{"wmoShader", {
672672
{
673673
2, {
674-
{"_146_VertexShader_UseLitColor", false, 0, 1, 4, 0},
674+
{"_139_VertexShader_UseLitColor", false, 0, 1, 4, 0},
675675
}
676676
},
677677
{
678678
0, {
679-
{"_78_scene_uLookAtMat", true, 0, 4, 4, 0},
680-
{"_78_scene_uPMatrix", true, 64, 4, 4, 0},
681-
{"_78_scene_uViewUp", true, 128, 1, 4, 0},
682-
{"_78_scene_uInteriorSunDir", true, 144, 1, 4, 0},
683-
{"_78_scene_extLight_uExteriorAmbientColor", true, 160, 1, 4, 0},
684-
{"_78_scene_extLight_uExteriorHorizontAmbientColor", true, 176, 1, 4, 0},
685-
{"_78_scene_extLight_uExteriorGroundAmbientColor", true, 192, 1, 4, 0},
686-
{"_78_scene_extLight_uExteriorDirectColor", true, 208, 1, 4, 0},
687-
{"_78_scene_extLight_uExteriorDirectColorDir", true, 224, 1, 4, 0},
688-
{"_78_scene_extLight_adtSpecMult", true, 240, 1, 4, 0},
689-
{"_78_fogData_densityParams", true, 256, 1, 4, 0},
690-
{"_78_fogData_heightPlane", true, 272, 1, 4, 0},
691-
{"_78_fogData_color_and_heightRate", true, 288, 1, 4, 0},
692-
{"_78_fogData_heightDensity_and_endColor", true, 304, 1, 4, 0},
693-
{"_78_fogData_sunAngle_and_sunColor", true, 320, 1, 4, 0},
694-
{"_78_fogData_heightColor_and_endFogDistance", true, 336, 1, 4, 0},
695-
{"_78_fogData_sunPercentage", true, 352, 1, 4, 0},
679+
{"_71_scene_uLookAtMat", true, 0, 4, 4, 0},
680+
{"_71_scene_uPMatrix", true, 64, 4, 4, 0},
681+
{"_71_scene_uViewUp", true, 128, 1, 4, 0},
682+
{"_71_scene_uInteriorSunDir", true, 144, 1, 4, 0},
683+
{"_71_scene_extLight_uExteriorAmbientColor", true, 160, 1, 4, 0},
684+
{"_71_scene_extLight_uExteriorHorizontAmbientColor", true, 176, 1, 4, 0},
685+
{"_71_scene_extLight_uExteriorGroundAmbientColor", true, 192, 1, 4, 0},
686+
{"_71_scene_extLight_uExteriorDirectColor", true, 208, 1, 4, 0},
687+
{"_71_scene_extLight_uExteriorDirectColorDir", true, 224, 1, 4, 0},
688+
{"_71_scene_extLight_adtSpecMult", true, 240, 1, 4, 0},
689+
{"_71_fogData_densityParams", true, 256, 1, 4, 0},
690+
{"_71_fogData_heightPlane", true, 272, 1, 4, 0},
691+
{"_71_fogData_color_and_heightRate", true, 288, 1, 4, 0},
692+
{"_71_fogData_heightDensity_and_endColor", true, 304, 1, 4, 0},
693+
{"_71_fogData_sunAngle_and_sunColor", true, 320, 1, 4, 0},
694+
{"_71_fogData_heightColor_and_endFogDistance", true, 336, 1, 4, 0},
695+
{"_71_fogData_sunPercentage", true, 352, 1, 4, 0},
696696
}
697697
},
698698
{
699699
1, {
700-
{"_58_uPlacementMat", true, 0, 4, 4, 0},
700+
{"_51_uPlacementMat", true, 0, 4, 4, 0},
701701
}
702702
},
703703
}},
@@ -1049,35 +1049,35 @@ const std::unordered_map<std::string, std::unordered_map<int, std::vector<field
10491049
{"wmoShader", {
10501050
{
10511051
4, {
1052-
{"_657_UseLitColor_EnableAlpha_PixelShader_BlendMode", false, 0, 1, 4, 0},
1053-
{"_657_FogColor_AlphaTest", true, 16, 1, 4, 0},
1052+
{"_729_UseLitColor_EnableAlpha_PixelShader_BlendMode", false, 0, 1, 4, 0},
1053+
{"_729_FogColor_AlphaTest", true, 16, 1, 4, 0},
10541054
}
10551055
},
10561056
{
10571057
0, {
1058-
{"_537_scene_uLookAtMat", true, 0, 4, 4, 0},
1059-
{"_537_scene_uPMatrix", true, 64, 4, 4, 0},
1060-
{"_537_scene_uViewUp", true, 128, 1, 4, 0},
1061-
{"_537_scene_uInteriorSunDir", true, 144, 1, 4, 0},
1062-
{"_537_scene_extLight_uExteriorAmbientColor", true, 160, 1, 4, 0},
1063-
{"_537_scene_extLight_uExteriorHorizontAmbientColor", true, 176, 1, 4, 0},
1064-
{"_537_scene_extLight_uExteriorGroundAmbientColor", true, 192, 1, 4, 0},
1065-
{"_537_scene_extLight_uExteriorDirectColor", true, 208, 1, 4, 0},
1066-
{"_537_scene_extLight_uExteriorDirectColorDir", true, 224, 1, 4, 0},
1067-
{"_537_scene_extLight_adtSpecMult", true, 240, 1, 4, 0},
1068-
{"_537_fogData_densityParams", true, 256, 1, 4, 0},
1069-
{"_537_fogData_heightPlane", true, 272, 1, 4, 0},
1070-
{"_537_fogData_color_and_heightRate", true, 288, 1, 4, 0},
1071-
{"_537_fogData_heightDensity_and_endColor", true, 304, 1, 4, 0},
1072-
{"_537_fogData_sunAngle_and_sunColor", true, 320, 1, 4, 0},
1073-
{"_537_fogData_heightColor_and_endFogDistance", true, 336, 1, 4, 0},
1074-
{"_537_fogData_sunPercentage", true, 352, 1, 4, 0},
1058+
{"_609_scene_uLookAtMat", true, 0, 4, 4, 0},
1059+
{"_609_scene_uPMatrix", true, 64, 4, 4, 0},
1060+
{"_609_scene_uViewUp", true, 128, 1, 4, 0},
1061+
{"_609_scene_uInteriorSunDir", true, 144, 1, 4, 0},
1062+
{"_609_scene_extLight_uExteriorAmbientColor", true, 160, 1, 4, 0},
1063+
{"_609_scene_extLight_uExteriorHorizontAmbientColor", true, 176, 1, 4, 0},
1064+
{"_609_scene_extLight_uExteriorGroundAmbientColor", true, 192, 1, 4, 0},
1065+
{"_609_scene_extLight_uExteriorDirectColor", true, 208, 1, 4, 0},
1066+
{"_609_scene_extLight_uExteriorDirectColorDir", true, 224, 1, 4, 0},
1067+
{"_609_scene_extLight_adtSpecMult", true, 240, 1, 4, 0},
1068+
{"_609_fogData_densityParams", true, 256, 1, 4, 0},
1069+
{"_609_fogData_heightPlane", true, 272, 1, 4, 0},
1070+
{"_609_fogData_color_and_heightRate", true, 288, 1, 4, 0},
1071+
{"_609_fogData_heightDensity_and_endColor", true, 304, 1, 4, 0},
1072+
{"_609_fogData_sunAngle_and_sunColor", true, 320, 1, 4, 0},
1073+
{"_609_fogData_heightColor_and_endFogDistance", true, 336, 1, 4, 0},
1074+
{"_609_fogData_sunPercentage", true, 352, 1, 4, 0},
10751075
}
10761076
},
10771077
{
10781078
3, {
1079-
{"_525_intLight_uInteriorAmbientColorAndApplyInteriorLight", true, 0, 1, 4, 0},
1080-
{"_525_intLight_uInteriorDirectColorAndApplyExteriorLight", true, 16, 1, 4, 0},
1079+
{"_597_intLight_uInteriorAmbientColorAndApplyInteriorLight", true, 0, 1, 4, 0},
1080+
{"_597_intLight_uInteriorDirectColorAndApplyExteriorLight", true, 16, 1, 4, 0},
10811081
}
10821082
},
10831083
}},

0 commit comments

Comments
 (0)