Skip to content

Commit

Permalink
Merge pull request #27 from Deamon87/development
Browse files Browse the repository at this point in the history
Update for 10.1
  • Loading branch information
Deamon87 authored Mar 10, 2023
2 parents 882db52 + d8e8f81 commit d7b7cd5
Show file tree
Hide file tree
Showing 11 changed files with 129 additions and 94 deletions.
10 changes: 7 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ static LONG WINAPI windows_exception_handler(EXCEPTION_POINTERS * ExceptionInfo)
double currentFrame;
double lastFrame;

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

// std::string rendererName = "ogl2";
// std::string rendererName = "ogl3";
std::string rendererName = "vulkan";
std::string rendererName = "ogl3";
// std::string rendererName = "vulkan";

if (argc > 1 && std::string(argv[1]) == "-vulkan") {
rendererName = "vulkan";
}

//FOR OGL

Expand Down
4 changes: 2 additions & 2 deletions src/ui/FrontendUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -715,8 +715,8 @@ void FrontendUI::showQuickLinksDialog() {
std::vector<int> replacementTextureFDids = {};

ImGui::Begin("Quick Links", &showQuickLinks);
if (ImGui::Button("nightborne model", ImVec2(-1, 0))) {
openM2SceneByfdid(1810676, replacementTextureFDids);
if (ImGui::Button("Primal enchant", ImVec2(-1, 0))) {
openM2SceneByfdid(4636728, replacementTextureFDids);
}
if (ImGui::Button("Tomb of sargares hall", ImVec2(-1, 0))) {
openMapByIdAndWDTId(1676, 1532459, 6289, -801, 3028);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "../../../../3rdparty/DBImporter/fileReaders/DBD/DBDFileStorage.h"
#include "../../../../3rdparty/DBImporter/exporters/sqlite/CSQLLiteExporter.h"
#include "../../../../3rdparty/DBImporter/importers/WDC3/WDC3Importer.h"
#include "../../../../3rdparty/DBImporter/fileReaders/WDC4/DB2Ver4.h"

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

addTableLambda = [fileDBDStorage, csqlLiteExporter](std::string tableName, std::shared_ptr<Db2File> db2File) -> bool {
std::shared_ptr<WDC3::DB2Base> db2Base = std::make_shared<WDC3::DB2Base>();
std::shared_ptr<WDC3::DB2Ver3> db2Base = nullptr;
if (*(uint32_t *)db2File->getContent()->data() == '4CDW') {
db2Base = std::make_shared<WDC4::DB2Ver4>();
} else {
db2Base = std::make_shared<WDC3::DB2Ver3>();
}

db2Base->process(db2File->getContent(), "");

DBDFile::BuildConfig *buildConfig = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion wowViewerLib/3rdparty/oneTbb
42 changes: 33 additions & 9 deletions wowViewerLib/shaders/glsl/common/commonFunctions.glsl
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
vec2 posToTexCoord(vec3 cameraPoint, vec3 normal){
// vec3 normPos = -normalize(cameraPoint.xyz);
// vec3 normPos = cameraPoint.xyz;
// vec3 reflection = reflect(normPos, normal);
// return (normalize(vec3(reflection.r, reflection.g, reflection.b + 1.0)).rg * 0.5) + vec2(0.5);

vec3 normPos_495 = normalize(cameraPoint.xyz);
vec3 temp_500 = (normPos_495 - (normal * (2.0 * dot(normPos_495, normal))));
vec3 temp_657 = vec3(temp_500.x, temp_500.y, (temp_500.z + 1.0));
vec2 posToTexCoord(const vec3 vertexPosInView, const vec3 normal){
//Blizz seems to have vertex in view space as vector from "vertex to eye", while in this implementation, it's
//vector from "eye to vertex". So the minus here is not needed
//vec3 viewVecNormalized = -normalize(cameraPoint.xyz);
vec3 viewVecNormalized = normalize(vertexPosInView.xyz);
vec3 reflection = reflect(viewVecNormalized, normalize(normal));
vec3 temp_657 = vec3(reflection.x, reflection.y, (reflection.z + 1.0));

return ((normalize(temp_657).xy * 0.5) + vec2(0.5));
}
Expand All @@ -24,3 +22,29 @@ mat3 blizzTranspose(mat4 value) {
);
}


#ifdef FRAGMENT_SHADER
//From: https://pdfslide.tips/technology/shaderx5-26normalmappingwithoutprecomputedtangents-130318-1.html?page=14
mat3 contangent_frame(vec3 N, vec3 p, vec2 uv)
{
// Get edge vectors of the pixel triangle
vec3 dp1 = dFdx(p);
vec3 dp2 = dFdy(p);
vec2 duv1 = dFdx(uv);
vec2 duv2 = dFdy(uv);
// Solve the linear system
vec3 dp2perp = cross(dp2, N);
vec3 dp1perp = cross(N, dp1);
vec3 T = dp2perp * duv1.x + dp1perp * duv2.x;
vec3 B = dp2perp * duv1.y + dp1perp * duv2.y;
// Construct a scale-invariant frame
float invmax = inversesqrt(max(dot(T,T), dot(B,B)));
return mat3(T * invmax, B * invmax, N);
}
#else
//Temp implementation.
//TODO: add implementation for raytracing case
mat3 contangent_frame(vec3 N, vec3 p, vec2 uv) {
return mat3(1.0);
}
#endif
1 change: 1 addition & 0 deletions wowViewerLib/shaders/glsl/vulkan/m2ParticleShader.frag
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ layout(std140, binding=4) uniform meshWideBlockPS {
};

layout(set=1,binding=5) uniform sampler2D uTexture;

layout(set=1,binding=6) uniform sampler2D uTexture2;
layout(set=1,binding=7) uniform sampler2D uTexture3;

Expand Down
22 changes: 8 additions & 14 deletions wowViewerLib/shaders/glsl/vulkan/wmoShader.frag
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
precision highp float;
precision highp int;

#define FRAGMENT_SHADER

#include "../common/commonLightFunctions.glsl"
#include "../common/commonFogFunctions.glsl"
#include "../common/commonFunctions.glsl"
Expand Down Expand Up @@ -159,7 +161,7 @@ void main() {
finalOpacity = tex.a;
} else if (uPixelShader == 7) { //MapObjTwoLayerEnvMetal

vec4 colorMix = mix(tex, tex2, vColor2.a);
vec4 colorMix = mix(tex, tex2, 1.0 - vColor2.a);

matDiffuse = colorMix.rgb ;
emissive = (colorMix.rgb * colorMix.a) * tex3.rgb * distFade;
Expand Down Expand Up @@ -243,22 +245,14 @@ void main() {
finalOpacity = tex.a;
} if (uPixelShader == 19) { //MapObjParallax
vec4 tex_6 = texture(uTexture6, vTexCoord2).rgba;
vec3 crossDy = cross(dFdy(vPosition.xyz), vNormal);
vec3 crossDx = cross(vNormal, dFdx(vPosition.xyz));
vec2 dTexCoord2Dx = dFdx(vTexCoord2);
vec2 dTexCoord2Dy = dFdy(vTexCoord2);

vec3 sum1 = dTexCoord2Dy.x * crossDx + dTexCoord2Dx.x * crossDy;
vec3 sum2 = dTexCoord2Dy.y * crossDx + dTexCoord2Dx.y * crossDy;

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

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

vec4 tex_4 = texture(uTexture4, vTexCoord2 - (vec2(dot1, dot2)* tex_6.r * 0.25)).rgba;
vec4 tex_5 = texture(uTexture5, vTexCoord3 - (vec2(dot1, dot2)* tex_6.r * 0.25)).rgba;
vec4 tex_4 = texture(uTexture4, vTexCoord2 - (dotResult * tex_6.r * 0.25)).rgba;
vec4 tex_5 = texture(uTexture5, vTexCoord3 - (dotResult * tex_6.r * 0.25)).rgba;
vec4 tex_3 = texture(uTexture3, vTexCoord2).rgba;

vec3 mix1 = tex_5.rgb + tex_4.rgb * tex_4.a;
Expand Down
2 changes: 1 addition & 1 deletion wowViewerLib/src/engine/objects/ViewsObjects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void GeneralView::setM2Lights(std::shared_ptr<M2Object> &m2Object) {
m2Object->setUseLocalLighting(false);
}

static std::array<GBufferBinding, 3> DrawPortalBindings = {
static std::array<GBufferBinding, 1> DrawPortalBindings = {
{+drawPortalShader::Attribute::aPosition, 3, GBindingType::GFLOAT, false, 12, 0 }, // 0
//24
};
Expand Down
124 changes: 62 additions & 62 deletions wowViewerLib/src/engine/shader/ShaderDefinitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -625,36 +625,36 @@ const std::unordered_map<std::string, std::unordered_map<int, std::vector<field
{"m2Shader", {
{
0, {
{"_210_scene_uLookAtMat", true, 0, 4, 4, 0},
{"_210_scene_uPMatrix", true, 64, 4, 4, 0},
{"_210_scene_uViewUp", true, 128, 1, 4, 0},
{"_210_scene_uInteriorSunDir", true, 144, 1, 4, 0},
{"_210_scene_extLight_uExteriorAmbientColor", true, 160, 1, 4, 0},
{"_210_scene_extLight_uExteriorHorizontAmbientColor", true, 176, 1, 4, 0},
{"_210_scene_extLight_uExteriorGroundAmbientColor", true, 192, 1, 4, 0},
{"_210_scene_extLight_uExteriorDirectColor", true, 208, 1, 4, 0},
{"_210_scene_extLight_uExteriorDirectColorDir", true, 224, 1, 4, 0},
{"_210_scene_extLight_adtSpecMult", true, 240, 1, 4, 0},
{"_210_fogData_densityParams", true, 256, 1, 4, 0},
{"_210_fogData_heightPlane", true, 272, 1, 4, 0},
{"_210_fogData_color_and_heightRate", true, 288, 1, 4, 0},
{"_210_fogData_heightDensity_and_endColor", true, 304, 1, 4, 0},
{"_210_fogData_sunAngle_and_sunColor", true, 320, 1, 4, 0},
{"_210_fogData_heightColor_and_endFogDistance", true, 336, 1, 4, 0},
{"_210_fogData_sunPercentage", true, 352, 1, 4, 0},
{"_203_scene_uLookAtMat", true, 0, 4, 4, 0},
{"_203_scene_uPMatrix", true, 64, 4, 4, 0},
{"_203_scene_uViewUp", true, 128, 1, 4, 0},
{"_203_scene_uInteriorSunDir", true, 144, 1, 4, 0},
{"_203_scene_extLight_uExteriorAmbientColor", true, 160, 1, 4, 0},
{"_203_scene_extLight_uExteriorHorizontAmbientColor", true, 176, 1, 4, 0},
{"_203_scene_extLight_uExteriorGroundAmbientColor", true, 192, 1, 4, 0},
{"_203_scene_extLight_uExteriorDirectColor", true, 208, 1, 4, 0},
{"_203_scene_extLight_uExteriorDirectColorDir", true, 224, 1, 4, 0},
{"_203_scene_extLight_adtSpecMult", true, 240, 1, 4, 0},
{"_203_fogData_densityParams", true, 256, 1, 4, 0},
{"_203_fogData_heightPlane", true, 272, 1, 4, 0},
{"_203_fogData_color_and_heightRate", true, 288, 1, 4, 0},
{"_203_fogData_heightDensity_and_endColor", true, 304, 1, 4, 0},
{"_203_fogData_sunAngle_and_sunColor", true, 320, 1, 4, 0},
{"_203_fogData_heightColor_and_endFogDistance", true, 336, 1, 4, 0},
{"_203_fogData_sunPercentage", true, 352, 1, 4, 0},
}
},
{
2, {
{"_200_vertexShader_IsAffectedByLight", false, 0, 1, 4, 0},
{"_200_color_Transparency", true, 16, 1, 4, 0},
{"_200_uTextMat[0]", true, 32, 4, 4, 2},
{"_193_vertexShader_IsAffectedByLight", false, 0, 1, 4, 0},
{"_193_color_Transparency", true, 16, 1, 4, 0},
{"_193_uTextMat[0]", true, 32, 4, 4, 2},
}
},
{
1, {
{"_100_uPlacementMat", true, 0, 4, 4, 0},
{"_100_uBoneMatrixes[0]", true, 64, 4, 4, 220},
{"_93_uPlacementMat", true, 0, 4, 4, 0},
{"_93_uBoneMatrixes[0]", true, 64, 4, 4, 220},
}
},
}},
Expand All @@ -671,33 +671,33 @@ const std::unordered_map<std::string, std::unordered_map<int, std::vector<field
{"wmoShader", {
{
2, {
{"_146_VertexShader_UseLitColor", false, 0, 1, 4, 0},
{"_139_VertexShader_UseLitColor", false, 0, 1, 4, 0},
}
},
{
0, {
{"_78_scene_uLookAtMat", true, 0, 4, 4, 0},
{"_78_scene_uPMatrix", true, 64, 4, 4, 0},
{"_78_scene_uViewUp", true, 128, 1, 4, 0},
{"_78_scene_uInteriorSunDir", true, 144, 1, 4, 0},
{"_78_scene_extLight_uExteriorAmbientColor", true, 160, 1, 4, 0},
{"_78_scene_extLight_uExteriorHorizontAmbientColor", true, 176, 1, 4, 0},
{"_78_scene_extLight_uExteriorGroundAmbientColor", true, 192, 1, 4, 0},
{"_78_scene_extLight_uExteriorDirectColor", true, 208, 1, 4, 0},
{"_78_scene_extLight_uExteriorDirectColorDir", true, 224, 1, 4, 0},
{"_78_scene_extLight_adtSpecMult", true, 240, 1, 4, 0},
{"_78_fogData_densityParams", true, 256, 1, 4, 0},
{"_78_fogData_heightPlane", true, 272, 1, 4, 0},
{"_78_fogData_color_and_heightRate", true, 288, 1, 4, 0},
{"_78_fogData_heightDensity_and_endColor", true, 304, 1, 4, 0},
{"_78_fogData_sunAngle_and_sunColor", true, 320, 1, 4, 0},
{"_78_fogData_heightColor_and_endFogDistance", true, 336, 1, 4, 0},
{"_78_fogData_sunPercentage", true, 352, 1, 4, 0},
{"_71_scene_uLookAtMat", true, 0, 4, 4, 0},
{"_71_scene_uPMatrix", true, 64, 4, 4, 0},
{"_71_scene_uViewUp", true, 128, 1, 4, 0},
{"_71_scene_uInteriorSunDir", true, 144, 1, 4, 0},
{"_71_scene_extLight_uExteriorAmbientColor", true, 160, 1, 4, 0},
{"_71_scene_extLight_uExteriorHorizontAmbientColor", true, 176, 1, 4, 0},
{"_71_scene_extLight_uExteriorGroundAmbientColor", true, 192, 1, 4, 0},
{"_71_scene_extLight_uExteriorDirectColor", true, 208, 1, 4, 0},
{"_71_scene_extLight_uExteriorDirectColorDir", true, 224, 1, 4, 0},
{"_71_scene_extLight_adtSpecMult", true, 240, 1, 4, 0},
{"_71_fogData_densityParams", true, 256, 1, 4, 0},
{"_71_fogData_heightPlane", true, 272, 1, 4, 0},
{"_71_fogData_color_and_heightRate", true, 288, 1, 4, 0},
{"_71_fogData_heightDensity_and_endColor", true, 304, 1, 4, 0},
{"_71_fogData_sunAngle_and_sunColor", true, 320, 1, 4, 0},
{"_71_fogData_heightColor_and_endFogDistance", true, 336, 1, 4, 0},
{"_71_fogData_sunPercentage", true, 352, 1, 4, 0},
}
},
{
1, {
{"_58_uPlacementMat", true, 0, 4, 4, 0},
{"_51_uPlacementMat", true, 0, 4, 4, 0},
}
},
}},
Expand Down Expand Up @@ -1049,35 +1049,35 @@ const std::unordered_map<std::string, std::unordered_map<int, std::vector<field
{"wmoShader", {
{
4, {
{"_657_UseLitColor_EnableAlpha_PixelShader_BlendMode", false, 0, 1, 4, 0},
{"_657_FogColor_AlphaTest", true, 16, 1, 4, 0},
{"_729_UseLitColor_EnableAlpha_PixelShader_BlendMode", false, 0, 1, 4, 0},
{"_729_FogColor_AlphaTest", true, 16, 1, 4, 0},
}
},
{
0, {
{"_537_scene_uLookAtMat", true, 0, 4, 4, 0},
{"_537_scene_uPMatrix", true, 64, 4, 4, 0},
{"_537_scene_uViewUp", true, 128, 1, 4, 0},
{"_537_scene_uInteriorSunDir", true, 144, 1, 4, 0},
{"_537_scene_extLight_uExteriorAmbientColor", true, 160, 1, 4, 0},
{"_537_scene_extLight_uExteriorHorizontAmbientColor", true, 176, 1, 4, 0},
{"_537_scene_extLight_uExteriorGroundAmbientColor", true, 192, 1, 4, 0},
{"_537_scene_extLight_uExteriorDirectColor", true, 208, 1, 4, 0},
{"_537_scene_extLight_uExteriorDirectColorDir", true, 224, 1, 4, 0},
{"_537_scene_extLight_adtSpecMult", true, 240, 1, 4, 0},
{"_537_fogData_densityParams", true, 256, 1, 4, 0},
{"_537_fogData_heightPlane", true, 272, 1, 4, 0},
{"_537_fogData_color_and_heightRate", true, 288, 1, 4, 0},
{"_537_fogData_heightDensity_and_endColor", true, 304, 1, 4, 0},
{"_537_fogData_sunAngle_and_sunColor", true, 320, 1, 4, 0},
{"_537_fogData_heightColor_and_endFogDistance", true, 336, 1, 4, 0},
{"_537_fogData_sunPercentage", true, 352, 1, 4, 0},
{"_609_scene_uLookAtMat", true, 0, 4, 4, 0},
{"_609_scene_uPMatrix", true, 64, 4, 4, 0},
{"_609_scene_uViewUp", true, 128, 1, 4, 0},
{"_609_scene_uInteriorSunDir", true, 144, 1, 4, 0},
{"_609_scene_extLight_uExteriorAmbientColor", true, 160, 1, 4, 0},
{"_609_scene_extLight_uExteriorHorizontAmbientColor", true, 176, 1, 4, 0},
{"_609_scene_extLight_uExteriorGroundAmbientColor", true, 192, 1, 4, 0},
{"_609_scene_extLight_uExteriorDirectColor", true, 208, 1, 4, 0},
{"_609_scene_extLight_uExteriorDirectColorDir", true, 224, 1, 4, 0},
{"_609_scene_extLight_adtSpecMult", true, 240, 1, 4, 0},
{"_609_fogData_densityParams", true, 256, 1, 4, 0},
{"_609_fogData_heightPlane", true, 272, 1, 4, 0},
{"_609_fogData_color_and_heightRate", true, 288, 1, 4, 0},
{"_609_fogData_heightDensity_and_endColor", true, 304, 1, 4, 0},
{"_609_fogData_sunAngle_and_sunColor", true, 320, 1, 4, 0},
{"_609_fogData_heightColor_and_endFogDistance", true, 336, 1, 4, 0},
{"_609_fogData_sunPercentage", true, 352, 1, 4, 0},
}
},
{
3, {
{"_525_intLight_uInteriorAmbientColorAndApplyInteriorLight", true, 0, 1, 4, 0},
{"_525_intLight_uInteriorDirectColorAndApplyExteriorLight", true, 16, 1, 4, 0},
{"_597_intLight_uInteriorAmbientColorAndApplyInteriorLight", true, 0, 1, 4, 0},
{"_597_intLight_uInteriorDirectColorAndApplyExteriorLight", true, 16, 1, 4, 0},
}
},
}},
Expand Down
5 changes: 5 additions & 0 deletions wowViewerLib/src/gapi/vulkan/GDeviceVulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,11 @@ std::shared_ptr<IShaderPermutation> GDeviceVLK::getShader(std::string shaderName
sharedPtr.reset(iPremutation);
sharedPtr->compileShader("","");
m_shaderPermutCache[hash] = sharedPtr;
} else if (shaderName == "drawPortalShader") {
IShaderPermutation *iPremutation = new GDrawBoundingBoxVLK(shaderName, this);
sharedPtr.reset(iPremutation);
sharedPtr->compileShader("","");
m_shaderPermutCache[hash] = sharedPtr;
} else if (shaderName == "imguiShader") {
IShaderPermutation *iPremutation = new GImguiShaderPermutation(shaderName, this);
sharedPtr.reset(iPremutation);
Expand Down

0 comments on commit d7b7cd5

Please sign in to comment.