Reimplement swaying leaves & grass with version 3.30 shaders.

* Move SOL_ALL_SAFETIES_ON to CMake target_compile_definitions.
master
Nicole Collings 2019-09-08 12:33:33 -07:00
parent d174c24847
commit 6ee9a3cb3c
8 changed files with 17 additions and 12 deletions

View File

@ -33,6 +33,9 @@ target_link_libraries (${MAIN_EXEC_NAME} Zepha_Core)
# Load Libraries
include(${CMAKE_CURRENT_SOURCE_DIR}/LoadLibs.cmake)
# Enable Safeties
target_compile_definitions(${MAIN_EXEC_NAME} PUBLIC SOL_ALL_SAFETIES_ON)
# Test Build
#add_subdirectory(test)
#add_executable(${TEST_EXEC_NAME} test/Main.cpp)

View File

@ -12,10 +12,10 @@ uniform mat4 model;
uniform mat4 projection;
uniform mat4 view;
uniform float time;
uniform sampler2D swayTex;
uniform float time;
out vec2 texCoords;
out vec3 fragPos;
out vec3 normal;

View File

@ -10,7 +10,7 @@ LocalDefs::LocalDefs(const LocalDefs &copy) : LocalDefs(copy.tex_path) {}
LocalDefs::LocalDefs(const std::string& path) :
luaApi(),
tex_path(path),
textureAtlas(8192) {
textureAtlas(2048) {
textureAtlas.loadDirectory(tex_path);
}

View File

@ -42,6 +42,8 @@ void Renderer::createWorldShaders() {
wgu.model = worldGeometryShader.getUniform("model");
wgu.view = worldGeometryShader.getUniform("view");
wgu.swaySampler = worldGeometryShader.getUniform("swayTex");
wgu.time = worldGeometryShader.getUniform("time");
worldGeometryShader.use();
@ -213,13 +215,15 @@ void Renderer::beginChunkDeferredCalls() {
glBindFramebuffer(GL_FRAMEBUFFER, gBuffer);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
swayMap.use(1);
worldGeometryShader.use();
glUniformMatrix4fv(wgu.proj, 1, GL_FALSE, glm::value_ptr(wgu.matrix));
glUniformMatrix4fv(wgu.view, 1, GL_FALSE, glm::value_ptr(camera.getViewMatrix()));
glUniform1f(wgu.time, static_cast<float>(elapsedTime));
swayMap.use(1);
glUniform1i(wgu.swaySampler, 1);
}
void Renderer::beginEntityDeferredCalls() {

View File

@ -15,7 +15,7 @@ struct WorldGeometryUniforms {
GLint model;
GLint view;
GLint swaySampler;
GLint time;
};

View File

@ -7,8 +7,6 @@
#include "../../../def/LocalDefs.h"
#include "../../../game/scene/world/LocalWorld.h"
#include "../customization/pVec3.h"
#define SOL_ALL_SAFETIES_ON = 1
#include <sol2/sol.hpp>
namespace ClientApi {

View File

@ -88,9 +88,9 @@ sol::protected_function_result LocalLuaParser::DoFileSandboxed(std::string file)
if (strncmp(mod.config.name.c_str(), modname.c_str(), modname_length) == 0) {
for (LuaModFile& f : mod.files) {
if (f.path == file) {
auto pfr = lua.safe_script(f.file, [](lua_State*, sol::protected_function_result errPfr) {
auto pfr = lua.safe_script(f.file, [&](lua_State*, sol::protected_function_result errPfr) {
sol::error err = errPfr;
std::cout << Log::err << "DoFileSandboxed returned an error: " << err.what() << Log::endl;
std::cout << Log::err << file << " returned an error: " << err.what() << Log::endl;
return errPfr;
});
return pfr;

View File

@ -314,9 +314,9 @@ sol::protected_function_result ServerLuaParser::DoFileSandboxed(std::string file
if (strncmp(mod.config.name.c_str(), modname.c_str(), modname_length) == 0) {
for (LuaModFile& f : mod.files) {
if (f.path == file) {
auto pfr = lua.safe_script(f.file, [](lua_State*, sol::protected_function_result errPfr) {
auto pfr = lua.safe_script(f.file, [&](lua_State*, sol::protected_function_result errPfr) {
sol::error err = errPfr;
std::cout << Log::err << "DoFileSandboxed returned an error: " << err.what() << Log::endl;
std::cout << Log::err << file << " returned an error: " << err.what() << Log::endl;
return errPfr;
});
return pfr;