Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #126

Merged
merged 10 commits into from
Oct 24, 2024
24 changes: 13 additions & 11 deletions assets/addons/toon_shader/shaders/programs/scene/toon.frag
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,16 @@ void main()
rimInfo.threshold = 0.1;
rimInfo.color = get_mat_rim_color();

vec2 texCoords = fs_in.vert_uv;
vec2 texCoords = get_vertex_uv();
vec4 baseColor = fetch_albedo_map(texCoords, get_instance_color());
vec4 color = baseColor;

mat3 normalMatrix = transpose(inverse(mat3(fs_in.M)));
mat3 normalMatrix = transpose(inverse(mat3(get_model_matrix())));
vec3 normal = get_normal_from_map(texCoords, get_mat_flags());
normal = normalize(normalMatrix * normal);

vec3 viewDir = normalize(u_renderSettings.posCam.xyz - fs_in.vert_pos_ws.xyz);
vec3 vertPos = get_vertex_position_ws();
vec3 viewDir = normalize(u_renderSettings.posCam.xyz - vertPos);
ShadingInfo shadingInfo;
shadingInfo.surfaceNormal = normal;
shadingInfo.viewDirection = viewDir;
Expand All @@ -160,8 +161,8 @@ void main()
for(uint i = SCENE_SPOT_LIGHT_BUFFER_START; i < SCENE_SPOT_LIGHT_BUFFER_END && visibleLightTileIndicesBuffer.data[tileStartOffset + i].index != -1; i++) {
uint lightIndex = visibleLightTileIndicesBuffer.data[tileStartOffset + i].index;
LightSourceData light = get_light_source(lightIndex);
float attenuation = calc_spot_light_attenuation(light, fs_in.vert_pos_ws.xyz);
vec3 lightDir = normalize(light.position.xyz - fs_in.vert_pos_ws.xyz);
float attenuation = calc_spot_light_attenuation(light, vertPos);
vec3 lightDir = normalize(light.position.xyz - vertPos);
float shadowFactor = 1.0;
if(CSPEC_ENABLE_DYNAMIC_SHADOWS == 1)
shadowFactor = enableShadows ? get_spot_light_shadow_factor(lightIndex, true) : 1.0;
Expand All @@ -172,11 +173,11 @@ void main()
for(uint i = SCENE_POINT_LIGHT_BUFFER_START; i < SCENE_POINT_LIGHT_BUFFER_END && visibleLightTileIndicesBuffer.data[tileStartOffset + i].index != -1; i++) {
uint lightIndex = visibleLightTileIndicesBuffer.data[tileStartOffset + i].index;
LightSourceData light = get_light_source(lightIndex);
float attenuation = calc_point_light_attenuation(light, fs_in.vert_pos_ws.xyz);
vec3 lightDir = normalize(light.position.xyz - fs_in.vert_pos_ws.xyz);
float attenuation = calc_point_light_attenuation(light, vertPos);
vec3 lightDir = normalize(light.position.xyz - vertPos);
float shadowFactor = 1.0;
if(CSPEC_ENABLE_DYNAMIC_SHADOWS == 1)
shadowFactor = enableShadows ? get_point_light_shadow_factor(lightIndex, true, fs_in.vert_pos_ws.xyz) : 1.0;
shadowFactor = enableShadows ? get_point_light_shadow_factor(lightIndex, true, vertPos) : 1.0;
calc_toon_blinn_phong_lighting(shadingInfo, specInfo, rimInfo, light, lightDir, attenuation, shadowFactor, normal, totalLightColor, totalSpecularColor, totalRimColor, lightIndex, enableShadows);
}
}
Expand Down Expand Up @@ -214,12 +215,13 @@ void main()
if(CSPEC_ENABLE_LIGHT_MAPS == 1) {
// TODO: Lightmap mode should be determined by specialization constant to avoid if-condition overhead
if(useLightmaps) {
vec4 colDirect = texture(u_lightMap, fs_in.vert_uv_lightmap.xy);
vec2 uv = get_vertex_uv_lightmap();
vec4 colDirect = texture(u_lightMap, uv);
float exposure = get_lightmap_exposure_pow();
if(is_indirect_light_map_enabled()) {
vec3 colIndirect = texture(u_lightMapIndirect, fs_in.vert_uv_lightmap.xy).rgb;
vec3 colIndirect = texture(u_lightMapIndirect, uv).rgb;
if(is_directional_light_map_enabled()) {
vec3 dominantDir = texture(u_lightMapDominant, fs_in.vert_uv_lightmap.xy).rgb;
vec3 dominantDir = texture(u_lightMapDominant, uv).rgb;
dominantDir = dominantDir * 2.0 - 1.0;
dominantDir = normalize(dominantDir);

Expand Down
14 changes: 14 additions & 0 deletions assets/scripts/localization/de/texts/prompts.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
prompt_button_abort = "Abbrechen"
prompt_button_cancel = "Abbrechen"
prompt_button_continue = "Fortfahren"
prompt_button_ignore = "Ignorieren"
prompt_button_no = "Nein"
prompt_button_ok = "OK"
prompt_button_retry = "Wiederholen"
prompt_button_try_again = "Erneut versuchen"
prompt_button_yes = "Ja"
prompt_crash = "Es ist ein schwerwiegender Fehler im Programm aufgetreten. Möchten Sie eine Diagnose-Datei speichern? Diese Datei enthält Informationen über Ihr System und den Zustand des Spiels zum Zeitpunkt des Absturzes und kann von einem Entwickler verwendet werden, um das zugrunde liegende Problem zu beheben."
prompt_crash_dump_archive_failed = "Fehler beim Speichern der Dump-Datei: {}"
prompt_crash_dump_generation_failed = "Fehler beim Speichern der Dump-Datei in '{}': Fehlercode {}"
prompt_crash_dump_saved = "Dump-Datei in '{}' gespeichert. Bitte senden Sie diese an einen Entwickler, zusammen mit einer Beschreibung dessen, was Sie getan haben, um den Fehler auszulösen."
prompt_fallback_to_opengl = "Wenn dieser Absturz weiterhin besteht, kann das Wechseln zur OpenGL-Rendering die Lösung sein. Möchten Sie das jetzt versuchen?"
14 changes: 14 additions & 0 deletions assets/scripts/localization/en/texts/prompts.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
prompt_button_abort = "Abort"
prompt_button_cancel = "Cancel"
prompt_button_continue = "Continue"
prompt_button_ignore = "Ignore"
prompt_button_no = "No"
prompt_button_ok = "Ok"
prompt_button_retry = "Retry"
prompt_button_try_again = "Try Again"
prompt_button_yes = "Yes"
prompt_crash = "A terminal error has occurred in the program. Would you like to save a diagnostic file? This file contains information about your system and the state of the game at the time of the crash and can be utilized by a developer to fix the underlying problem."
prompt_crash_dump_archive_failed = "Failed to save dump file: {}"
prompt_crash_dump_generation_failed = "Failed to save dump file to '{}': Error code {}"
prompt_crash_dump_saved = "Saved dump file to '{}'. Please send it to a developer, along with a description of what you did to trigger the error."
prompt_fallback_to_opengl = "If this crash persists, switching to OpenGL rendering may help resolve it. Would you like to try that now?"
14 changes: 14 additions & 0 deletions assets/scripts/localization/es/texts/prompts.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
prompt_button_abort = "Abortar"
prompt_button_cancel = "Cancelar"
prompt_button_continue = "Continuar"
prompt_button_ignore = "Ignorar"
prompt_button_no = "No"
prompt_button_ok = "OK"
prompt_button_retry = "Reintentar"
prompt_button_try_again = "Intentar de nuevo"
prompt_button_yes = "Sí"
prompt_crash = "Se ha producido un error terminal en el programa. ¿Le gustaría guardar un archivo de diagnóstico? Este archivo contiene información sobre su sistema y el estado del juego en el momento del fallo, y puede ser utilizado por un desarrollador para solucionar el problema subyacente."
prompt_crash_dump_archive_failed = "No se pudo guardar el archivo de volcado: {}"
prompt_crash_dump_generation_failed = "No se pudo guardar el archivo de volcado en '{}': Código de error {}"
prompt_crash_dump_saved = "Archivo de volcado guardado en '{}'. Por favor, envíelo a un desarrollador junto con una descripción de lo que hizo para provocar el error."
prompt_fallback_to_opengl = "Si este error persiste, cambiar a renderizado con OpenGL podría ayudar a resolverlo. ¿Le gustaría intentarlo ahora?"
14 changes: 14 additions & 0 deletions assets/scripts/localization/fr/texts/prompts.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
prompt_button_abort = "Abandonner"
prompt_button_cancel = "Annuler"
prompt_button_continue = "Continuer"
prompt_button_ignore = "Ignorer"
prompt_button_no = "Non"
prompt_button_ok = "OK"
prompt_button_retry = "Réessayer"
prompt_button_try_again = "Réessayer"
prompt_button_yes = "Oui"
prompt_crash = "Une erreur fatale est survenue dans le programme. Souhaitez-vous enregistrer un fichier de diagnostic ? Ce fichier contient des informations sur votre système et l'état du jeu au moment du crash et peut être utilisé par un développeur pour résoudre le problème sous-jacent."
prompt_crash_dump_archive_failed = "Échec de l'enregistrement du fichier de vidage : {}"
prompt_crash_dump_generation_failed = "Échec de l'enregistrement du fichier de vidage dans '{}': Code d'erreur {}"
prompt_crash_dump_saved = "Fichier de vidage enregistré dans '{}'. Veuillez l'envoyer à un développeur, accompagné d'une description de ce que vous faisiez pour provoquer l'erreur."
prompt_fallback_to_opengl = "Si ce crash persiste, passer au rendu OpenGL pourrait aider à le résoudre. Voulez-vous essayer maintenant ?"
14 changes: 14 additions & 0 deletions assets/scripts/localization/it/texts/prompts.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
prompt_button_abort = "Interrompi"
prompt_button_cancel = "Annulla"
prompt_button_continue = "Continua"
prompt_button_ignore = "Ignora"
prompt_button_no = "No"
prompt_button_ok = "OK"
prompt_button_retry = "Riprova"
prompt_button_try_again = "Prova di nuovo"
prompt_button_yes = "Sì"
prompt_crash = "Si è verificato un errore fatale nel programma. Vuoi salvare un file diagnostico? Questo file contiene informazioni sul tuo sistema e lo stato del gioco al momento del crash e può essere utilizzato da uno sviluppatore per risolvere il problema sottostante."
prompt_crash_dump_archive_failed = "Impossibile salvare il file di dump: {}"
prompt_crash_dump_generation_failed = "Impossibile salvare il file di dump in '{}': Codice errore {}"
prompt_crash_dump_saved = "File di dump salvato in '{}'. Inviarlo a uno sviluppatore, insieme a una descrizione di ciò che hai fatto per provocare l'errore."
prompt_fallback_to_opengl = "Se questo crash persiste, il passaggio al rendering OpenGL potrebbe aiutare a risolverlo. Vuoi provare ora?"
14 changes: 14 additions & 0 deletions assets/scripts/localization/jp/texts/prompts.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
prompt_button_abort = "中止"
prompt_button_cancel = "キャンセル"
prompt_button_continue = "続行"
prompt_button_ignore = "無視"
prompt_button_no = "いいえ"
prompt_button_ok = "OK"
prompt_button_retry = "再試行"
prompt_button_try_again = "もう一度試す"
prompt_button_yes = "はい"
prompt_crash = "プログラムに致命的なエラーが発生しました。診断ファイルを保存しますか?このファイルには、クラッシュ時のシステム情報やゲームの状態が含まれており、開発者が問題を解決するのに役立てることができます。"
prompt_crash_dump_archive_failed = "ダンプファイルの保存に失敗しました: {}"
prompt_crash_dump_generation_failed = "'{}' にダンプファイルを保存できませんでした: エラーコード {}"
prompt_crash_dump_saved = "'{}' にダンプファイルを保存しました。このファイルと、エラーが発生するまでに行った操作の説明を開発者に送ってください。"
prompt_fallback_to_opengl = "このクラッシュが続く場合、OpenGL レンダリングに切り替えることで解決する可能性があります。今すぐ試してみますか?"
14 changes: 14 additions & 0 deletions assets/scripts/localization/pl/texts/prompts.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
prompt_button_abort = "Przerwij"
prompt_button_cancel = "Anuluj"
prompt_button_continue = "Kontynuuj"
prompt_button_ignore = "Ignoruj"
prompt_button_no = "Nie"
prompt_button_ok = "OK"
prompt_button_retry = "Ponów próbę"
prompt_button_try_again = "Spróbuj ponownie"
prompt_button_yes = "Tak"
prompt_crash = "W programie wystąpił krytyczny błąd. Czy chcesz zapisać plik diagnostyczny? Plik ten zawiera informacje o twoim systemie i stanie gry w momencie awarii i może zostać wykorzystany przez programistę do rozwiązania problemu."
prompt_crash_dump_archive_failed = "Nie udało się zapisać pliku zrzutu: {}"
prompt_crash_dump_generation_failed = "Nie udało się zapisać pliku zrzutu w '{}': Kod błędu {}"
prompt_crash_dump_saved = "Zapisano plik zrzutu w '{}'. Wyślij go do programisty wraz z opisem, co zrobiłeś, aby wywołać błąd."
prompt_fallback_to_opengl = "Jeśli ten błąd będzie się powtarzał, przełączenie na renderowanie OpenGL może pomóc go rozwiązać. Czy chcesz spróbować teraz?"
14 changes: 14 additions & 0 deletions assets/scripts/localization/zh-cn/texts/prompts.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
prompt_button_abort = "中止"
prompt_button_cancel = "取消"
prompt_button_continue = "继续"
prompt_button_ignore = "忽略"
prompt_button_no = "否"
prompt_button_ok = "确定"
prompt_button_retry = "重试"
prompt_button_try_again = "再试一次"
prompt_button_yes = "是"
prompt_crash = "程序发生了致命错误。是否要保存诊断文件?该文件包含您的系统信息以及游戏崩溃时的状态,可供开发人员用于修复潜在问题。"
prompt_crash_dump_archive_failed = "无法保存转储文件:{}"
prompt_crash_dump_generation_failed = "无法保存转储文件到'{}':错误代码 {}"
prompt_crash_dump_saved = "转储文件已保存到'{}'。请将其与您触发错误时的操作说明一并发送给开发人员。"
prompt_fallback_to_opengl = "如果此崩溃持续发生,切换到 OpenGL 渲染可能有助于解决问题。您想立即尝试吗?"
2 changes: 2 additions & 0 deletions core/client/include/pragma/c_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ class DLLCLIENT CEngine : public Engine, public pragma::RenderContext {
// If the input is an axis input, inOutState may change to represent actual button state
bool GetInputButtonState(float axisInput, GLFW::Modifier mods, GLFW::KeyState &inOutState) const;

virtual void HandleOpenGLFallback() override;

void SetRenderResolution(std::optional<Vector2i> resolution);
Vector2i GetRenderResolution() const;

Expand Down
18 changes: 18 additions & 0 deletions core/client/src/c_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ namespace pragma::string {
#include <pragma/engine_init.hpp>
#include <pragma/console/convars.h>
#include "pragma/console/engine_cvar.h"
#include "pragma/debug/debug_utils.hpp"
#include "pragma/model/c_modelmanager.h"
#include "pragma/networking/iclient.hpp"
#include "pragma/networking/local_client.hpp"
Expand Down Expand Up @@ -637,6 +638,23 @@ extern std::optional<Color> g_titleBarColor;
extern std::optional<Color> g_borderColor;
extern bool g_windowless;
void register_game_shaders();

void CEngine::HandleOpenGLFallback()
{
if(ustring::compare(GetRenderAPI(), std::string {"opengl"}, false))
return;
auto *cl = static_cast<ClientState *>(GetClientState());
if(!cl)
return;
auto msg = Locale::GetText("prompt_fallback_to_opengl");
if(pragma::debug::show_message_prompt(msg, pragma::debug::MessageBoxButtons::YesNo, util::get_program_name()) != pragma::debug::MessageBoxButton::Yes)
return;
cl->SetConVar("render_api", "opengl");
SaveClientConfig();
ShutDown();
util::start_process(util::get_program_name().c_str());
}

bool CEngine::Initialize(int argc, char *argv[])
{
Engine::Initialize(argc, argv);
Expand Down
18 changes: 0 additions & 18 deletions core/shared/include/pragma/debug/debug_lua_zerobrane.hpp

This file was deleted.

43 changes: 43 additions & 0 deletions core/shared/include/pragma/debug/debug_utils.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Copyright (c) 2021 Silverlan */

#ifndef __DEBUG_UTILS_HPP__
#define __DEBUG_UTILS_HPP__

#include "pragma/networkdefinitions.h"
#include <string>
#include <optional>
#include <cinttypes>

namespace pragma::debug {
enum class MessageBoxButton : uint32_t {
Ok = 0,
Cancel,
Abort,
Retry,
Ignore,
Yes,
No,
TryAgain,
Continue,
};
enum class MessageBoxButtons : uint8_t {
Ok = 0,
OkCancel,
AbortRetryIgnore,
YesNoCancel,
YesNo,
RetryCancel,
CancelTryAgainContinue,
};
DLLNETWORK void open_file_in_zerobrane(const std::string &fileName, uint32_t lineIdx);
DLLNETWORK std::optional<MessageBoxButton> show_message_prompt(const std::string &msg, MessageBoxButtons bts, std::optional<std::string> title = {});
#ifdef _WIN32
DLLNETWORK bool is_module_in_callstack(struct _EXCEPTION_POINTERS *exp, const std::string &moduleName);
#endif
};

#endif
29 changes: 19 additions & 10 deletions core/shared/include/pragma/debug/mdump.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
#ifndef __MDUMP_H__
#define __MDUMP_H__

#ifdef _WIN32
#include "pragma/definitions.h"

#ifdef _WIN32
#if _MSC_VER < 1300
#define DECLSPEC_DEPRECATED
// VC6: change this path to your Platform SDK headers
Expand All @@ -21,15 +22,23 @@

// based on dbghelp.h
typedef BOOL(WINAPI *MINIDUMPWRITEDUMP)(HANDLE hProcess, DWORD dwPid, HANDLE hFile, MINIDUMP_TYPE DumpType, CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam, CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam);

class DLLNETWORK MiniDumper {
private:
static LPCSTR m_szAppName;

static LONG WINAPI TopLevelFilter(struct _EXCEPTION_POINTERS *pExceptionInfo);
public:
MiniDumper(LPCSTR szAppName);
};
#endif

namespace pragma::debug {
class DLLNETWORK CrashHandler {
public:
CrashHandler(const std::string &appName);
~CrashHandler();
private:
bool GenerateCrashDump() const;
std::string m_appName;
#ifdef _WIN32
struct _EXCEPTION_POINTERS *m_pExceptionInfo = nullptr;
std::optional<std::string> GenerateMiniDump(std::string &outErr) const;
static LONG WINAPI TopLevelFilter(struct _EXCEPTION_POINTERS *pExceptionInfo);
#else
int m_sig = -1;
#endif
};
};
#endif
1 change: 1 addition & 0 deletions core/shared/include/pragma/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ class DLLNETWORK Engine : public CVarHandler, public CallbackHandler {
virtual void Close();
virtual void Release();
virtual void ClearConsole();
virtual void HandleOpenGLFallback() {};
void ClearCache();

void SetRunUpdaterOnClose(bool run);
Expand Down
8 changes: 2 additions & 6 deletions core/shared/include/pragma/engine_init.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
template<class T>
std::shared_ptr<T> InitializeEngine(int argc, char *argv[])
{
#ifdef _WIN32
auto exe = engine_info::get_executable_name();
MiniDumper dmp(exe.c_str());
#endif
pragma::debug::CrashHandler dmp(exe);
auto en = std::shared_ptr<T> {new T {argc, argv}, [](T *p) {
#ifdef _WIN32
if(std::uncaught_exceptions() > 0) {
Expand All @@ -41,10 +39,8 @@ std::shared_ptr<T> InitializeEngine(int argc, char *argv[])

inline DLLNETWORK std::shared_ptr<Engine> InitializeServer(int argc, char *argv[])
{
#ifdef _WIN32
auto exe = engine_info::get_executable_name();
MiniDumper dmp(exe.c_str());
#endif
pragma::debug::CrashHandler dmp(exe);
auto en = std::shared_ptr<Engine> {new Engine {argc, argv}, [](Engine *p) {
if(std::uncaught_exceptions() > 0) {
// If we're stack unwinding due to an uncaught exception,
Expand Down
Loading
Loading