Fix code formatting issues and VS compilation
Also temporarily disable multicheck build so that we get a full build even when there are style issues on Vulkan. Fixes #33356.
This commit is contained in:
parent
b509c814fc
commit
fff4240bb4
|
@ -4,7 +4,6 @@ language: cpp
|
|||
dist: xenial
|
||||
|
||||
stages:
|
||||
- check
|
||||
- build
|
||||
|
||||
env:
|
||||
|
@ -21,7 +20,7 @@ cache:
|
|||
matrix:
|
||||
include:
|
||||
- name: Static checks (clang-format) + Documentation checks
|
||||
stage: check
|
||||
stage: build
|
||||
env: STATIC_CHECKS=yes
|
||||
os: linux
|
||||
compiler: gcc
|
||||
|
|
|
@ -1,3 +1,33 @@
|
|||
/*************************************************************************/
|
||||
/* vector3i.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "vector3i.h"
|
||||
|
||||
void Vector3i::set_axis(int p_axis, int32_t p_value) {
|
||||
|
|
|
@ -1,3 +1,33 @@
|
|||
/*************************************************************************/
|
||||
/* vector3i.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef VECTOR3I_H
|
||||
#define VECTOR3I_H
|
||||
|
||||
|
|
|
@ -1,3 +1,33 @@
|
|||
/*************************************************************************/
|
||||
/* rid_owner.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "rid_owner.h"
|
||||
|
||||
volatile uint64_t RID_AllocBase::base_id = 1;
|
||||
|
|
|
@ -1,3 +1,33 @@
|
|||
/*************************************************************************/
|
||||
/* rid_owner.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef RID_OWNER_H
|
||||
#define RID_OWNER_H
|
||||
|
||||
|
|
|
@ -1,3 +1,33 @@
|
|||
/*************************************************************************/
|
||||
/* spin_lock.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef SPIN_LOCK_H
|
||||
#define SPIN_LOCK_H
|
||||
|
||||
|
|
|
@ -1,3 +1,33 @@
|
|||
/*************************************************************************/
|
||||
/* thread_work_pool.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "thread_work_pool.h"
|
||||
#include "core/os/os.h"
|
||||
|
||||
|
|
|
@ -1,3 +1,33 @@
|
|||
/*************************************************************************/
|
||||
/* thread_work_pool.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef THREAD_WORK_POOL_H
|
||||
#define THREAD_WORK_POOL_H
|
||||
|
||||
|
|
|
@ -225,7 +225,7 @@ public:
|
|||
|
||||
uint64_t shadow_atlas_realloc_tolerance_msec;
|
||||
|
||||
struct ShadowAtlas {
|
||||
struct ShadowAtlas {
|
||||
enum {
|
||||
QUADRANT_SHIFT = 27,
|
||||
SHADOW_INDEX_MASK = (1 << QUADRANT_SHIFT) - 1,
|
||||
|
@ -304,7 +304,7 @@ public:
|
|||
|
||||
/* REFLECTION PROBE INSTANCE */
|
||||
|
||||
struct ReflectionProbeInstance {
|
||||
struct ReflectionProbeInstance {
|
||||
|
||||
RasterizerStorageGLES2::ReflectionProbe *probe_ptr;
|
||||
RID probe;
|
||||
|
@ -345,7 +345,7 @@ public:
|
|||
|
||||
/* ENVIRONMENT API */
|
||||
|
||||
struct Environment {
|
||||
struct Environment {
|
||||
VS::EnvironmentBG bg_mode;
|
||||
|
||||
RID sky;
|
||||
|
@ -496,7 +496,7 @@ public:
|
|||
|
||||
/* LIGHT INSTANCE */
|
||||
|
||||
struct LightInstance {
|
||||
struct LightInstance {
|
||||
|
||||
struct ShadowTransform {
|
||||
CameraMatrix camera;
|
||||
|
|
|
@ -1,3 +1,33 @@
|
|||
/*************************************************************************/
|
||||
/* editor_visual_profiler.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "editor_visual_profiler.h"
|
||||
|
||||
#include "core/os/os.h"
|
||||
|
|
|
@ -1,3 +1,33 @@
|
|||
/*************************************************************************/
|
||||
/* editor_visual_profiler.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef EDITOR_FRAME_PROFILER_H
|
||||
#define EDITOR_FRAME_PROFILER_H
|
||||
|
||||
|
|
|
@ -1,3 +1,33 @@
|
|||
/*************************************************************************/
|
||||
/* resource_importer_layered_texture.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#if 0
|
||||
/*************************************************************************/
|
||||
/* resource_importer_layered_texture.h */
|
||||
|
|
|
@ -35,11 +35,11 @@ void GIProbeEditorPlugin::_bake() {
|
|||
if (gi_probe) {
|
||||
if (gi_probe->get_probe_data().is_null()) {
|
||||
String path = get_tree()->get_edited_scene_root()->get_filename();
|
||||
if (path==String()) {
|
||||
path="res://"+gi_probe->get_name()+"_data.res";
|
||||
if (path == String()) {
|
||||
path = "res://" + gi_probe->get_name() + "_data.res";
|
||||
} else {
|
||||
String ext = path.get_extension();
|
||||
path = path.get_basename()+"."+gi_probe->get_name()+"_data.res";
|
||||
path = path.get_basename() + "." + gi_probe->get_name() + "_data.res";
|
||||
}
|
||||
probe_file->set_current_path(path);
|
||||
probe_file->popup_centered_ratio();
|
||||
|
@ -65,7 +65,7 @@ bool GIProbeEditorPlugin::handles(Object *p_object) const {
|
|||
|
||||
void GIProbeEditorPlugin::_notification(int p_what) {
|
||||
|
||||
if (p_what==NOTIFICATION_PROCESS) {
|
||||
if (p_what == NOTIFICATION_PROCESS) {
|
||||
if (!gi_probe) {
|
||||
return;
|
||||
}
|
||||
|
@ -73,14 +73,14 @@ void GIProbeEditorPlugin::_notification(int p_what) {
|
|||
String text;
|
||||
|
||||
Vector3i size = gi_probe->get_estimated_cell_size();
|
||||
text = itos(size.x)+", "+itos(size.y)+", "+itos(size.z);
|
||||
text = itos(size.x) + ", " + itos(size.y) + ", " + itos(size.z);
|
||||
int data_size = 4;
|
||||
if (GLOBAL_GET("rendering/quality/gi_probes/anisotropic")) {
|
||||
data_size+=4;
|
||||
data_size += 4;
|
||||
}
|
||||
text += " - VRAM Size: " + String::num(size.x*size.y*size.z*data_size/(1024.0*1024.0),2)+" Mb.";
|
||||
text += " - VRAM Size: " + String::num(size.x * size.y * size.z * data_size / (1024.0 * 1024.0), 2) + " Mb.";
|
||||
|
||||
if (bake_info->get_text()==text) {
|
||||
if (bake_info->get_text() == text) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -123,12 +123,12 @@ void GIProbeEditorPlugin::bake_func_end() {
|
|||
tmp_progress = NULL;
|
||||
}
|
||||
|
||||
void GIProbeEditorPlugin::_giprobe_save_path_and_bake(const String& p_path) {
|
||||
void GIProbeEditorPlugin::_giprobe_save_path_and_bake(const String &p_path) {
|
||||
probe_file->hide();
|
||||
if (gi_probe) {
|
||||
gi_probe->bake();
|
||||
ERR_FAIL_COND( gi_probe->get_probe_data().is_null() );
|
||||
ResourceSaver::save(p_path,gi_probe->get_probe_data(),ResourceSaver::FLAG_CHANGE_PATH);
|
||||
ERR_FAIL_COND(gi_probe->get_probe_data().is_null());
|
||||
ResourceSaver::save(p_path, gi_probe->get_probe_data(), ResourceSaver::FLAG_CHANGE_PATH);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -136,13 +136,12 @@ void GIProbeEditorPlugin::_bind_methods() {
|
|||
|
||||
ClassDB::bind_method("_bake", &GIProbeEditorPlugin::_bake);
|
||||
ClassDB::bind_method("_giprobe_save_path_and_bake", &GIProbeEditorPlugin::_giprobe_save_path_and_bake);
|
||||
|
||||
}
|
||||
|
||||
GIProbeEditorPlugin::GIProbeEditorPlugin(EditorNode *p_node) {
|
||||
|
||||
editor = p_node;
|
||||
bake_hb = memnew( HBoxContainer );
|
||||
bake_hb = memnew(HBoxContainer);
|
||||
bake_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
bake_hb->hide();
|
||||
bake = memnew(ToolButton);
|
||||
|
@ -150,17 +149,17 @@ GIProbeEditorPlugin::GIProbeEditorPlugin(EditorNode *p_node) {
|
|||
bake->set_text(TTR("Bake GI Probe"));
|
||||
bake->connect("pressed", this, "_bake");
|
||||
bake_hb->add_child(bake);
|
||||
bake_info = memnew( Label );
|
||||
bake_info = memnew(Label);
|
||||
bake_info->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
bake_info->set_clip_text(true);
|
||||
bake_hb->add_child(bake_info);
|
||||
|
||||
add_control_to_container(CONTAINER_SPATIAL_EDITOR_MENU, bake_hb);
|
||||
gi_probe = NULL;
|
||||
probe_file = memnew( EditorFileDialog );
|
||||
probe_file = memnew(EditorFileDialog);
|
||||
probe_file->set_mode(EditorFileDialog::MODE_SAVE_FILE);
|
||||
probe_file->add_filter("*.res");
|
||||
probe_file->connect("file_selected",this,"_giprobe_save_path_and_bake");
|
||||
probe_file->connect("file_selected", this, "_giprobe_save_path_and_bake");
|
||||
get_editor_interface()->get_base_control()->add_child(probe_file);
|
||||
probe_file->set_title(TTR("Select path for GIProbe Data File"));
|
||||
|
||||
|
|
|
@ -55,8 +55,7 @@ class GIProbeEditorPlugin : public EditorPlugin {
|
|||
static void bake_func_end();
|
||||
|
||||
void _bake();
|
||||
void _giprobe_save_path_and_bake(const String& p_path);
|
||||
|
||||
void _giprobe_save_path_and_bake(const String &p_path);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
|
|
@ -1,3 +1,33 @@
|
|||
/*************************************************************************/
|
||||
/* register_types.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "register_types.h"
|
||||
|
||||
#include "core/os/os.h"
|
||||
|
|
|
@ -1,3 +1,33 @@
|
|||
/*************************************************************************/
|
||||
/* texture_basisu.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "texture_basisu.h"
|
||||
#if 0
|
||||
#include "core/os/os.h"
|
||||
|
|
|
@ -1,3 +1,33 @@
|
|||
/*************************************************************************/
|
||||
/* texture_basisu.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "scene/resources/texture.h"
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
|
||||
class BulletPhysicsServer;
|
||||
|
||||
class RIDBullet {
|
||||
class RIDBullet {
|
||||
RID self;
|
||||
BulletPhysicsServer *physicsServer;
|
||||
|
||||
|
|
|
@ -367,7 +367,7 @@ static NSCursor *cursorFromSelector(SEL selector, SEL fallback = nil) {
|
|||
|
||||
#if defined(VULKAN_ENABLED)
|
||||
if (OS_OSX::singleton->video_driver_index == OS::VIDEO_DRIVER_VULKAN) {
|
||||
CALayer* layer = [OS_OSX::singleton->window_view layer];
|
||||
CALayer *layer = [OS_OSX::singleton->window_view layer];
|
||||
layer.contentsScale = OS_OSX::singleton->_display_scale();
|
||||
}
|
||||
#endif
|
||||
|
@ -395,7 +395,7 @@ static NSCursor *cursorFromSelector(SEL selector, SEL fallback = nil) {
|
|||
|
||||
#if defined(VULKAN_ENABLED)
|
||||
if (OS_OSX::singleton->video_driver_index == OS::VIDEO_DRIVER_VULKAN) {
|
||||
CALayer* layer = [OS_OSX::singleton->window_view layer];
|
||||
CALayer *layer = [OS_OSX::singleton->window_view layer];
|
||||
layer.contentsScale = OS_OSX::singleton->_display_scale();
|
||||
OS_OSX::singleton->context_vulkan->window_resize(0, OS_OSX::singleton->window_size.width, OS_OSX::singleton->window_size.height);
|
||||
}
|
||||
|
@ -462,7 +462,7 @@ static NSCursor *cursorFromSelector(SEL selector, SEL fallback = nil) {
|
|||
}
|
||||
- (void)cancelComposition;
|
||||
|
||||
- (CALayer*)makeBackingLayer;
|
||||
- (CALayer *)makeBackingLayer;
|
||||
|
||||
- (BOOL)wantsUpdateLayer;
|
||||
- (void)updateLayer;
|
||||
|
@ -477,10 +477,10 @@ static NSCursor *cursorFromSelector(SEL selector, SEL fallback = nil) {
|
|||
}
|
||||
}
|
||||
|
||||
- (CALayer*)makeBackingLayer {
|
||||
- (CALayer *)makeBackingLayer {
|
||||
#if defined(VULKAN_ENABLED)
|
||||
if (OS_OSX::singleton->video_driver_index == OS::VIDEO_DRIVER_VULKAN) {
|
||||
CALayer* layer = [[CAMetalLayer class] layer];
|
||||
CALayer *layer = [[CAMetalLayer class] layer];
|
||||
layer.contentsScale = OS_OSX::singleton->_display_scale();
|
||||
return layer;
|
||||
}
|
||||
|
@ -1949,7 +1949,6 @@ void OS_OSX::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, c
|
|||
|
||||
cursors_cache.erase(p_shape);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void OS_OSX::set_mouse_show(bool p_show) {
|
||||
|
|
|
@ -1457,7 +1457,6 @@ Error OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int
|
|||
context_gles2 = NULL;
|
||||
ERR_FAIL_V(ERR_UNAVAILABLE);
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
#if defined(VULKAN_ENABLED)
|
||||
|
@ -1659,7 +1658,6 @@ void OS_Windows::finalize() {
|
|||
|
||||
if (context_gles2)
|
||||
memdelete(context_gles2);
|
||||
|
||||
}
|
||||
#endif
|
||||
#if defined(VULKAN_ENABLED)
|
||||
|
|
|
@ -415,7 +415,6 @@ Vector3i GIProbe::get_estimated_cell_size() const {
|
|||
int longest_axis = bounds.get_longest_axis_index();
|
||||
axis_cell_size[longest_axis] = 1 << cell_subdiv;
|
||||
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
|
||||
if (i == longest_axis)
|
||||
|
@ -431,7 +430,7 @@ Vector3i GIProbe::get_estimated_cell_size() const {
|
|||
}
|
||||
}
|
||||
|
||||
return Vector3i(axis_cell_size[0],axis_cell_size[1],axis_cell_size[2]);
|
||||
return Vector3i(axis_cell_size[0], axis_cell_size[1], axis_cell_size[2]);
|
||||
}
|
||||
void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug) {
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ class FabrikInverseKinematic {
|
|||
};
|
||||
|
||||
public:
|
||||
struct Task {
|
||||
struct Task {
|
||||
RID self;
|
||||
Skeleton *skeleton;
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
#include "body_sw.h"
|
||||
|
||||
class ConstraintSW {
|
||||
class ConstraintSW {
|
||||
|
||||
BodySW **_body_ptr;
|
||||
int _body_count;
|
||||
|
|
|
@ -48,7 +48,7 @@ SHAPE_CUSTOM, ///< Server-Implementation based custom shape, calling shape_creat
|
|||
|
||||
class ShapeSW;
|
||||
|
||||
class ShapeOwnerSW {
|
||||
class ShapeOwnerSW {
|
||||
public:
|
||||
virtual void _shape_changed() = 0;
|
||||
virtual void remove_shape(ShapeSW *p_shape) = 0;
|
||||
|
@ -56,7 +56,7 @@ public:
|
|||
virtual ~ShapeOwnerSW() {}
|
||||
};
|
||||
|
||||
class ShapeSW {
|
||||
class ShapeSW {
|
||||
|
||||
RID self;
|
||||
AABB aabb;
|
||||
|
|
|
@ -59,7 +59,7 @@ public:
|
|||
PhysicsDirectSpaceStateSW();
|
||||
};
|
||||
|
||||
class SpaceSW {
|
||||
class SpaceSW {
|
||||
|
||||
public:
|
||||
enum ElapsedTime {
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
#include "body_2d_sw.h"
|
||||
|
||||
class Constraint2DSW {
|
||||
class Constraint2DSW {
|
||||
|
||||
Body2DSW **_body_ptr;
|
||||
int _body_count;
|
||||
|
|
|
@ -48,7 +48,7 @@ SHAPE_CUSTOM, ///< Server-Implementation based custom shape, calling shape_creat
|
|||
|
||||
class Shape2DSW;
|
||||
|
||||
class ShapeOwner2DSW {
|
||||
class ShapeOwner2DSW {
|
||||
public:
|
||||
virtual void _shape_changed() = 0;
|
||||
virtual void remove_shape(Shape2DSW *p_shape) = 0;
|
||||
|
@ -56,7 +56,7 @@ public:
|
|||
virtual ~ShapeOwner2DSW() {}
|
||||
};
|
||||
|
||||
class Shape2DSW {
|
||||
class Shape2DSW {
|
||||
|
||||
RID self;
|
||||
Rect2 aabb;
|
||||
|
|
|
@ -61,7 +61,7 @@ public:
|
|||
Physics2DDirectSpaceStateSW();
|
||||
};
|
||||
|
||||
class Space2DSW {
|
||||
class Space2DSW {
|
||||
|
||||
public:
|
||||
enum ElapsedTime {
|
||||
|
|
|
@ -1,3 +1,33 @@
|
|||
/*************************************************************************/
|
||||
/* rasterizer_effects_rd.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "rasterizer_effects_rd.h"
|
||||
|
||||
static _FORCE_INLINE_ void store_transform_3x3(const Basis &p_basis, float *p_array) {
|
||||
|
|
|
@ -1,3 +1,33 @@
|
|||
/*************************************************************************/
|
||||
/* rasterizer_effects_rd.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef RASTERIZER_EFFECTS_RD_H
|
||||
#define RASTERIZER_EFFECTS_RD_H
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*************************************************************************/
|
||||
/* rasterizer_rd.cpp */
|
||||
/* rasterizer_rd.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
|
|
|
@ -1556,7 +1556,7 @@ void RasterizerSceneForwardRD::_setup_gi_probes(RID *p_gi_probe_probe_cull_resul
|
|||
gi_probe_ubo.texture_slot = gi_probe_instance_get_slot(rpi);
|
||||
gi_probe_ubo.anisotropy_strength = storage->gi_probe_get_anisotropy_strength(base_probe);
|
||||
gi_probe_ubo.ao = storage->gi_probe_get_ao(base_probe);
|
||||
gi_probe_ubo.ao_size = Math::pow(storage->gi_probe_get_ao_size(base_probe),4.0);
|
||||
gi_probe_ubo.ao_size = Math::pow(storage->gi_probe_get_ao_size(base_probe), 4.0f);
|
||||
|
||||
if (gi_probe_is_anisotropic()) {
|
||||
gi_probe_ubo.texture_slot *= 3;
|
||||
|
|
|
@ -1,3 +1,33 @@
|
|||
/*************************************************************************/
|
||||
/* rasterizer_scene_rd.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "rasterizer_scene_rd.h"
|
||||
#include "core/os/os.h"
|
||||
#include "core/project_settings.h"
|
||||
|
@ -1680,7 +1710,7 @@ void RasterizerSceneRD::gi_probe_update(RID p_probe, bool p_update_light_instanc
|
|||
|
||||
// UDPDATE TIME
|
||||
|
||||
if (gi_probe->has_dynamic_object_data) {
|
||||
if (gi_probe->has_dynamic_object_data) {
|
||||
//if it has dynamic object data, it needs to be cleared
|
||||
RD::get_singleton()->texture_clear(gi_probe->texture, Color(0, 0, 0, 0), 0, gi_probe->mipmaps.size(), 0, 1, true);
|
||||
if (gi_probe_is_anisotropic()) {
|
||||
|
@ -1954,9 +1984,9 @@ void RasterizerSceneRD::gi_probe_update(RID p_probe, bool p_update_light_instanc
|
|||
push_constant.prev_rect_size[1] = 0;
|
||||
push_constant.on_mipmap = false;
|
||||
push_constant.propagation = storage->gi_probe_get_propagation(gi_probe->probe);
|
||||
push_constant.pad[0]=0;
|
||||
push_constant.pad[1]=0;
|
||||
push_constant.pad[2]=0;
|
||||
push_constant.pad[0] = 0;
|
||||
push_constant.pad[1] = 0;
|
||||
push_constant.pad[2] = 0;
|
||||
|
||||
//process lighting
|
||||
RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin();
|
||||
|
|
|
@ -1,3 +1,33 @@
|
|||
/*************************************************************************/
|
||||
/* rasterizer_scene_rd.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef RASTERIZER_SCENE_RD_H
|
||||
#define RASTERIZER_SCENE_RD_H
|
||||
|
||||
|
|
|
@ -1,3 +1,33 @@
|
|||
/*************************************************************************/
|
||||
/* shader_compiler_rd.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "shader_compiler_rd.h"
|
||||
|
||||
#include "core/os/os.h"
|
||||
|
|
|
@ -1,3 +1,33 @@
|
|||
/*************************************************************************/
|
||||
/* shader_compiler_rd.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef SHADER_COMPILER_RD_H
|
||||
#define SHADER_COMPILER_RD_H
|
||||
|
||||
|
|
|
@ -1,68 +1,62 @@
|
|||
/* clang-format off */
|
||||
[vertex]
|
||||
/* clang-format on */
|
||||
|
||||
#version 450
|
||||
|
||||
/* clang-format off */
|
||||
VERSION_DEFINES
|
||||
/* clang-format on */
|
||||
|
||||
#include "blur_inc.glsl"
|
||||
|
||||
layout(location =0) out vec2 uv_interp;
|
||||
layout(location = 0) out vec2 uv_interp;
|
||||
/* clang-format on */
|
||||
|
||||
void main() {
|
||||
|
||||
vec2 base_arr[4] = vec2[](vec2(0.0,0.0),vec2(0.0,1.0),vec2(1.0,1.0),vec2(1.0,0.0));
|
||||
vec2 base_arr[4] = vec2[](vec2(0.0, 0.0), vec2(0.0, 1.0), vec2(1.0, 1.0), vec2(1.0, 0.0));
|
||||
uv_interp = base_arr[gl_VertexIndex];
|
||||
|
||||
if (bool(blur.flags&FLAG_USE_BLUR_SECTION)) {
|
||||
if (bool(blur.flags & FLAG_USE_BLUR_SECTION)) {
|
||||
uv_interp = blur.section.xy + uv_interp * blur.section.zw;
|
||||
}
|
||||
|
||||
gl_Position = vec4( uv_interp *2.0 - 1.0, 0.0, 1.0);
|
||||
gl_Position = vec4(uv_interp * 2.0 - 1.0, 0.0, 1.0);
|
||||
|
||||
if (bool(blur.flags&FLAG_FLIP_Y)) {
|
||||
if (bool(blur.flags & FLAG_FLIP_Y)) {
|
||||
uv_interp.y = 1.0 - uv_interp.y;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* clang-format off */
|
||||
[fragment]
|
||||
/* clang-format on */
|
||||
|
||||
#version 450
|
||||
|
||||
/* clang-format off */
|
||||
VERSION_DEFINES
|
||||
/* clang-format on */
|
||||
|
||||
#include "blur_inc.glsl"
|
||||
|
||||
layout(location =0) in vec2 uv_interp;
|
||||
layout(location = 0) in vec2 uv_interp;
|
||||
/* clang-format on */
|
||||
|
||||
layout( set=0, binding=0 ) uniform sampler2D source_color;
|
||||
layout(set = 0, binding = 0) uniform sampler2D source_color;
|
||||
|
||||
#ifdef MODE_SSAO_MERGE
|
||||
layout( set=1, binding=0 ) uniform sampler2D source_ssao;
|
||||
layout(set = 1, binding = 0) uniform sampler2D source_ssao;
|
||||
#endif
|
||||
|
||||
#ifdef GLOW_USE_AUTO_EXPOSURE
|
||||
layout( set=1, binding=0 ) uniform sampler2D source_auto_exposure;
|
||||
layout(set = 1, binding = 0) uniform sampler2D source_auto_exposure;
|
||||
#endif
|
||||
|
||||
|
||||
layout(location = 0) out vec4 frag_color;
|
||||
|
||||
//DOF
|
||||
#if defined(MODE_DOF_FAR_BLUR) || defined(MODE_DOF_NEAR_BLUR)
|
||||
|
||||
layout( set=1, binding=0 ) uniform sampler2D dof_source_depth;
|
||||
layout(set = 1, binding = 0) uniform sampler2D dof_source_depth;
|
||||
|
||||
#ifdef DOF_NEAR_BLUR_MERGE
|
||||
layout( set=2, binding=0 ) uniform sampler2D source_dof_original;
|
||||
layout(set = 2, binding = 0) uniform sampler2D source_dof_original;
|
||||
#endif
|
||||
|
||||
#ifdef DOF_QUALITY_LOW
|
||||
|
@ -86,16 +80,15 @@ const float dof_kernel[21] = float[](0.028174, 0.032676, 0.037311, 0.041944, 0.0
|
|||
|
||||
#endif
|
||||
|
||||
|
||||
void main() {
|
||||
|
||||
#ifdef MODE_MIPMAP
|
||||
|
||||
vec2 pix_size = blur.pixel_size;
|
||||
vec4 color = texture(source_color, uv_interp + vec2(-0.5,-0.5) * pix_size);
|
||||
color += texture(source_color, uv_interp + vec2(0.5,-0.5) * pix_size);
|
||||
color += texture(source_color, uv_interp + vec2(0.5,0.5) * pix_size);
|
||||
color += texture(source_color, uv_interp + vec2(-0.5,0.5) * pix_size);
|
||||
vec4 color = texture(source_color, uv_interp + vec2(-0.5, -0.5) * pix_size);
|
||||
color += texture(source_color, uv_interp + vec2(0.5, -0.5) * pix_size);
|
||||
color += texture(source_color, uv_interp + vec2(0.5, 0.5) * pix_size);
|
||||
color += texture(source_color, uv_interp + vec2(-0.5, 0.5) * pix_size);
|
||||
frag_color = color / 4.0;
|
||||
|
||||
#endif
|
||||
|
@ -104,7 +97,7 @@ void main() {
|
|||
|
||||
//Simpler blur uses SIGMA2 for the gaussian kernel for a stronger effect
|
||||
|
||||
if (bool(blur.flags&FLAG_HORIZONTAL)) {
|
||||
if (bool(blur.flags & FLAG_HORIZONTAL)) {
|
||||
|
||||
vec2 pix_size = blur.pixel_size;
|
||||
pix_size *= 0.5; //reading from larger buffer, so use more samples
|
||||
|
@ -128,13 +121,11 @@ void main() {
|
|||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef MODE_GAUSSIAN_GLOW
|
||||
|
||||
//Glow uses larger sigma 1 for a more rounded blur effect
|
||||
|
||||
if (bool(blur.flags&FLAG_HORIZONTAL)) {
|
||||
if (bool(blur.flags & FLAG_HORIZONTAL)) {
|
||||
|
||||
vec2 pix_size = blur.pixel_size;
|
||||
pix_size *= 0.5; //reading from larger buffer, so use more samples
|
||||
|
@ -159,8 +150,7 @@ void main() {
|
|||
frag_color = color;
|
||||
}
|
||||
|
||||
|
||||
if (bool(blur.flags&FLAG_GLOW_FIRST_PASS)) {
|
||||
if (bool(blur.flags & FLAG_GLOW_FIRST_PASS)) {
|
||||
#ifdef GLOW_USE_AUTO_EXPOSURE
|
||||
|
||||
frag_color /= texelFetch(source_auto_exposure, ivec2(0, 0), 0).r / blur.glow_auto_exposure_grey;
|
||||
|
@ -173,7 +163,6 @@ void main() {
|
|||
frag_color = min(frag_color * feedback, vec4(blur.glow_luminance_cap));
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef MODE_DOF_FAR_BLUR
|
||||
|
@ -183,7 +172,7 @@ void main() {
|
|||
float depth = texture(dof_source_depth, uv_interp, 0.0).r;
|
||||
depth = depth * 2.0 - 1.0;
|
||||
|
||||
if (bool(blur.flags&FLAG_USE_ORTHOGONAL_PROJECTION)) {
|
||||
if (bool(blur.flags & FLAG_USE_ORTHOGONAL_PROJECTION)) {
|
||||
depth = ((depth + (blur.camera_z_far + blur.camera_z_near) / (blur.camera_z_far - blur.camera_z_near)) * (blur.camera_z_far - blur.camera_z_near)) / 2.0;
|
||||
} else {
|
||||
depth = 2.0 * blur.camera_z_near * blur.camera_z_far / (blur.camera_z_far + blur.camera_z_near - depth * (blur.camera_z_far - blur.camera_z_near));
|
||||
|
@ -202,14 +191,14 @@ void main() {
|
|||
float tap_depth = texture(dof_source_depth, tap_uv, 0.0).r;
|
||||
tap_depth = tap_depth * 2.0 - 1.0;
|
||||
|
||||
if (bool(blur.flags&FLAG_USE_ORTHOGONAL_PROJECTION)) {
|
||||
if (bool(blur.flags & FLAG_USE_ORTHOGONAL_PROJECTION)) {
|
||||
|
||||
tap_depth = ((tap_depth + (blur.camera_z_far + blur.camera_z_near) / (blur.camera_z_far - blur.camera_z_near)) * (blur.camera_z_far - blur.camera_z_near)) / 2.0;
|
||||
} else {
|
||||
tap_depth = 2.0 * blur.camera_z_near * blur.camera_z_far / (blur.camera_z_far + blur.camera_z_near - tap_depth * (blur.camera_z_far - blur.camera_z_near));
|
||||
}
|
||||
|
||||
float tap_amount = mix(smoothstep(blur.dof_begin, blur.dof_end, tap_depth), 1.0, int_ofs == 0);
|
||||
float tap_amount = mix(smoothstep(blur.dof_begin, blur.dof_end, tap_depth), 1.0, int_ofs == 0);
|
||||
tap_amount *= tap_amount * tap_amount; //prevent undesired glow effect
|
||||
|
||||
vec4 tap_color = texture(source_color, tap_uv, 0.0) * tap_k;
|
||||
|
@ -244,7 +233,7 @@ void main() {
|
|||
|
||||
float tap_depth = texture(dof_source_depth, tap_uv, 0.0).r;
|
||||
tap_depth = tap_depth * 2.0 - 1.0;
|
||||
if (bool(blur.flags&FLAG_USE_ORTHOGONAL_PROJECTION)) {
|
||||
if (bool(blur.flags & FLAG_USE_ORTHOGONAL_PROJECTION)) {
|
||||
|
||||
tap_depth = ((tap_depth + (blur.camera_z_far + blur.camera_z_near) / (blur.camera_z_far - blur.camera_z_near)) * (blur.camera_z_far - blur.camera_z_near)) / 2.0;
|
||||
} else {
|
||||
|
@ -253,7 +242,7 @@ void main() {
|
|||
float tap_amount = 1.0 - smoothstep(blur.dof_end, blur.dof_begin, tap_depth);
|
||||
tap_amount *= tap_amount * tap_amount; //prevent undesired glow effect
|
||||
|
||||
if (bool(blur.flags&FLAG_DOF_NEAR_FIRST_TAP)) {
|
||||
if (bool(blur.flags & FLAG_DOF_NEAR_FIRST_TAP)) {
|
||||
tap_color.a = 1.0 - smoothstep(blur.dof_end, blur.dof_begin, tap_depth);
|
||||
}
|
||||
|
||||
|
@ -271,7 +260,7 @@ void main() {
|
|||
}
|
||||
#endif
|
||||
|
||||
if (bool(blur.flags&FLAG_DOF_NEAR_FIRST_TAP)) {
|
||||
if (bool(blur.flags & FLAG_DOF_NEAR_FIRST_TAP)) {
|
||||
frag_color = color_accum;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
#define FLAG_HORIZONTAL (1<<0)
|
||||
#define FLAG_USE_BLUR_SECTION (1<<1)
|
||||
#define FLAG_USE_ORTHOGONAL_PROJECTION (1<<2)
|
||||
#define FLAG_DOF_NEAR_FIRST_TAP (1<<3)
|
||||
#define FLAG_GLOW_FIRST_PASS (1<<4)
|
||||
#define FLAG_FLIP_Y (1<<5)
|
||||
#define FLAG_HORIZONTAL (1 << 0)
|
||||
#define FLAG_USE_BLUR_SECTION (1 << 1)
|
||||
#define FLAG_USE_ORTHOGONAL_PROJECTION (1 << 2)
|
||||
#define FLAG_DOF_NEAR_FIRST_TAP (1 << 3)
|
||||
#define FLAG_GLOW_FIRST_PASS (1 << 4)
|
||||
#define FLAG_FLIP_Y (1 << 5)
|
||||
|
||||
layout(push_constant, binding = 1, std430) uniform Blur {
|
||||
vec4 section;
|
||||
vec2 pixel_size;
|
||||
uint flags;
|
||||
uint pad;
|
||||
//glow
|
||||
// Glow.
|
||||
float glow_strength;
|
||||
float glow_bloom;
|
||||
float glow_hdr_threshold;
|
||||
|
@ -19,7 +19,7 @@ layout(push_constant, binding = 1, std430) uniform Blur {
|
|||
float glow_white;
|
||||
float glow_luminance_cap;
|
||||
float glow_auto_exposure_grey;
|
||||
//dof
|
||||
// DOF.
|
||||
float dof_begin;
|
||||
float dof_end;
|
||||
float dof_radius;
|
||||
|
@ -30,7 +30,4 @@ layout(push_constant, binding = 1, std430) uniform Blur {
|
|||
float camera_z_near;
|
||||
|
||||
vec4 ssao_color;
|
||||
|
||||
|
||||
|
||||
} blur;
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
/* clang-format off */
|
||||
[vertex]
|
||||
/* clang-format on */
|
||||
|
||||
#version 450
|
||||
|
||||
/* clang-format off */
|
||||
VERSION_DEFINES
|
||||
/* clang-format on */
|
||||
|
||||
#ifdef USE_ATTRIBUTES
|
||||
layout(location = 0) in vec2 vertex_attrib;
|
||||
/* clang-format on */
|
||||
layout(location = 3) in vec4 color_attrib;
|
||||
layout(location = 4) in vec2 uv_attrib;
|
||||
|
||||
|
@ -19,22 +17,21 @@ layout(location = 6) in uvec4 bones_attrib;
|
|||
|
||||
#include "canvas_uniforms_inc.glsl"
|
||||
|
||||
|
||||
layout(location=0) out vec2 uv_interp;
|
||||
layout(location=1) out vec4 color_interp;
|
||||
layout(location=2) out vec2 vertex_interp;
|
||||
layout(location = 0) out vec2 uv_interp;
|
||||
layout(location = 1) out vec4 color_interp;
|
||||
layout(location = 2) out vec2 vertex_interp;
|
||||
|
||||
#ifdef USE_NINEPATCH
|
||||
|
||||
layout(location=3) out vec2 pixel_size_interp;
|
||||
layout(location = 3) out vec2 pixel_size_interp;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_MATERIAL_UNIFORMS
|
||||
layout(set = 1, binding = 1, std140) uniform MaterialUniforms {
|
||||
/* clang-format off */
|
||||
layout(set = 1, binding = 1, std140) uniform MaterialUniforms{
|
||||
/* clang-format off */
|
||||
MATERIAL_UNIFORMS
|
||||
/* clang-format on */
|
||||
/* clang-format on */
|
||||
} material;
|
||||
#endif
|
||||
|
||||
|
@ -42,32 +39,31 @@ MATERIAL_UNIFORMS
|
|||
VERTEX_SHADER_GLOBALS
|
||||
/* clang-format on */
|
||||
|
||||
|
||||
void main() {
|
||||
|
||||
vec4 instance_custom = vec4(0.0);
|
||||
#ifdef USE_PRIMITIVE
|
||||
|
||||
//weird bug,
|
||||
//this works
|
||||
//weird bug,
|
||||
//this works
|
||||
vec2 vertex;
|
||||
vec2 uv;
|
||||
vec4 color;
|
||||
|
||||
if (gl_VertexIndex==0) {
|
||||
if (gl_VertexIndex == 0) {
|
||||
vertex = draw_data.points[0];
|
||||
uv = draw_data.uvs[0];
|
||||
color = vec4(unpackHalf2x16(draw_data.colors[0]),unpackHalf2x16(draw_data.colors[1]));
|
||||
} else if (gl_VertexIndex==1) {
|
||||
color = vec4(unpackHalf2x16(draw_data.colors[0]), unpackHalf2x16(draw_data.colors[1]));
|
||||
} else if (gl_VertexIndex == 1) {
|
||||
vertex = draw_data.points[1];
|
||||
uv = draw_data.uvs[1];
|
||||
color = vec4(unpackHalf2x16(draw_data.colors[2]),unpackHalf2x16(draw_data.colors[3]));
|
||||
color = vec4(unpackHalf2x16(draw_data.colors[2]), unpackHalf2x16(draw_data.colors[3]));
|
||||
} else {
|
||||
vertex = draw_data.points[2];
|
||||
uv = draw_data.uvs[2];
|
||||
color = vec4(unpackHalf2x16(draw_data.colors[4]),unpackHalf2x16(draw_data.colors[5]));
|
||||
color = vec4(unpackHalf2x16(draw_data.colors[4]), unpackHalf2x16(draw_data.colors[5]));
|
||||
}
|
||||
uvec4 bones = uvec4(0,0,0,0);
|
||||
uvec4 bones = uvec4(0, 0, 0, 0);
|
||||
|
||||
#elif defined(USE_ATTRIBUTES)
|
||||
|
||||
|
@ -78,57 +74,56 @@ void main() {
|
|||
uvec4 bones = bones_attrib;
|
||||
#else
|
||||
|
||||
vec2 vertex_base_arr[4] = vec2[](vec2(0.0,0.0),vec2(0.0,1.0),vec2(1.0,1.0),vec2(1.0,0.0));
|
||||
vec2 vertex_base_arr[4] = vec2[](vec2(0.0, 0.0), vec2(0.0, 1.0), vec2(1.0, 1.0), vec2(1.0, 0.0));
|
||||
vec2 vertex_base = vertex_base_arr[gl_VertexIndex];
|
||||
|
||||
vec2 uv = draw_data.src_rect.xy + abs(draw_data.src_rect.zw) * ((draw_data.flags&FLAGS_TRANSPOSE_RECT)!=0 ? vertex_base.yx : vertex_base.xy);
|
||||
vec2 uv = draw_data.src_rect.xy + abs(draw_data.src_rect.zw) * ((draw_data.flags & FLAGS_TRANSPOSE_RECT) != 0 ? vertex_base.yx : vertex_base.xy);
|
||||
vec4 color = draw_data.modulation;
|
||||
vec2 vertex = draw_data.dst_rect.xy + abs(draw_data.dst_rect.zw) * mix(vertex_base, vec2(1.0, 1.0) - vertex_base, lessThan(draw_data.src_rect.zw, vec2(0.0, 0.0)));
|
||||
uvec4 bones = uvec4(0,0,0,0);
|
||||
uvec4 bones = uvec4(0, 0, 0, 0);
|
||||
|
||||
#endif
|
||||
|
||||
mat4 world_matrix = mat4(vec4(draw_data.world_x,0.0,0.0),vec4(draw_data.world_y,0.0,0.0),vec4(0.0,0.0,1.0,0.0),vec4(draw_data.world_ofs,0.0,1.0));
|
||||
mat4 world_matrix = mat4(vec4(draw_data.world_x, 0.0, 0.0), vec4(draw_data.world_y, 0.0, 0.0), vec4(0.0, 0.0, 1.0, 0.0), vec4(draw_data.world_ofs, 0.0, 1.0));
|
||||
|
||||
#if 0
|
||||
if (draw_data.flags & FLAGS_INSTANCING_ENABLED) {
|
||||
|
||||
if (draw_data.flags&FLAGS_INSTANCING_ENABLED) {
|
||||
|
||||
uint offset = draw_data.flags&FLAGS_INSTANCING_STRIDE_MASK;
|
||||
uint offset = draw_data.flags & FLAGS_INSTANCING_STRIDE_MASK;
|
||||
offset *= gl_InstanceIndex;
|
||||
mat4 instance_xform = mat4(
|
||||
vec4( texelFetch(instancing_buffer,offset+0),texelFetch(instancing_buffer,offset+1),0.0,texelFetch(instancing_buffer,offset+3) ),
|
||||
vec4( texelFetch(instancing_buffer,offset+4),texelFetch(instancing_buffer,offset+5),0.0,texelFetch(instancing_buffer,offset+7) ),
|
||||
vec4( 0.0,0.0,1.0,0.0),
|
||||
vec4( 0.0,0.0,0.0,1.0 ) );
|
||||
offset+=8;
|
||||
if ( draw_data.flags&FLAGS_INSTANCING_HAS_COLORS ) {
|
||||
mat4 instance_xform = mat4(
|
||||
vec4(texelFetch(instancing_buffer, offset + 0), texelFetch(instancing_buffer, offset + 1), 0.0, texelFetch(instancing_buffer, offset + 3)),
|
||||
vec4(texelFetch(instancing_buffer, offset + 4), texelFetch(instancing_buffer, offset + 5), 0.0, texelFetch(instancing_buffer, offset + 7)),
|
||||
vec4(0.0, 0.0, 1.0, 0.0),
|
||||
vec4(0.0, 0.0, 0.0, 1.0));
|
||||
offset += 8;
|
||||
if (draw_data.flags & FLAGS_INSTANCING_HAS_COLORS) {
|
||||
vec4 instance_color;
|
||||
if (draw_data.flags&FLAGS_INSTANCING_COLOR_8_BIT ) {
|
||||
uint bits = floatBitsToUint(texelFetch(instancing_buffer,offset));
|
||||
if (draw_data.flags & FLAGS_INSTANCING_COLOR_8_BIT) {
|
||||
uint bits = floatBitsToUint(texelFetch(instancing_buffer, offset));
|
||||
instance_color = unpackUnorm4x8(bits);
|
||||
offset+=1;
|
||||
offset += 1;
|
||||
} else {
|
||||
instance_color = vec4(texelFetch(instancing_buffer,offset+0),texelFetch(instancing_buffer,offset+1),texelFetch(instancing_buffer,offset+2),texelFetch(instancing_buffer,offset+3));
|
||||
offser+=4;
|
||||
instance_color = vec4(texelFetch(instancing_buffer, offset + 0), texelFetch(instancing_buffer, offset + 1), texelFetch(instancing_buffer, offset + 2), texelFetch(instancing_buffer, offset + 3));
|
||||
offser += 4;
|
||||
}
|
||||
|
||||
color*=instance_color;
|
||||
color *= instance_color;
|
||||
}
|
||||
if ( draw_data.flags&FLAGS_INSTANCING_HAS_CUSTOM_DATA ) {
|
||||
if (draw_data.flags&FLAGS_INSTANCING_CUSTOM_DATA_8_BIT ) {
|
||||
uint bits = floatBitsToUint(texelFetch(instancing_buffer,offset));
|
||||
if (draw_data.flags & FLAGS_INSTANCING_HAS_CUSTOM_DATA) {
|
||||
if (draw_data.flags & FLAGS_INSTANCING_CUSTOM_DATA_8_BIT) {
|
||||
uint bits = floatBitsToUint(texelFetch(instancing_buffer, offset));
|
||||
instance_custom = unpackUnorm4x8(bits);
|
||||
} else {
|
||||
instance_custom = vec4(texelFetch(instancing_buffer,offset+0),texelFetch(instancing_buffer,offset+1),texelFetch(instancing_buffer,offset+2),texelFetch(instancing_buffer,offset+3));
|
||||
instance_custom = vec4(texelFetch(instancing_buffer, offset + 0), texelFetch(instancing_buffer, offset + 1), texelFetch(instancing_buffer, offset + 2), texelFetch(instancing_buffer, offset + 3));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(USE_ATTRIBUTES) && !defined(USE_PRIMITIVE)
|
||||
if (bool(draw_data.flags&FLAGS_USING_PARTICLES)) {
|
||||
if (bool(draw_data.flags & FLAGS_USING_PARTICLES)) {
|
||||
//scale by texture size
|
||||
vertex /= draw_data.color_texture_pixel_size;
|
||||
}
|
||||
|
@ -143,19 +138,17 @@ VERTEX_SHADER_CODE
|
|||
/* clang-format on */
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef USE_NINEPATCH
|
||||
pixel_size_interp = abs(draw_data.dst_rect.zw) * vertex_base;
|
||||
#endif
|
||||
|
||||
#if !defined(SKIP_TRANSFORM_USED)
|
||||
vertex = (world_matrix * vec4(vertex,0.0,1.0)).xy;
|
||||
vertex = (world_matrix * vec4(vertex, 0.0, 1.0)).xy;
|
||||
#endif
|
||||
|
||||
color_interp = color;
|
||||
|
||||
if (bool(draw_data.flags&FLAGS_USE_PIXEL_SNAP)) {
|
||||
if (bool(draw_data.flags & FLAGS_USE_PIXEL_SNAP)) {
|
||||
|
||||
vertex = floor(vertex + 0.5);
|
||||
// precision issue on some hardware creates artifacts within texture
|
||||
|
@ -165,38 +158,38 @@ VERTEX_SHADER_CODE
|
|||
|
||||
#ifdef USE_ATTRIBUTES
|
||||
#if 0
|
||||
if (bool(draw_data.flags&FLAGS_USE_SKELETON) && bone_weights != vec4(0.0)) { //must be a valid bone
|
||||
if (bool(draw_data.flags & FLAGS_USE_SKELETON) && bone_weights != vec4(0.0)) { //must be a valid bone
|
||||
//skeleton transform
|
||||
|
||||
ivec4 bone_indicesi = ivec4(bone_indices);
|
||||
|
||||
uvec2 tex_ofs = bone_indicesi.x *2;
|
||||
uvec2 tex_ofs = bone_indicesi.x * 2;
|
||||
|
||||
mat2x4 m;
|
||||
m = mat2x4(
|
||||
texelFetch(skeleton_buffer, tex_ofs+0),
|
||||
texelFetch(skeleton_buffer, tex_ofs+1) ) *
|
||||
texelFetch(skeleton_buffer, tex_ofs + 0),
|
||||
texelFetch(skeleton_buffer, tex_ofs + 1)) *
|
||||
bone_weights.x;
|
||||
|
||||
tex_ofs = bone_indicesi.y * 2;
|
||||
|
||||
m += mat2x4(
|
||||
texelFetch(skeleton_buffer, tex_ofs+0),
|
||||
texelFetch(skeleton_buffer, tex_ofs+1) ) *
|
||||
texelFetch(skeleton_buffer, tex_ofs + 0),
|
||||
texelFetch(skeleton_buffer, tex_ofs + 1)) *
|
||||
bone_weights.y;
|
||||
|
||||
tex_ofs = bone_indicesi.z * 2;
|
||||
|
||||
m += mat2x4(
|
||||
texelFetch(skeleton_buffer, tex_ofs+0),
|
||||
texelFetch(skeleton_buffer, tex_ofs+1) ) *
|
||||
texelFetch(skeleton_buffer, tex_ofs + 0),
|
||||
texelFetch(skeleton_buffer, tex_ofs + 1)) *
|
||||
bone_weights.z;
|
||||
|
||||
tex_ofs = bone_indicesi.w * 2;
|
||||
|
||||
m += mat2x4(
|
||||
texelFetch(skeleton_buffer, tex_ofs+0),
|
||||
texelFetch(skeleton_buffer, tex_ofs+1) ) *
|
||||
texelFetch(skeleton_buffer, tex_ofs + 0),
|
||||
texelFetch(skeleton_buffer, tex_ofs + 1)) *
|
||||
bone_weights.w;
|
||||
|
||||
mat4 bone_matrix = skeleton_data.skeleton_transform * transpose(mat4(m[0], m[1], vec4(0.0, 0.0, 1.0, 0.0), vec4(0.0, 0.0, 0.0, 1.0))) * skeleton_data.skeleton_transform_inverse;
|
||||
|
@ -206,18 +199,16 @@ VERTEX_SHADER_CODE
|
|||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
vertex = (canvas_data.canvas_transform * vec4(vertex,0.0,1.0)).xy;
|
||||
vertex = (canvas_data.canvas_transform * vec4(vertex, 0.0, 1.0)).xy;
|
||||
|
||||
vertex_interp = vertex;
|
||||
uv_interp = uv;
|
||||
|
||||
gl_Position = canvas_data.screen_transform * vec4(vertex,0.0,1.0);
|
||||
gl_Position = canvas_data.screen_transform * vec4(vertex, 0.0, 1.0);
|
||||
|
||||
#ifdef USE_POINT_SIZE
|
||||
gl_PointSize=point_size;
|
||||
gl_PointSize = point_size;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/* clang-format off */
|
||||
|
@ -225,33 +216,31 @@ VERTEX_SHADER_CODE
|
|||
|
||||
#version 450
|
||||
|
||||
/* clang-format off */
|
||||
VERSION_DEFINES
|
||||
/* clang-format on */
|
||||
|
||||
#include "canvas_uniforms_inc.glsl"
|
||||
|
||||
layout(location=0) in vec2 uv_interp;
|
||||
layout(location=1) in vec4 color_interp;
|
||||
layout(location=2) in vec2 vertex_interp;
|
||||
layout(location = 0) in vec2 uv_interp;
|
||||
/* clang-format on */
|
||||
layout(location = 1) in vec4 color_interp;
|
||||
layout(location = 2) in vec2 vertex_interp;
|
||||
|
||||
#ifdef USE_NINEPATCH
|
||||
|
||||
layout(location=3) in vec2 pixel_size_interp;
|
||||
layout(location = 3) in vec2 pixel_size_interp;
|
||||
|
||||
#endif
|
||||
|
||||
layout(location = 0) out vec4 frag_color;
|
||||
|
||||
#ifdef USE_MATERIAL_UNIFORMS
|
||||
layout(set = 1, binding = 1, std140) uniform MaterialUniforms {
|
||||
/* clang-format off */
|
||||
layout(set = 1, binding = 1, std140) uniform MaterialUniforms{
|
||||
/* clang-format off */
|
||||
MATERIAL_UNIFORMS
|
||||
/* clang-format on */
|
||||
/* clang-format on */
|
||||
} material;
|
||||
#endif
|
||||
|
||||
|
||||
/* clang-format off */
|
||||
FRAGMENT_SHADER_GLOBALS
|
||||
/* clang-format on */
|
||||
|
@ -290,7 +279,7 @@ float map_ninepatch_axis(float pixel, float draw_size, float tex_pixel_size, flo
|
|||
} else if (pixel >= draw_size - margin_end) {
|
||||
return (tex_size - (draw_size - pixel)) * tex_pixel_size;
|
||||
} else {
|
||||
if (!bool(draw_data.flags&FLAGS_NINEPACH_DRAW_CENTER)) {
|
||||
if (!bool(draw_data.flags & FLAGS_NINEPACH_DRAW_CENTER)) {
|
||||
draw_center--;
|
||||
}
|
||||
|
||||
|
@ -318,7 +307,6 @@ float map_ninepatch_axis(float pixel, float draw_size, float tex_pixel_size, flo
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
|
@ -333,8 +321,8 @@ void main() {
|
|||
|
||||
int draw_center = 2;
|
||||
uv = vec2(
|
||||
map_ninepatch_axis(pixel_size_interp.x, abs(draw_data.dst_rect.z), draw_data.color_texture_pixel_size.x, draw_data.ninepatch_margins.x, draw_data.ninepatch_margins.z, int(draw_data.flags>>FLAGS_NINEPATCH_H_MODE_SHIFT)&0x3, draw_center),
|
||||
map_ninepatch_axis(pixel_size_interp.y, abs(draw_data.dst_rect.w), draw_data.color_texture_pixel_size.y, draw_data.ninepatch_margins.y, draw_data.ninepatch_margins.w, int(draw_data.flags>>FLAGS_NINEPATCH_V_MODE_SHIFT)&0x3, draw_center));
|
||||
map_ninepatch_axis(pixel_size_interp.x, abs(draw_data.dst_rect.z), draw_data.color_texture_pixel_size.x, draw_data.ninepatch_margins.x, draw_data.ninepatch_margins.z, int(draw_data.flags >> FLAGS_NINEPATCH_H_MODE_SHIFT) & 0x3, draw_center),
|
||||
map_ninepatch_axis(pixel_size_interp.y, abs(draw_data.dst_rect.w), draw_data.color_texture_pixel_size.y, draw_data.ninepatch_margins.y, draw_data.ninepatch_margins.w, int(draw_data.flags >> FLAGS_NINEPATCH_V_MODE_SHIFT) & 0x3, draw_center));
|
||||
|
||||
if (draw_center == 0) {
|
||||
color.a = 0.0;
|
||||
|
@ -342,18 +330,17 @@ void main() {
|
|||
|
||||
uv = uv * draw_data.src_rect.zw + draw_data.src_rect.xy; //apply region if needed
|
||||
|
||||
#endif
|
||||
if (bool(draw_data.flags&FLAGS_CLIP_RECT_UV)) {
|
||||
#endif
|
||||
if (bool(draw_data.flags & FLAGS_CLIP_RECT_UV)) {
|
||||
|
||||
uv = clamp(uv, draw_data.src_rect.xy, draw_data.src_rect.xy + abs(draw_data.src_rect.zw));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
color *= texture(sampler2D(color_texture,texture_sampler), uv);
|
||||
|
||||
uint light_count = (draw_data.flags>>FLAGS_LIGHT_COUNT_SHIFT)&0xF; //max 16 lights
|
||||
color *= texture(sampler2D(color_texture, texture_sampler), uv);
|
||||
|
||||
uint light_count = (draw_data.flags >> FLAGS_LIGHT_COUNT_SHIFT) & 0xF; //max 16 lights
|
||||
|
||||
vec3 normal;
|
||||
|
||||
|
@ -364,9 +351,8 @@ void main() {
|
|||
bool normal_used = false;
|
||||
#endif
|
||||
|
||||
|
||||
if (normal_used || (light_count > 0 && bool(draw_data.flags&FLAGS_DEFAULT_NORMAL_MAP_USED))) {
|
||||
normal.xy = texture(sampler2D(normal_texture,texture_sampler), uv).xy * vec2(2.0,-2.0) - vec2(1.0,-1.0);
|
||||
if (normal_used || (light_count > 0 && bool(draw_data.flags & FLAGS_DEFAULT_NORMAL_MAP_USED))) {
|
||||
normal.xy = texture(sampler2D(normal_texture, texture_sampler), uv).xy * vec2(2.0, -2.0) - vec2(1.0, -1.0);
|
||||
normal.z = sqrt(1.0 - dot(normal.xy, normal.xy));
|
||||
normal_used = true;
|
||||
} else {
|
||||
|
@ -382,22 +368,21 @@ void main() {
|
|||
bool specular_shininess_used = false;
|
||||
#endif
|
||||
|
||||
if (specular_shininess_used || (light_count > 0 && normal_used && bool(draw_data.flags&FLAGS_DEFAULT_SPECULAR_MAP_USED))) {
|
||||
specular_shininess = texture(sampler2D(specular_texture,texture_sampler ), uv);
|
||||
if (specular_shininess_used || (light_count > 0 && normal_used && bool(draw_data.flags & FLAGS_DEFAULT_SPECULAR_MAP_USED))) {
|
||||
specular_shininess = texture(sampler2D(specular_texture, texture_sampler), uv);
|
||||
specular_shininess *= unpackUnorm4x8(draw_data.specular_shininess);
|
||||
specular_shininess_used=true;
|
||||
specular_shininess_used = true;
|
||||
} else {
|
||||
specular_shininess = vec4(1.0);
|
||||
}
|
||||
|
||||
|
||||
#if defined(SCREEN_UV_USED)
|
||||
vec2 screen_uv = gl_FragCoord.xy * canvas_data.screen_pixel_size;
|
||||
#else
|
||||
vec2 screen_uv = vec2(0.0);
|
||||
#endif
|
||||
|
||||
vec3 light_vertex = vec3(vertex,0.0);
|
||||
vec3 light_vertex = vec3(vertex, 0.0);
|
||||
vec2 shadow_vertex = vertex;
|
||||
|
||||
{
|
||||
|
@ -423,65 +408,63 @@ FRAGMENT_SHADER_CODE
|
|||
//convert by item transform
|
||||
normal.xy = mat2(normalize(draw_data.world_x), normalize(draw_data.world_y)) * normal.xy;
|
||||
//convert by canvas transform
|
||||
normal = normalize((canvas_data.canvas_normal_transform * vec4(normal,0.0)).xyz);
|
||||
normal = normalize((canvas_data.canvas_normal_transform * vec4(normal, 0.0)).xyz);
|
||||
}
|
||||
|
||||
|
||||
vec4 base_color=color;
|
||||
if (bool(draw_data.flags&FLAGS_USING_LIGHT_MASK)) {
|
||||
color=vec4(0.0); //inivisible by default due to using light mask
|
||||
vec4 base_color = color;
|
||||
if (bool(draw_data.flags & FLAGS_USING_LIGHT_MASK)) {
|
||||
color = vec4(0.0); //inivisible by default due to using light mask
|
||||
}
|
||||
|
||||
color*=canvas_data.canvas_modulation;
|
||||
color *= canvas_data.canvas_modulation;
|
||||
#ifdef USE_LIGHTING
|
||||
for(uint i=0;i<MAX_LIGHT_TEXTURES;i++) {
|
||||
if (i>=light_count) {
|
||||
for (uint i = 0; i < MAX_LIGHT_TEXTURES; i++) {
|
||||
if (i >= light_count) {
|
||||
break;
|
||||
}
|
||||
uint light_base;
|
||||
if (i<8) {
|
||||
if (i<4) {
|
||||
light_base=draw_data.lights[0];
|
||||
if (i < 8) {
|
||||
if (i < 4) {
|
||||
light_base = draw_data.lights[0];
|
||||
} else {
|
||||
light_base=draw_data.lights[1];
|
||||
light_base = draw_data.lights[1];
|
||||
}
|
||||
} else {
|
||||
if (i<12) {
|
||||
light_base=draw_data.lights[2];
|
||||
if (i < 12) {
|
||||
light_base = draw_data.lights[2];
|
||||
} else {
|
||||
light_base=draw_data.lights[3];
|
||||
light_base = draw_data.lights[3];
|
||||
}
|
||||
}
|
||||
light_base>>=(i&3)*8;
|
||||
light_base&=0xFF;
|
||||
light_base >>= (i & 3) * 8;
|
||||
light_base &= 0xFF;
|
||||
|
||||
vec2 tex_uv = (vec4(vertex,0.0,1.0) * mat4(light_array.data[light_base].matrix[0],light_array.data[light_base].matrix[1],vec4(0.0,0.0,1.0,0.0),vec4(0.0,0.0,0.0,1.0))).xy; //multiply inverse given its transposed. Optimizer removes useless operations.
|
||||
vec4 light_color = texture(sampler2D(light_textures[i],texture_sampler),tex_uv);
|
||||
vec2 tex_uv = (vec4(vertex, 0.0, 1.0) * mat4(light_array.data[light_base].matrix[0], light_array.data[light_base].matrix[1], vec4(0.0, 0.0, 1.0, 0.0), vec4(0.0, 0.0, 0.0, 1.0))).xy; //multiply inverse given its transposed. Optimizer removes useless operations.
|
||||
vec4 light_color = texture(sampler2D(light_textures[i], texture_sampler), tex_uv);
|
||||
vec4 light_base_color = light_array.data[light_base].color;
|
||||
|
||||
#ifdef LIGHT_SHADER_CODE_USED
|
||||
|
||||
vec4 shadow_modulate = vec4(1.0);
|
||||
vec3 light_position = vec3(light_array.data[light_base].position,light_array.data[light_base].height);
|
||||
vec3 light_position = vec3(light_array.data[light_base].position, light_array.data[light_base].height);
|
||||
|
||||
light_color.rgb*=light_base_color.rgb;
|
||||
light_color = light_compute(light_vertex,light_position,normal,light_color,light_base_color.a,specular_shininess,shadow_modulate,screen_uv,color,uv);
|
||||
light_color.rgb *= light_base_color.rgb;
|
||||
light_color = light_compute(light_vertex, light_position, normal, light_color, light_base_color.a, specular_shininess, shadow_modulate, screen_uv, color, uv);
|
||||
#else
|
||||
|
||||
|
||||
light_color.rgb*=light_base_color.rgb*light_base_color.a;
|
||||
light_color.rgb *= light_base_color.rgb * light_base_color.a;
|
||||
|
||||
if (normal_used) {
|
||||
|
||||
vec3 light_pos = vec3(light_array.data[light_base].position,light_array.data[light_base].height);
|
||||
vec3 light_pos = vec3(light_array.data[light_base].position, light_array.data[light_base].height);
|
||||
vec3 pos = light_vertex;
|
||||
vec3 light_vec = normalize(light_pos-pos);
|
||||
float cNdotL = max(0.0,dot(normal,light_vec));
|
||||
vec3 light_vec = normalize(light_pos - pos);
|
||||
float cNdotL = max(0.0, dot(normal, light_vec));
|
||||
|
||||
if (specular_shininess_used) {
|
||||
//blinn
|
||||
vec3 view = vec3(0.0,0.0,1.0);// not great but good enough
|
||||
vec3 half_vec = normalize(view+light_vec);
|
||||
vec3 view = vec3(0.0, 0.0, 1.0); // not great but good enough
|
||||
vec3 half_vec = normalize(view + light_vec);
|
||||
|
||||
float cNdotV = max(dot(normal, view), 0.0);
|
||||
float cNdotH = max(dot(normal, half_vec), 0.0);
|
||||
|
@ -496,7 +479,6 @@ FRAGMENT_SHADER_CODE
|
|||
} else {
|
||||
light_color.rgb *= cNdotL;
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
if (any(lessThan(tex_uv, vec2(0.0, 0.0))) || any(greaterThanEqual(tex_uv, vec2(1.0, 1.0)))) {
|
||||
|
@ -504,98 +486,96 @@ FRAGMENT_SHADER_CODE
|
|||
light_color.a = 0.0;
|
||||
}
|
||||
|
||||
if (bool(light_array.data[light_base].flags&LIGHT_FLAGS_HAS_SHADOW)) {
|
||||
if (bool(light_array.data[light_base].flags & LIGHT_FLAGS_HAS_SHADOW)) {
|
||||
|
||||
vec2 shadow_pos = (vec4(shadow_vertex,0.0,1.0) * mat4(light_array.data[light_base].shadow_matrix[0],light_array.data[light_base].shadow_matrix[1],vec4(0.0,0.0,1.0,0.0),vec4(0.0,0.0,0.0,1.0))).xy; //multiply inverse given its transposed. Optimizer removes useless operations.
|
||||
vec2 shadow_pos = (vec4(shadow_vertex, 0.0, 1.0) * mat4(light_array.data[light_base].shadow_matrix[0], light_array.data[light_base].shadow_matrix[1], vec4(0.0, 0.0, 1.0, 0.0), vec4(0.0, 0.0, 0.0, 1.0))).xy; //multiply inverse given its transposed. Optimizer removes useless operations.
|
||||
|
||||
vec2 pos_norm = normalize(shadow_pos);
|
||||
vec2 pos_abs = abs(pos_norm);
|
||||
vec2 pos_box = pos_norm / max(pos_abs.x,pos_abs.y);
|
||||
vec2 pos_rot = pos_norm * mat2(vec2(0.7071067811865476,-0.7071067811865476),vec2(0.7071067811865476,0.7071067811865476)); //is there a faster way to 45 degrees rot?
|
||||
vec2 pos_box = pos_norm / max(pos_abs.x, pos_abs.y);
|
||||
vec2 pos_rot = pos_norm * mat2(vec2(0.7071067811865476, -0.7071067811865476), vec2(0.7071067811865476, 0.7071067811865476)); //is there a faster way to 45 degrees rot?
|
||||
float tex_ofs;
|
||||
float distance;
|
||||
if (pos_rot.y>0) {
|
||||
if (pos_rot.x>0) {
|
||||
tex_ofs=pos_box.y*0.125+0.125;
|
||||
distance=shadow_pos.x;
|
||||
if (pos_rot.y > 0) {
|
||||
if (pos_rot.x > 0) {
|
||||
tex_ofs = pos_box.y * 0.125 + 0.125;
|
||||
distance = shadow_pos.x;
|
||||
} else {
|
||||
tex_ofs=pos_box.x*-0.125+(0.25+0.125);
|
||||
distance=shadow_pos.y;
|
||||
tex_ofs = pos_box.x * -0.125 + (0.25 + 0.125);
|
||||
distance = shadow_pos.y;
|
||||
}
|
||||
} else {
|
||||
if (pos_rot.x<0) {
|
||||
tex_ofs=pos_box.y*-0.125+(0.5+0.125);
|
||||
distance=-shadow_pos.x;
|
||||
if (pos_rot.x < 0) {
|
||||
tex_ofs = pos_box.y * -0.125 + (0.5 + 0.125);
|
||||
distance = -shadow_pos.x;
|
||||
} else {
|
||||
tex_ofs=pos_box.x*0.125+(0.75+0.125);
|
||||
distance=-shadow_pos.y;
|
||||
tex_ofs = pos_box.x * 0.125 + (0.75 + 0.125);
|
||||
distance = -shadow_pos.y;
|
||||
}
|
||||
}
|
||||
|
||||
//float distance = length(shadow_pos);
|
||||
float shadow;
|
||||
uint shadow_mode = light_array.data[light_base].flags&LIGHT_FLAGS_FILTER_MASK;
|
||||
uint shadow_mode = light_array.data[light_base].flags & LIGHT_FLAGS_FILTER_MASK;
|
||||
|
||||
vec4 shadow_uv = vec4(tex_ofs,0.0,distance,1.0);
|
||||
vec4 shadow_uv = vec4(tex_ofs, 0.0, distance, 1.0);
|
||||
|
||||
if (shadow_mode==LIGHT_FLAGS_SHADOW_NEAREST) {
|
||||
shadow = textureProj(sampler2DShadow(shadow_textures[i],shadow_sampler),shadow_uv).x;
|
||||
} else if (shadow_mode==LIGHT_FLAGS_SHADOW_PCF5) {
|
||||
vec4 shadow_pixel_size = vec4(light_array.data[light_base].shadow_pixel_size,0.0,0.0,0.0);
|
||||
if (shadow_mode == LIGHT_FLAGS_SHADOW_NEAREST) {
|
||||
shadow = textureProj(sampler2DShadow(shadow_textures[i], shadow_sampler), shadow_uv).x;
|
||||
} else if (shadow_mode == LIGHT_FLAGS_SHADOW_PCF5) {
|
||||
vec4 shadow_pixel_size = vec4(light_array.data[light_base].shadow_pixel_size, 0.0, 0.0, 0.0);
|
||||
shadow = 0.0;
|
||||
shadow += textureProj(sampler2DShadow(shadow_textures[i],shadow_sampler),shadow_uv-shadow_pixel_size*2.0).x;
|
||||
shadow += textureProj(sampler2DShadow(shadow_textures[i],shadow_sampler),shadow_uv-shadow_pixel_size).x;
|
||||
shadow += textureProj(sampler2DShadow(shadow_textures[i],shadow_sampler),shadow_uv).x;
|
||||
shadow += textureProj(sampler2DShadow(shadow_textures[i],shadow_sampler),shadow_uv+shadow_pixel_size).x;
|
||||
shadow += textureProj(sampler2DShadow(shadow_textures[i],shadow_sampler),shadow_uv+shadow_pixel_size*2.0).x;
|
||||
shadow/=5.0;
|
||||
shadow += textureProj(sampler2DShadow(shadow_textures[i], shadow_sampler), shadow_uv - shadow_pixel_size * 2.0).x;
|
||||
shadow += textureProj(sampler2DShadow(shadow_textures[i], shadow_sampler), shadow_uv - shadow_pixel_size).x;
|
||||
shadow += textureProj(sampler2DShadow(shadow_textures[i], shadow_sampler), shadow_uv).x;
|
||||
shadow += textureProj(sampler2DShadow(shadow_textures[i], shadow_sampler), shadow_uv + shadow_pixel_size).x;
|
||||
shadow += textureProj(sampler2DShadow(shadow_textures[i], shadow_sampler), shadow_uv + shadow_pixel_size * 2.0).x;
|
||||
shadow /= 5.0;
|
||||
} else { //PCF13
|
||||
vec4 shadow_pixel_size = vec4(light_array.data[light_base].shadow_pixel_size,0.0,0.0,0.0);
|
||||
vec4 shadow_pixel_size = vec4(light_array.data[light_base].shadow_pixel_size, 0.0, 0.0, 0.0);
|
||||
shadow = 0.0;
|
||||
shadow += textureProj(sampler2DShadow(shadow_textures[i],shadow_sampler),shadow_uv-shadow_pixel_size*6.0).x;
|
||||
shadow += textureProj(sampler2DShadow(shadow_textures[i],shadow_sampler),shadow_uv-shadow_pixel_size*5.0).x;
|
||||
shadow += textureProj(sampler2DShadow(shadow_textures[i],shadow_sampler),shadow_uv-shadow_pixel_size*4.0).x;
|
||||
shadow += textureProj(sampler2DShadow(shadow_textures[i],shadow_sampler),shadow_uv-shadow_pixel_size*3.0).x;
|
||||
shadow += textureProj(sampler2DShadow(shadow_textures[i],shadow_sampler),shadow_uv-shadow_pixel_size*2.0).x;
|
||||
shadow += textureProj(sampler2DShadow(shadow_textures[i],shadow_sampler),shadow_uv-shadow_pixel_size).x;
|
||||
shadow += textureProj(sampler2DShadow(shadow_textures[i],shadow_sampler),shadow_uv).x;
|
||||
shadow += textureProj(sampler2DShadow(shadow_textures[i],shadow_sampler),shadow_uv+shadow_pixel_size).x;
|
||||
shadow += textureProj(sampler2DShadow(shadow_textures[i],shadow_sampler),shadow_uv+shadow_pixel_size*2.0).x;
|
||||
shadow += textureProj(sampler2DShadow(shadow_textures[i],shadow_sampler),shadow_uv+shadow_pixel_size*3.0).x;
|
||||
shadow += textureProj(sampler2DShadow(shadow_textures[i],shadow_sampler),shadow_uv+shadow_pixel_size*4.0).x;
|
||||
shadow += textureProj(sampler2DShadow(shadow_textures[i],shadow_sampler),shadow_uv+shadow_pixel_size*5.0).x;
|
||||
shadow += textureProj(sampler2DShadow(shadow_textures[i],shadow_sampler),shadow_uv+shadow_pixel_size*6.0).x;
|
||||
shadow/=13.0;
|
||||
shadow += textureProj(sampler2DShadow(shadow_textures[i], shadow_sampler), shadow_uv - shadow_pixel_size * 6.0).x;
|
||||
shadow += textureProj(sampler2DShadow(shadow_textures[i], shadow_sampler), shadow_uv - shadow_pixel_size * 5.0).x;
|
||||
shadow += textureProj(sampler2DShadow(shadow_textures[i], shadow_sampler), shadow_uv - shadow_pixel_size * 4.0).x;
|
||||
shadow += textureProj(sampler2DShadow(shadow_textures[i], shadow_sampler), shadow_uv - shadow_pixel_size * 3.0).x;
|
||||
shadow += textureProj(sampler2DShadow(shadow_textures[i], shadow_sampler), shadow_uv - shadow_pixel_size * 2.0).x;
|
||||
shadow += textureProj(sampler2DShadow(shadow_textures[i], shadow_sampler), shadow_uv - shadow_pixel_size).x;
|
||||
shadow += textureProj(sampler2DShadow(shadow_textures[i], shadow_sampler), shadow_uv).x;
|
||||
shadow += textureProj(sampler2DShadow(shadow_textures[i], shadow_sampler), shadow_uv + shadow_pixel_size).x;
|
||||
shadow += textureProj(sampler2DShadow(shadow_textures[i], shadow_sampler), shadow_uv + shadow_pixel_size * 2.0).x;
|
||||
shadow += textureProj(sampler2DShadow(shadow_textures[i], shadow_sampler), shadow_uv + shadow_pixel_size * 3.0).x;
|
||||
shadow += textureProj(sampler2DShadow(shadow_textures[i], shadow_sampler), shadow_uv + shadow_pixel_size * 4.0).x;
|
||||
shadow += textureProj(sampler2DShadow(shadow_textures[i], shadow_sampler), shadow_uv + shadow_pixel_size * 5.0).x;
|
||||
shadow += textureProj(sampler2DShadow(shadow_textures[i], shadow_sampler), shadow_uv + shadow_pixel_size * 6.0).x;
|
||||
shadow /= 13.0;
|
||||
}
|
||||
|
||||
vec4 shadow_color = light_array.data[light_base].shadow_color;
|
||||
#ifdef LIGHT_SHADER_CODE_USED
|
||||
shadow_color*=shadow_modulate;
|
||||
shadow_color *= shadow_modulate;
|
||||
#endif
|
||||
light_color = mix(light_color,shadow_color,shadow);
|
||||
|
||||
light_color = mix(light_color, shadow_color, shadow);
|
||||
}
|
||||
|
||||
uint blend_mode = light_array.data[light_base].flags&LIGHT_FLAGS_BLEND_MASK;
|
||||
uint blend_mode = light_array.data[light_base].flags & LIGHT_FLAGS_BLEND_MASK;
|
||||
|
||||
switch(blend_mode) {
|
||||
switch (blend_mode) {
|
||||
case LIGHT_FLAGS_BLEND_MODE_ADD: {
|
||||
color.rgb+=light_color.rgb*light_color.a;
|
||||
color.rgb += light_color.rgb * light_color.a;
|
||||
} break;
|
||||
case LIGHT_FLAGS_BLEND_MODE_SUB: {
|
||||
color.rgb-=light_color.rgb*light_color.a;
|
||||
color.rgb -= light_color.rgb * light_color.a;
|
||||
} break;
|
||||
case LIGHT_FLAGS_BLEND_MODE_MIX: {
|
||||
color.rgb=mix(color.rgb,light_color.rgb,light_color.a);
|
||||
color.rgb = mix(color.rgb, light_color.rgb, light_color.a);
|
||||
} break;
|
||||
case LIGHT_FLAGS_BLEND_MODE_MASK: {
|
||||
light_color.a*=base_color.a;
|
||||
color.rgb=mix(color.rgb,light_color.rgb,light_color.a);
|
||||
light_color.a *= base_color.a;
|
||||
color.rgb = mix(color.rgb, light_color.rgb, light_color.a);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
frag_color = color;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* clang-format off */
|
||||
[vertex]
|
||||
/* clang-format on */
|
||||
|
||||
#version 450
|
||||
|
||||
layout(location = 0) in highp vec3 vertex;
|
||||
/* clang-format on */
|
||||
|
||||
layout(push_constant, binding = 0, std430) uniform Constants {
|
||||
|
||||
|
@ -18,23 +18,22 @@ layout(location = 0) out highp float depth;
|
|||
|
||||
void main() {
|
||||
|
||||
highp vec4 vtx = vec4(vertex, 1.0) * mat4(constants.modelview[0],constants.modelview[1],vec4(0.0,0.0,1.0,0.0),vec4(0.0,0.0,0.0,1.0));
|
||||
depth = dot(constants.direction,vtx.xy);
|
||||
highp vec4 vtx = vec4(vertex, 1.0) * mat4(constants.modelview[0], constants.modelview[1], vec4(0.0, 0.0, 1.0, 0.0), vec4(0.0, 0.0, 0.0, 1.0));
|
||||
depth = dot(constants.direction, vtx.xy);
|
||||
|
||||
gl_Position = constants.projection * vtx;
|
||||
|
||||
}
|
||||
|
||||
/* clang-format off */
|
||||
[fragment]
|
||||
/* clang-format on */
|
||||
|
||||
#version 450
|
||||
|
||||
layout(location = 0) in highp float depth;
|
||||
/* clang-format on */
|
||||
layout(location = 0) out highp float distance_buf;
|
||||
|
||||
void main() {
|
||||
|
||||
distance_buf=depth;
|
||||
distance_buf = depth;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
|
||||
|
||||
|
||||
#define M_PI 3.14159265359
|
||||
|
||||
#define FLAGS_INSTANCING_STRIDE_MASK 0xF
|
||||
#define FLAGS_INSTANCING_ENABLED (1<<4)
|
||||
#define FLAGS_INSTANCING_ENABLED (1 << 4)
|
||||
#define FLAGS_INSTANCING_HAS_COLORS (1 << 5)
|
||||
#define FLAGS_INSTANCING_COLOR_8BIT (1 << 6)
|
||||
#define FLAGS_INSTANCING_HAS_CUSTOM_DATA (1 << 7)
|
||||
|
@ -53,7 +50,6 @@ layout(push_constant, binding = 0, std430) uniform DrawData {
|
|||
#endif
|
||||
vec2 color_texture_pixel_size;
|
||||
uint lights[4];
|
||||
|
||||
} draw_data;
|
||||
|
||||
// The values passed per draw primitives are cached within it
|
||||
|
@ -67,7 +63,6 @@ layout(set = 0, binding = 5) uniform textureBuffer instancing_buffer;
|
|||
|
||||
/* SET1: Is reserved for the material */
|
||||
|
||||
|
||||
#ifdef USE_MATERIAL_SAMPLERS
|
||||
|
||||
layout(set = 1, binding = 0) uniform sampler material_samplers[12];
|
||||
|
@ -76,7 +71,6 @@ layout(set = 1, binding = 0) uniform sampler material_samplers[12];
|
|||
|
||||
/* SET2: Canvas Item State (including lighting) */
|
||||
|
||||
|
||||
layout(set = 2, binding = 0, std140) uniform CanvasData {
|
||||
mat4 canvas_transform;
|
||||
mat4 screen_transform;
|
||||
|
@ -95,21 +89,19 @@ layout(set = 2, binding = 2, std140) uniform SkeletonData {
|
|||
mat4 skeleton_transform_inverse;
|
||||
} skeleton_data;
|
||||
|
||||
|
||||
#ifdef USE_LIGHTING
|
||||
|
||||
#define LIGHT_FLAGS_BLEND_MASK (3<<16)
|
||||
#define LIGHT_FLAGS_BLEND_MODE_ADD (0<<16)
|
||||
#define LIGHT_FLAGS_BLEND_MODE_SUB (1<<16)
|
||||
#define LIGHT_FLAGS_BLEND_MODE_MIX (2<<16)
|
||||
#define LIGHT_FLAGS_BLEND_MODE_MASK (3<<16)
|
||||
#define LIGHT_FLAGS_HAS_SHADOW (1<<20)
|
||||
#define LIGHT_FLAGS_BLEND_MASK (3 << 16)
|
||||
#define LIGHT_FLAGS_BLEND_MODE_ADD (0 << 16)
|
||||
#define LIGHT_FLAGS_BLEND_MODE_SUB (1 << 16)
|
||||
#define LIGHT_FLAGS_BLEND_MODE_MIX (2 << 16)
|
||||
#define LIGHT_FLAGS_BLEND_MODE_MASK (3 << 16)
|
||||
#define LIGHT_FLAGS_HAS_SHADOW (1 << 20)
|
||||
#define LIGHT_FLAGS_FILTER_SHIFT 22
|
||||
#define LIGHT_FLAGS_FILTER_MASK (3<<22)
|
||||
#define LIGHT_FLAGS_SHADOW_NEAREST (0<<22)
|
||||
#define LIGHT_FLAGS_SHADOW_PCF5 (1<<22)
|
||||
#define LIGHT_FLAGS_SHADOW_PCF13 (2<<22)
|
||||
|
||||
#define LIGHT_FLAGS_FILTER_MASK (3 << 22)
|
||||
#define LIGHT_FLAGS_SHADOW_NEAREST (0 << 22)
|
||||
#define LIGHT_FLAGS_SHADOW_PCF5 (1 << 22)
|
||||
#define LIGHT_FLAGS_SHADOW_PCF13 (2 << 22)
|
||||
|
||||
struct Light {
|
||||
mat2x4 matrix; //light to texture coordinate matrix (transposed)
|
||||
|
|
|
@ -1,53 +1,46 @@
|
|||
/* clang-format off */
|
||||
[vertex]
|
||||
/* clang-format on */
|
||||
|
||||
#version 450
|
||||
|
||||
/* clang-format off */
|
||||
VERSION_DEFINES
|
||||
/* clang-format on */
|
||||
|
||||
layout(location =0) out vec2 uv_interp;
|
||||
layout(location = 0) out vec2 uv_interp;
|
||||
/* clang-format on */
|
||||
|
||||
void main() {
|
||||
|
||||
vec2 base_arr[4] = vec2[](vec2(0.0,0.0),vec2(0.0,1.0),vec2(1.0,1.0),vec2(1.0,0.0));
|
||||
vec2 base_arr[4] = vec2[](vec2(0.0, 0.0), vec2(0.0, 1.0), vec2(1.0, 1.0), vec2(1.0, 0.0));
|
||||
uv_interp = base_arr[gl_VertexIndex];
|
||||
|
||||
gl_Position = vec4( uv_interp *2.0 - 1.0, 0.0, 1.0);
|
||||
|
||||
gl_Position = vec4(uv_interp * 2.0 - 1.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
/* clang-format off */
|
||||
[fragment]
|
||||
/* clang-format on */
|
||||
|
||||
#version 450
|
||||
|
||||
/* clang-format off */
|
||||
VERSION_DEFINES
|
||||
/* clang-format on */
|
||||
|
||||
layout(location =0) in vec2 uv_interp;
|
||||
layout(location = 0) in vec2 uv_interp;
|
||||
/* clang-format on */
|
||||
|
||||
#ifdef MODE_CUBE_TO_DP
|
||||
|
||||
layout( set=0, binding=0 ) uniform samplerCube source_cube;
|
||||
layout(set = 0, binding = 0) uniform samplerCube source_cube;
|
||||
|
||||
layout(push_constant, binding = 0, std430) uniform Params {
|
||||
float bias;
|
||||
float z_far;
|
||||
float z_near;
|
||||
bool z_flip;
|
||||
|
||||
} params;
|
||||
|
||||
layout(location=0) out float depth_buffer;
|
||||
layout(location = 0) out float depth_buffer;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
void main() {
|
||||
|
||||
#ifdef MODE_CUBE_TO_DP
|
||||
|
@ -57,7 +50,6 @@ void main() {
|
|||
normal.z = 0.5 - 0.5 * ((normal.x * normal.x) + (normal.y * normal.y));
|
||||
normal = normalize(normal);
|
||||
|
||||
|
||||
normal.y = -normal.y; //needs to be flipped to match projection matrix
|
||||
if (!params.z_flip) {
|
||||
normal.z = -normal.z;
|
||||
|
|
|
@ -1,41 +1,34 @@
|
|||
/* clang-format off */
|
||||
[vertex]
|
||||
/* clang-format on */
|
||||
|
||||
#version 450
|
||||
|
||||
/* clang-format off */
|
||||
VERSION_DEFINES
|
||||
|
||||
layout(location = 0) out highp vec2 uv_interp;
|
||||
/* clang-format on */
|
||||
|
||||
|
||||
layout(location=0) out highp vec2 uv_interp;
|
||||
|
||||
|
||||
void main() {
|
||||
|
||||
vec2 base_arr[4] = vec2[](vec2(0.0,0.0),vec2(0.0,1.0),vec2(1.0,1.0),vec2(1.0,0.0));
|
||||
vec2 base_arr[4] = vec2[](vec2(0.0, 0.0), vec2(0.0, 1.0), vec2(1.0, 1.0), vec2(1.0, 0.0));
|
||||
uv_interp = base_arr[gl_VertexIndex];
|
||||
gl_Position = vec4( uv_interp *2.0 - 1.0, 0.0, 1.0);
|
||||
|
||||
gl_Position = vec4(uv_interp * 2.0 - 1.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
/* clang-format off */
|
||||
[fragment]
|
||||
/* clang-format on */
|
||||
|
||||
#version 450
|
||||
|
||||
/* clang-format off */
|
||||
VERSION_DEFINES
|
||||
/* clang-format on */
|
||||
|
||||
#ifdef MODE_SOURCE_PANORAMA
|
||||
layout( set=0, binding=0 ) uniform sampler2D source_panorama;
|
||||
layout(set = 0, binding = 0) uniform sampler2D source_panorama;
|
||||
/* clang-format on */
|
||||
#endif
|
||||
|
||||
#ifdef MODE_SOURCE_CUBEMAP
|
||||
layout( set=0, binding=0 ) uniform samplerCube source_cube;
|
||||
layout(set = 0, binding = 0) uniform samplerCube source_cube;
|
||||
#endif
|
||||
|
||||
layout(push_constant, binding = 1, std430) uniform Params {
|
||||
|
@ -45,7 +38,7 @@ layout(push_constant, binding = 1, std430) uniform Params {
|
|||
bool use_direct_write;
|
||||
} params;
|
||||
|
||||
layout(location=0) in vec2 uv_interp;
|
||||
layout(location = 0) in vec2 uv_interp;
|
||||
|
||||
layout(location = 0) out vec4 frag_color;
|
||||
|
||||
|
@ -184,7 +177,6 @@ vec4 texturePanorama(vec3 normal, sampler2D pano) {
|
|||
|
||||
#endif
|
||||
|
||||
|
||||
void main() {
|
||||
|
||||
vec2 uv = (uv_interp * 2.0) - 1.0;
|
||||
|
@ -200,7 +192,7 @@ void main() {
|
|||
#endif
|
||||
|
||||
#ifdef MODE_SOURCE_CUBEMAP
|
||||
frag_color = vec4(texture(source_cube,N).rgb, 1.0);
|
||||
frag_color = vec4(texture(source_cube, N).rgb, 1.0);
|
||||
#endif
|
||||
|
||||
} else {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* clang-format off */
|
||||
[compute]
|
||||
|
||||
#version 450
|
||||
|
@ -5,26 +6,23 @@
|
|||
VERSION_DEFINES
|
||||
|
||||
#ifdef MODE_DYNAMIC
|
||||
|
||||
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
|
||||
|
||||
#else
|
||||
|
||||
layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
|
||||
|
||||
#endif
|
||||
/* clang-format on */
|
||||
|
||||
#ifndef MODE_DYNAMIC
|
||||
|
||||
#define NO_CHILDREN 0xFFFFFFFF
|
||||
#define GREY_VEC vec3(0.33333,0.33333,0.33333)
|
||||
#define GREY_VEC vec3(0.33333, 0.33333, 0.33333)
|
||||
|
||||
struct CellChildren {
|
||||
uint children[8];
|
||||
};
|
||||
|
||||
layout(set=0,binding=1,std430) buffer CellChildrenBuffer {
|
||||
CellChildren data[];
|
||||
layout(set = 0, binding = 1, std430) buffer CellChildrenBuffer {
|
||||
CellChildren data[];
|
||||
} cell_children;
|
||||
|
||||
struct CellData {
|
||||
|
@ -34,11 +32,10 @@ struct CellData {
|
|||
uint normal; //RGB normal encoded
|
||||
};
|
||||
|
||||
layout(set=0,binding=2,std430) buffer CellDataBuffer {
|
||||
CellData data[];
|
||||
layout(set = 0, binding = 2, std430) buffer CellDataBuffer {
|
||||
CellData data[];
|
||||
} cell_data;
|
||||
|
||||
|
||||
#endif // MODE DYNAMIC
|
||||
|
||||
#define LIGHT_TYPE_DIRECTIONAL 0
|
||||
|
@ -64,23 +61,19 @@ struct Light {
|
|||
bool has_shadow;
|
||||
};
|
||||
|
||||
|
||||
layout(set=0,binding=3,std140) uniform Lights {
|
||||
Light data[MAX_LIGHTS];
|
||||
layout(set = 0, binding = 3, std140) uniform Lights {
|
||||
Light data[MAX_LIGHTS];
|
||||
} lights;
|
||||
|
||||
|
||||
|
||||
#endif // MODE COMPUTE LIGHT
|
||||
|
||||
|
||||
#ifdef MODE_SECOND_BOUNCE
|
||||
|
||||
layout (set=0,binding=5) uniform texture3D color_texture;
|
||||
layout(set = 0, binding = 5) uniform texture3D color_texture;
|
||||
|
||||
#ifdef MODE_ANISOTROPIC
|
||||
layout (set=0,binding=7) uniform texture3D aniso_pos_texture;
|
||||
layout (set=0,binding=8) uniform texture3D aniso_neg_texture;
|
||||
layout(set = 0, binding = 7) uniform texture3D aniso_pos_texture;
|
||||
layout(set = 0, binding = 8) uniform texture3D aniso_neg_texture;
|
||||
#endif // MODE ANISOTROPIC
|
||||
|
||||
#endif // MODE_SECOND_BOUNCE
|
||||
|
@ -88,7 +81,6 @@ layout (set=0,binding=8) uniform texture3D aniso_neg_texture;
|
|||
#ifndef MODE_DYNAMIC
|
||||
|
||||
layout(push_constant, binding = 0, std430) uniform Params {
|
||||
|
||||
ivec3 limits;
|
||||
uint stack_size;
|
||||
|
||||
|
@ -101,38 +93,33 @@ layout(push_constant, binding = 0, std430) uniform Params {
|
|||
uint cell_count;
|
||||
float aniso_strength;
|
||||
uint pad;
|
||||
|
||||
} params;
|
||||
|
||||
|
||||
layout(set=0,binding=4,std430) buffer Outputs {
|
||||
vec4 data[];
|
||||
layout(set = 0, binding = 4, std430) buffer Outputs {
|
||||
vec4 data[];
|
||||
} outputs;
|
||||
|
||||
#endif // MODE DYNAMIC
|
||||
|
||||
layout (set=0,binding=9) uniform texture3D texture_sdf;
|
||||
layout (set=0,binding=10) uniform sampler texture_sampler;
|
||||
layout(set = 0, binding = 9) uniform texture3D texture_sdf;
|
||||
layout(set = 0, binding = 10) uniform sampler texture_sampler;
|
||||
|
||||
#ifdef MODE_WRITE_TEXTURE
|
||||
|
||||
layout (rgba8,set=0,binding=5) uniform restrict writeonly image3D color_tex;
|
||||
layout(rgba8, set = 0, binding = 5) uniform restrict writeonly image3D color_tex;
|
||||
|
||||
#ifdef MODE_ANISOTROPIC
|
||||
|
||||
layout (r16ui,set=0,binding=6) uniform restrict writeonly uimage3D aniso_pos_tex;
|
||||
layout (r16ui,set=0,binding=7) uniform restrict writeonly uimage3D aniso_neg_tex;
|
||||
layout(r16ui, set = 0, binding = 6) uniform restrict writeonly uimage3D aniso_pos_tex;
|
||||
layout(r16ui, set = 0, binding = 7) uniform restrict writeonly uimage3D aniso_neg_tex;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef MODE_DYNAMIC
|
||||
|
||||
layout(push_constant, binding = 0, std430) uniform Params {
|
||||
|
||||
ivec3 limits;
|
||||
uint light_count; //when not lighting
|
||||
ivec3 x_dir;
|
||||
|
@ -155,35 +142,35 @@ layout(push_constant, binding = 0, std430) uniform Params {
|
|||
|
||||
#ifdef MODE_DYNAMIC_LIGHTING
|
||||
|
||||
layout (rgba8,set=0,binding=5) uniform restrict readonly image2D source_albedo;
|
||||
layout (rgba8,set=0,binding=6) uniform restrict readonly image2D source_normal;
|
||||
layout (rgba8,set=0,binding=7) uniform restrict readonly image2D source_orm;
|
||||
layout(rgba8, set = 0, binding = 5) uniform restrict readonly image2D source_albedo;
|
||||
layout(rgba8, set = 0, binding = 6) uniform restrict readonly image2D source_normal;
|
||||
layout(rgba8, set = 0, binding = 7) uniform restrict readonly image2D source_orm;
|
||||
//layout (set=0,binding=8) uniform texture2D source_depth;
|
||||
layout (rgba16f,set=0,binding=11) uniform restrict image2D emission;
|
||||
layout (r32f,set=0,binding=12) uniform restrict image2D depth;
|
||||
layout(rgba16f, set = 0, binding = 11) uniform restrict image2D emission;
|
||||
layout(r32f, set = 0, binding = 12) uniform restrict image2D depth;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef MODE_DYNAMIC_SHRINK
|
||||
|
||||
layout (rgba16f,set=0,binding=5) uniform restrict readonly image2D source_light;
|
||||
layout (r32f,set=0,binding=6) uniform restrict readonly image2D source_depth;
|
||||
layout(rgba16f, set = 0, binding = 5) uniform restrict readonly image2D source_light;
|
||||
layout(r32f, set = 0, binding = 6) uniform restrict readonly image2D source_depth;
|
||||
|
||||
#ifdef MODE_DYNAMIC_SHRINK_WRITE
|
||||
|
||||
layout (rgba16f,set=0,binding=7) uniform restrict writeonly image2D light;
|
||||
layout (r32f,set=0,binding=8) uniform restrict writeonly image2D depth;
|
||||
layout(rgba16f, set = 0, binding = 7) uniform restrict writeonly image2D light;
|
||||
layout(r32f, set = 0, binding = 8) uniform restrict writeonly image2D depth;
|
||||
|
||||
#endif // MODE_DYNAMIC_SHRINK_WRITE
|
||||
|
||||
#ifdef MODE_DYNAMIC_SHRINK_PLOT
|
||||
|
||||
layout (rgba8,set=0,binding=11) uniform restrict image3D color_texture;
|
||||
layout(rgba8, set = 0, binding = 11) uniform restrict image3D color_texture;
|
||||
|
||||
#ifdef MODE_ANISOTROPIC
|
||||
|
||||
layout (r16ui,set=0,binding=12) uniform restrict writeonly uimage3D aniso_pos_texture;
|
||||
layout (r16ui,set=0,binding=13) uniform restrict writeonly uimage3D aniso_neg_texture;
|
||||
layout(r16ui, set = 0, binding = 12) uniform restrict writeonly uimage3D aniso_pos_texture;
|
||||
layout(r16ui, set = 0, binding = 13) uniform restrict writeonly uimage3D aniso_neg_texture;
|
||||
|
||||
#endif // MODE ANISOTROPIC
|
||||
|
||||
|
@ -193,25 +180,22 @@ layout (r16ui,set=0,binding=13) uniform restrict writeonly uimage3D aniso_neg_te
|
|||
|
||||
//layout (rgba8,set=0,binding=5) uniform restrict writeonly image3D color_tex;
|
||||
|
||||
|
||||
#endif // MODE DYNAMIC
|
||||
|
||||
#if defined(MODE_COMPUTE_LIGHT) || defined(MODE_DYNAMIC_LIGHTING)
|
||||
|
||||
float raymarch(float distance,float distance_adv,vec3 from,vec3 direction) {
|
||||
|
||||
|
||||
float raymarch(float distance, float distance_adv, vec3 from, vec3 direction) {
|
||||
|
||||
vec3 cell_size = 1.0 / vec3(params.limits);
|
||||
float occlusion = 1.0;
|
||||
while (distance > 0.5) { //use this to avoid precision errors
|
||||
float advance = texture(sampler3D(texture_sdf,texture_sampler),from * cell_size).r * 255.0 - 1.0;
|
||||
if (advance<0.0) {
|
||||
float advance = texture(sampler3D(texture_sdf, texture_sampler), from * cell_size).r * 255.0 - 1.0;
|
||||
if (advance < 0.0) {
|
||||
occlusion = 0.0;
|
||||
break;
|
||||
}
|
||||
|
||||
occlusion=min(advance,occlusion);
|
||||
occlusion = min(advance, occlusion);
|
||||
|
||||
advance = max(distance_adv, advance - mod(advance, distance_adv)); //should always advance in multiples of distance_adv
|
||||
|
||||
|
@ -219,14 +203,12 @@ float raymarch(float distance,float distance_adv,vec3 from,vec3 direction) {
|
|||
distance -= advance;
|
||||
}
|
||||
|
||||
return occlusion;//max(0.0,distance);
|
||||
|
||||
return occlusion; //max(0.0,distance);
|
||||
}
|
||||
|
||||
bool compute_light_vector(uint light, vec3 pos,out float attenuation, out vec3 light_pos) {
|
||||
bool compute_light_vector(uint light, vec3 pos, out float attenuation, out vec3 light_pos) {
|
||||
|
||||
|
||||
if (lights.data[light].type==LIGHT_TYPE_DIRECTIONAL) {
|
||||
if (lights.data[light].type == LIGHT_TYPE_DIRECTIONAL) {
|
||||
|
||||
light_pos = pos - lights.data[light].direction * length(vec3(params.limits));
|
||||
attenuation = 1.0;
|
||||
|
@ -239,14 +221,12 @@ bool compute_light_vector(uint light, vec3 pos,out float attenuation, out vec3 l
|
|||
return false;
|
||||
}
|
||||
|
||||
attenuation = pow(clamp(1.0 - distance / lights.data[light].radius, 0.0001, 1.0), lights.data[light].attenuation);
|
||||
|
||||
attenuation = pow( clamp( 1.0 - distance / lights.data[light].radius, 0.0001, 1.0), lights.data[light].attenuation );
|
||||
|
||||
|
||||
if (lights.data[light].type==LIGHT_TYPE_SPOT) {
|
||||
if (lights.data[light].type == LIGHT_TYPE_SPOT) {
|
||||
|
||||
vec3 rel = normalize(pos - light_pos);
|
||||
float angle = acos(dot(rel,lights.data[light].direction));
|
||||
float angle = acos(dot(rel, lights.data[light].direction));
|
||||
if (angle > lights.data[light].spot_angle_radians) {
|
||||
return false;
|
||||
}
|
||||
|
@ -279,23 +259,20 @@ float get_normal_advance(vec3 p_normal) {
|
|||
unorm = vec3(1.0, 0.0, 0.0);
|
||||
}
|
||||
|
||||
return 1.0 / dot(normal,unorm);
|
||||
return 1.0 / dot(normal, unorm);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void clip_segment(vec4 plane, vec3 begin, inout vec3 end) {
|
||||
|
||||
vec3 segment = begin - end;
|
||||
float den = dot(plane.xyz,segment);
|
||||
float den = dot(plane.xyz, segment);
|
||||
|
||||
//printf("den is %i\n",den);
|
||||
if (den < 0.0001) {
|
||||
return;
|
||||
}
|
||||
|
||||
float dist = (dot(plane.xyz,begin) - plane.w) / den;
|
||||
float dist = (dot(plane.xyz, begin) - plane.w) / den;
|
||||
|
||||
if (dist < 0.0001 || dist > 1.0001) {
|
||||
return;
|
||||
|
@ -308,13 +285,13 @@ bool compute_light_at_pos(uint index, vec3 pos, vec3 normal, inout vec3 light, i
|
|||
float attenuation;
|
||||
vec3 light_pos;
|
||||
|
||||
if (!compute_light_vector(index,pos,attenuation,light_pos)) {
|
||||
if (!compute_light_vector(index, pos, attenuation, light_pos)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
light_dir = normalize(pos - light_pos);
|
||||
|
||||
if (attenuation < 0.01 || (length(normal) > 0.2 && dot(normal,light_dir)>=0)) {
|
||||
if (attenuation < 0.01 || (length(normal) > 0.2 && dot(normal, light_dir) >= 0)) {
|
||||
return false; //not facing the light, or attenuation is near zero
|
||||
}
|
||||
|
||||
|
@ -322,21 +299,19 @@ bool compute_light_at_pos(uint index, vec3 pos, vec3 normal, inout vec3 light, i
|
|||
|
||||
float distance_adv = get_normal_advance(light_dir);
|
||||
|
||||
|
||||
vec3 to = pos;
|
||||
if (length(normal) > 0.2) {
|
||||
to += normal * distance_adv * 0.51;
|
||||
} else {
|
||||
to -= sign(light_dir)*0.45; //go near the edge towards the light direction to avoid self occlusion
|
||||
to -= sign(light_dir) * 0.45; //go near the edge towards the light direction to avoid self occlusion
|
||||
}
|
||||
|
||||
//clip
|
||||
clip_segment(mix(vec4(-1.0,0.0,0.0,0.0),vec4(1.0,0.0,0.0,float(params.limits.x-1)),bvec4(light_dir.x < 0.0)),to,light_pos);
|
||||
clip_segment(mix(vec4(0.0,-1.0,0.0,0.0),vec4(0.0,1.0,0.0,float(params.limits.y-1)),bvec4(light_dir.y < 0.0)),to,light_pos);
|
||||
clip_segment(mix(vec4(0.0,0.0,-1.0,0.0),vec4(0.0,0.0,1.0,float(params.limits.z-1)),bvec4(light_dir.z < 0.0)),to,light_pos);
|
||||
clip_segment(mix(vec4(-1.0, 0.0, 0.0, 0.0), vec4(1.0, 0.0, 0.0, float(params.limits.x - 1)), bvec4(light_dir.x < 0.0)), to, light_pos);
|
||||
clip_segment(mix(vec4(0.0, -1.0, 0.0, 0.0), vec4(0.0, 1.0, 0.0, float(params.limits.y - 1)), bvec4(light_dir.y < 0.0)), to, light_pos);
|
||||
clip_segment(mix(vec4(0.0, 0.0, -1.0, 0.0), vec4(0.0, 0.0, 1.0, float(params.limits.z - 1)), bvec4(light_dir.z < 0.0)), to, light_pos);
|
||||
|
||||
|
||||
float distance = length(to-light_pos);
|
||||
float distance = length(to - light_pos);
|
||||
if (distance < 0.1) {
|
||||
return false; // hit
|
||||
}
|
||||
|
@ -355,14 +330,13 @@ bool compute_light_at_pos(uint index, vec3 pos, vec3 normal, inout vec3 light, i
|
|||
attenuation *= 1.0 - smoothstep(0.1*distance_adv,distance_adv,dist);
|
||||
*/
|
||||
|
||||
float occlusion = raymarch(distance,distance_adv,light_pos,light_dir);
|
||||
float occlusion = raymarch(distance, distance_adv, light_pos, light_dir);
|
||||
|
||||
if (occlusion==0.0) {
|
||||
if (occlusion == 0.0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
attenuation *= occlusion;//1.0 - smoothstep(0.1*distance_adv,distance_adv,dist);
|
||||
|
||||
attenuation *= occlusion; //1.0 - smoothstep(0.1*distance_adv,distance_adv,dist);
|
||||
}
|
||||
|
||||
light = lights.data[index].color * attenuation * lights.data[index].energy;
|
||||
|
@ -375,91 +349,88 @@ void main() {
|
|||
|
||||
#ifndef MODE_DYNAMIC
|
||||
|
||||
uint cell_index = gl_GlobalInvocationID.x;;
|
||||
uint cell_index = gl_GlobalInvocationID.x;
|
||||
if (cell_index >= params.cell_count) {
|
||||
return;
|
||||
}
|
||||
cell_index += params.cell_offset;
|
||||
|
||||
uvec3 posu = uvec3(cell_data.data[cell_index].position&0x7FF,(cell_data.data[cell_index].position>>11)&0x3FF,cell_data.data[cell_index].position>>21);
|
||||
uvec3 posu = uvec3(cell_data.data[cell_index].position & 0x7FF, (cell_data.data[cell_index].position >> 11) & 0x3FF, cell_data.data[cell_index].position >> 21);
|
||||
vec4 albedo = unpackUnorm4x8(cell_data.data[cell_index].albedo);
|
||||
|
||||
#endif
|
||||
|
||||
/////////////////COMPUTE LIGHT///////////////////////////////
|
||||
/////////////////COMPUTE LIGHT///////////////////////////////
|
||||
|
||||
#ifdef MODE_COMPUTE_LIGHT
|
||||
|
||||
vec3 pos = vec3(posu) + vec3(0.5);
|
||||
|
||||
vec3 emission = vec3(uvec3(cell_data.data[cell_index].emission & 0x1ff,(cell_data.data[cell_index].emission >> 9) & 0x1ff,(cell_data.data[cell_index].emission >> 18) & 0x1ff)) * pow(2.0, float(cell_data.data[cell_index].emission >> 27) - 15.0 - 9.0);
|
||||
vec3 emission = vec3(uvec3(cell_data.data[cell_index].emission & 0x1ff, (cell_data.data[cell_index].emission >> 9) & 0x1ff, (cell_data.data[cell_index].emission >> 18) & 0x1ff)) * pow(2.0, float(cell_data.data[cell_index].emission >> 27) - 15.0 - 9.0);
|
||||
vec3 normal = unpackSnorm4x8(cell_data.data[cell_index].normal).xyz;
|
||||
|
||||
#ifdef MODE_ANISOTROPIC
|
||||
vec3 accum[6]=vec3[](vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));
|
||||
const vec3 accum_dirs[6]=vec3[](vec3(1.0,0.0,0.0),vec3(-1.0,0.0,0.0),vec3(0.0,1.0,0.0),vec3(0.0,-1.0,0.0),vec3(0.0,0.0,1.0),vec3(0.0,0.0,-1.0));
|
||||
vec3 accum[6] = vec3[](vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));
|
||||
const vec3 accum_dirs[6] = vec3[](vec3(1.0, 0.0, 0.0), vec3(-1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0), vec3(0.0, -1.0, 0.0), vec3(0.0, 0.0, 1.0), vec3(0.0, 0.0, -1.0));
|
||||
#else
|
||||
vec3 accum = vec3(0.0);
|
||||
#endif
|
||||
|
||||
for(uint i=0;i<params.light_count;i++) {
|
||||
for (uint i = 0; i < params.light_count; i++) {
|
||||
|
||||
vec3 light;
|
||||
vec3 light_dir;
|
||||
if (!compute_light_at_pos(i,pos,normal.xyz,light,light_dir)) {
|
||||
if (!compute_light_at_pos(i, pos, normal.xyz, light, light_dir)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
light*= albedo.rgb;
|
||||
light *= albedo.rgb;
|
||||
|
||||
#ifdef MODE_ANISOTROPIC
|
||||
for(uint j=0;j<6;j++) {
|
||||
for (uint j = 0; j < 6; j++) {
|
||||
|
||||
accum[j]+=max(0.0,dot(accum_dirs[j],-light_dir))*light;
|
||||
accum[j] += max(0.0, dot(accum_dirs[j], -light_dir)) * light;
|
||||
}
|
||||
#else
|
||||
if (length(normal) > 0.2) {
|
||||
accum+=max(0.0,dot(normal,-light_dir))*light;
|
||||
accum += max(0.0, dot(normal, -light_dir)) * light;
|
||||
} else {
|
||||
//all directions
|
||||
accum+=light;
|
||||
accum += light;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifdef MODE_ANISOTROPIC
|
||||
|
||||
for(uint i=0;i<6;i++) {
|
||||
for (uint i = 0; i < 6; i++) {
|
||||
vec3 light = accum[i];
|
||||
if (length(normal) > 0.2) {
|
||||
light += max(0.0,dot(accum_dirs[i],-normal)) * emission;
|
||||
light += max(0.0, dot(accum_dirs[i], -normal)) * emission;
|
||||
} else {
|
||||
light += emission;
|
||||
}
|
||||
|
||||
outputs.data[cell_index*6+i] = vec4(light,0.0);
|
||||
outputs.data[cell_index * 6 + i] = vec4(light, 0.0);
|
||||
}
|
||||
|
||||
#else
|
||||
outputs.data[cell_index]=vec4(accum + emission,0.0);
|
||||
outputs.data[cell_index] = vec4(accum + emission, 0.0);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif //MODE_COMPUTE_LIGHT
|
||||
|
||||
/////////////////SECOND BOUNCE///////////////////////////////
|
||||
/////////////////SECOND BOUNCE///////////////////////////////
|
||||
|
||||
#ifdef MODE_SECOND_BOUNCE
|
||||
vec3 pos = vec3(posu) + vec3(0.5);
|
||||
ivec3 ipos = ivec3(posu);
|
||||
vec4 normal = unpackSnorm4x8(cell_data.data[cell_index].normal);
|
||||
|
||||
|
||||
#ifdef MODE_ANISOTROPIC
|
||||
vec3 accum[6];
|
||||
const vec3 accum_dirs[6]=vec3[](vec3(1.0,0.0,0.0),vec3(-1.0,0.0,0.0),vec3(0.0,1.0,0.0),vec3(0.0,-1.0,0.0),vec3(0.0,0.0,1.0),vec3(0.0,0.0,-1.0));
|
||||
const vec3 accum_dirs[6] = vec3[](vec3(1.0, 0.0, 0.0), vec3(-1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0), vec3(0.0, -1.0, 0.0), vec3(0.0, 0.0, 1.0), vec3(0.0, 0.0, -1.0));
|
||||
|
||||
/*vec3 src_color = texelFetch(sampler3D(color_texture,texture_sampler),ipos,0).rgb * params.dynamic_range;
|
||||
vec3 src_aniso_pos = texelFetch(sampler3D(aniso_pos_texture,texture_sampler),ipos,0).rgb;
|
||||
|
@ -471,12 +442,12 @@ void main() {
|
|||
accum[4]=src_col * src_aniso_pos.z;
|
||||
accum[5]=src_col * src_aniso_neg.z;*/
|
||||
|
||||
accum[0] = outputs.data[cell_index*6+0].rgb;
|
||||
accum[1] = outputs.data[cell_index*6+1].rgb;
|
||||
accum[2] = outputs.data[cell_index*6+2].rgb;
|
||||
accum[3] = outputs.data[cell_index*6+3].rgb;
|
||||
accum[4] = outputs.data[cell_index*6+4].rgb;
|
||||
accum[5] = outputs.data[cell_index*6+5].rgb;
|
||||
accum[0] = outputs.data[cell_index * 6 + 0].rgb;
|
||||
accum[1] = outputs.data[cell_index * 6 + 1].rgb;
|
||||
accum[2] = outputs.data[cell_index * 6 + 2].rgb;
|
||||
accum[3] = outputs.data[cell_index * 6 + 3].rgb;
|
||||
accum[4] = outputs.data[cell_index * 6 + 4].rgb;
|
||||
accum[5] = outputs.data[cell_index * 6 + 5].rgb;
|
||||
|
||||
#else
|
||||
vec3 accum = outputs.data[cell_index].rgb;
|
||||
|
@ -493,12 +464,12 @@ void main() {
|
|||
#define MAX_CONE_DIRS 6
|
||||
|
||||
vec3 cone_dirs[MAX_CONE_DIRS] = vec3[](
|
||||
vec3(0.0, 0.0, 1.0),
|
||||
vec3(0.866025, 0.0, 0.5),
|
||||
vec3(0.267617, 0.823639, 0.5),
|
||||
vec3(-0.700629, 0.509037, 0.5),
|
||||
vec3(-0.700629, -0.509037, 0.5),
|
||||
vec3(0.267617, -0.823639, 0.5));
|
||||
vec3(0.0, 0.0, 1.0),
|
||||
vec3(0.866025, 0.0, 0.5),
|
||||
vec3(0.267617, 0.823639, 0.5),
|
||||
vec3(-0.700629, 0.509037, 0.5),
|
||||
vec3(-0.700629, -0.509037, 0.5),
|
||||
vec3(0.267617, -0.823639, 0.5));
|
||||
|
||||
float cone_weights[MAX_CONE_DIRS] = float[](0.25, 0.15, 0.15, 0.15, 0.15, 0.15);
|
||||
float tan_half_angle = 0.577;
|
||||
|
@ -514,7 +485,7 @@ void main() {
|
|||
vec3 cell_size = 1.0 / vec3(params.limits);
|
||||
|
||||
#ifdef MODE_ANISOTROPIC
|
||||
vec3 aniso_normal = mix(direction,normal.xyz,params.aniso_strength);
|
||||
vec3 aniso_normal = mix(direction, normal.xyz, params.aniso_strength);
|
||||
#endif
|
||||
while (dist < max_distance && color.a < 0.95) {
|
||||
float diameter = max(1.0, 2.0 * tan_half_angle * dist);
|
||||
|
@ -526,148 +497,141 @@ void main() {
|
|||
//}
|
||||
|
||||
float log2_diameter = log2(diameter);
|
||||
vec4 scolor = textureLod(sampler3D(color_texture,texture_sampler), uvw_pos, log2_diameter);
|
||||
vec4 scolor = textureLod(sampler3D(color_texture, texture_sampler), uvw_pos, log2_diameter);
|
||||
#ifdef MODE_ANISOTROPIC
|
||||
|
||||
vec3 aniso_neg = textureLod(sampler3D(aniso_neg_texture,texture_sampler), uvw_pos, log2_diameter).rgb;
|
||||
vec3 aniso_pos = textureLod(sampler3D(aniso_pos_texture,texture_sampler), uvw_pos, log2_diameter).rgb;
|
||||
vec3 aniso_neg = textureLod(sampler3D(aniso_neg_texture, texture_sampler), uvw_pos, log2_diameter).rgb;
|
||||
vec3 aniso_pos = textureLod(sampler3D(aniso_pos_texture, texture_sampler), uvw_pos, log2_diameter).rgb;
|
||||
|
||||
scolor.rgb*=dot(max(vec3(0.0),(aniso_normal * aniso_pos)),vec3(1.0)) + dot(max(vec3(0.0),(-aniso_normal * aniso_neg)),vec3(1.0));
|
||||
scolor.rgb *= dot(max(vec3(0.0), (aniso_normal * aniso_pos)), vec3(1.0)) + dot(max(vec3(0.0), (-aniso_normal * aniso_neg)), vec3(1.0));
|
||||
#endif
|
||||
float a = (1.0 - color.a);
|
||||
color += a * scolor;
|
||||
dist += half_diameter;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
color *= cone_weights[i] * vec4(albedo.rgb,1.0) * params.dynamic_range; //restore range
|
||||
color *= cone_weights[i] * vec4(albedo.rgb, 1.0) * params.dynamic_range; //restore range
|
||||
#ifdef MODE_ANISOTROPIC
|
||||
for(uint j=0;j<6;j++) {
|
||||
for (uint j = 0; j < 6; j++) {
|
||||
|
||||
accum[j]+=max(0.0,dot(accum_dirs[j],direction))*color.rgb;
|
||||
accum[j] += max(0.0, dot(accum_dirs[j], direction)) * color.rgb;
|
||||
}
|
||||
#else
|
||||
accum+=color.rgb;
|
||||
accum += color.rgb;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MODE_ANISOTROPIC
|
||||
|
||||
outputs.data[cell_index*6+0]=vec4(accum[0],0.0);
|
||||
outputs.data[cell_index*6+1]=vec4(accum[1],0.0);
|
||||
outputs.data[cell_index*6+2]=vec4(accum[2],0.0);
|
||||
outputs.data[cell_index*6+3]=vec4(accum[3],0.0);
|
||||
outputs.data[cell_index*6+4]=vec4(accum[4],0.0);
|
||||
outputs.data[cell_index*6+5]=vec4(accum[5],0.0);
|
||||
outputs.data[cell_index * 6 + 0] = vec4(accum[0], 0.0);
|
||||
outputs.data[cell_index * 6 + 1] = vec4(accum[1], 0.0);
|
||||
outputs.data[cell_index * 6 + 2] = vec4(accum[2], 0.0);
|
||||
outputs.data[cell_index * 6 + 3] = vec4(accum[3], 0.0);
|
||||
outputs.data[cell_index * 6 + 4] = vec4(accum[4], 0.0);
|
||||
outputs.data[cell_index * 6 + 5] = vec4(accum[5], 0.0);
|
||||
#else
|
||||
outputs.data[cell_index]=vec4(accum,0.0);
|
||||
outputs.data[cell_index] = vec4(accum, 0.0);
|
||||
|
||||
#endif
|
||||
|
||||
#endif // MODE_SECOND_BOUNCE
|
||||
/////////////////UPDATE MIPMAPS///////////////////////////////
|
||||
|
||||
/////////////////UPDATE MIPMAPS///////////////////////////////
|
||||
|
||||
#ifdef MODE_UPDATE_MIPMAPS
|
||||
|
||||
{
|
||||
#ifdef MODE_ANISOTROPIC
|
||||
vec3 light_accum[6] = vec3[](vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));
|
||||
vec3 light_accum[6] = vec3[](vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));
|
||||
#else
|
||||
vec3 light_accum = vec3(0.0);
|
||||
#endif
|
||||
float count = 0.0;
|
||||
for(uint i=0;i<8;i++) {
|
||||
for (uint i = 0; i < 8; i++) {
|
||||
uint child_index = cell_children.data[cell_index].children[i];
|
||||
if (child_index==NO_CHILDREN) {
|
||||
if (child_index == NO_CHILDREN) {
|
||||
continue;
|
||||
}
|
||||
#ifdef MODE_ANISOTROPIC
|
||||
light_accum[0] += outputs.data[child_index*6+0].rgb;
|
||||
light_accum[1] += outputs.data[child_index*6+1].rgb;
|
||||
light_accum[2] += outputs.data[child_index*6+2].rgb;
|
||||
light_accum[3] += outputs.data[child_index*6+3].rgb;
|
||||
light_accum[4] += outputs.data[child_index*6+4].rgb;
|
||||
light_accum[5] += outputs.data[child_index*6+5].rgb;
|
||||
light_accum[0] += outputs.data[child_index * 6 + 0].rgb;
|
||||
light_accum[1] += outputs.data[child_index * 6 + 1].rgb;
|
||||
light_accum[2] += outputs.data[child_index * 6 + 2].rgb;
|
||||
light_accum[3] += outputs.data[child_index * 6 + 3].rgb;
|
||||
light_accum[4] += outputs.data[child_index * 6 + 4].rgb;
|
||||
light_accum[5] += outputs.data[child_index * 6 + 5].rgb;
|
||||
|
||||
#else
|
||||
light_accum += outputs.data[child_index].rgb;
|
||||
|
||||
#endif
|
||||
|
||||
count+=1.0;
|
||||
count += 1.0;
|
||||
}
|
||||
|
||||
float divisor = mix(8.0,count,params.propagation);
|
||||
float divisor = mix(8.0, count, params.propagation);
|
||||
#ifdef MODE_ANISOTROPIC
|
||||
outputs.data[cell_index*6+0]=vec4(light_accum[0] / divisor,0.0);
|
||||
outputs.data[cell_index*6+1]=vec4(light_accum[1] / divisor,0.0);
|
||||
outputs.data[cell_index*6+2]=vec4(light_accum[2] / divisor,0.0);
|
||||
outputs.data[cell_index*6+3]=vec4(light_accum[3] / divisor,0.0);
|
||||
outputs.data[cell_index*6+4]=vec4(light_accum[4] / divisor,0.0);
|
||||
outputs.data[cell_index*6+5]=vec4(light_accum[5] / divisor,0.0);
|
||||
outputs.data[cell_index * 6 + 0] = vec4(light_accum[0] / divisor, 0.0);
|
||||
outputs.data[cell_index * 6 + 1] = vec4(light_accum[1] / divisor, 0.0);
|
||||
outputs.data[cell_index * 6 + 2] = vec4(light_accum[2] / divisor, 0.0);
|
||||
outputs.data[cell_index * 6 + 3] = vec4(light_accum[3] / divisor, 0.0);
|
||||
outputs.data[cell_index * 6 + 4] = vec4(light_accum[4] / divisor, 0.0);
|
||||
outputs.data[cell_index * 6 + 5] = vec4(light_accum[5] / divisor, 0.0);
|
||||
|
||||
#else
|
||||
outputs.data[cell_index]=vec4(light_accum / divisor,0.0);
|
||||
outputs.data[cell_index] = vec4(light_accum / divisor, 0.0);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
///////////////////WRITE TEXTURE/////////////////////////////
|
||||
///////////////////WRITE TEXTURE/////////////////////////////
|
||||
|
||||
#ifdef MODE_WRITE_TEXTURE
|
||||
{
|
||||
|
||||
#ifdef MODE_ANISOTROPIC
|
||||
vec3 accum_total = vec3(0.0);
|
||||
accum_total += outputs.data[cell_index*6+0].rgb;
|
||||
accum_total += outputs.data[cell_index*6+1].rgb;
|
||||
accum_total += outputs.data[cell_index*6+2].rgb;
|
||||
accum_total += outputs.data[cell_index*6+3].rgb;
|
||||
accum_total += outputs.data[cell_index*6+4].rgb;
|
||||
accum_total += outputs.data[cell_index*6+5].rgb;
|
||||
|
||||
float accum_total_energy = max(dot(accum_total,GREY_VEC),0.00001);
|
||||
vec3 iso_positive = vec3(dot(outputs.data[cell_index*6+0].rgb,GREY_VEC),dot(outputs.data[cell_index*6+2].rgb,GREY_VEC),dot(outputs.data[cell_index*6+4].rgb,GREY_VEC))/vec3(accum_total_energy);
|
||||
vec3 iso_negative = vec3(dot(outputs.data[cell_index*6+1].rgb,GREY_VEC),dot(outputs.data[cell_index*6+3].rgb,GREY_VEC),dot(outputs.data[cell_index*6+5].rgb,GREY_VEC))/vec3(accum_total_energy);
|
||||
accum_total += outputs.data[cell_index * 6 + 0].rgb;
|
||||
accum_total += outputs.data[cell_index * 6 + 1].rgb;
|
||||
accum_total += outputs.data[cell_index * 6 + 2].rgb;
|
||||
accum_total += outputs.data[cell_index * 6 + 3].rgb;
|
||||
accum_total += outputs.data[cell_index * 6 + 4].rgb;
|
||||
accum_total += outputs.data[cell_index * 6 + 5].rgb;
|
||||
|
||||
float accum_total_energy = max(dot(accum_total, GREY_VEC), 0.00001);
|
||||
vec3 iso_positive = vec3(dot(outputs.data[cell_index * 6 + 0].rgb, GREY_VEC), dot(outputs.data[cell_index * 6 + 2].rgb, GREY_VEC), dot(outputs.data[cell_index * 6 + 4].rgb, GREY_VEC)) / vec3(accum_total_energy);
|
||||
vec3 iso_negative = vec3(dot(outputs.data[cell_index * 6 + 1].rgb, GREY_VEC), dot(outputs.data[cell_index * 6 + 3].rgb, GREY_VEC), dot(outputs.data[cell_index * 6 + 5].rgb, GREY_VEC)) / vec3(accum_total_energy);
|
||||
|
||||
{
|
||||
uint aniso_pos = uint(clamp(iso_positive.b * 31.0,0.0,31.0));
|
||||
aniso_pos |= uint(clamp(iso_positive.g * 63.0,0.0,63.0))<<5;
|
||||
aniso_pos |= uint(clamp(iso_positive.r * 31.0,0.0,31.0))<<11;
|
||||
imageStore(aniso_pos_tex,ivec3(posu),uvec4(aniso_pos));
|
||||
uint aniso_pos = uint(clamp(iso_positive.b * 31.0, 0.0, 31.0));
|
||||
aniso_pos |= uint(clamp(iso_positive.g * 63.0, 0.0, 63.0)) << 5;
|
||||
aniso_pos |= uint(clamp(iso_positive.r * 31.0, 0.0, 31.0)) << 11;
|
||||
imageStore(aniso_pos_tex, ivec3(posu), uvec4(aniso_pos));
|
||||
}
|
||||
|
||||
{
|
||||
uint aniso_neg = uint(clamp(iso_negative.b * 31.0,0.0,31.0));
|
||||
aniso_neg |= uint(clamp(iso_negative.g * 63.0,0.0,63.0))<<5;
|
||||
aniso_neg |= uint(clamp(iso_negative.r * 31.0,0.0,31.0))<<11;
|
||||
imageStore(aniso_neg_tex,ivec3(posu),uvec4(aniso_neg));
|
||||
uint aniso_neg = uint(clamp(iso_negative.b * 31.0, 0.0, 31.0));
|
||||
aniso_neg |= uint(clamp(iso_negative.g * 63.0, 0.0, 63.0)) << 5;
|
||||
aniso_neg |= uint(clamp(iso_negative.r * 31.0, 0.0, 31.0)) << 11;
|
||||
imageStore(aniso_neg_tex, ivec3(posu), uvec4(aniso_neg));
|
||||
}
|
||||
|
||||
imageStore(color_tex,ivec3(posu),vec4(accum_total / params.dynamic_range ,albedo.a));
|
||||
imageStore(color_tex, ivec3(posu), vec4(accum_total / params.dynamic_range, albedo.a));
|
||||
|
||||
#else
|
||||
|
||||
imageStore(color_tex,ivec3(posu),vec4(outputs.data[cell_index].rgb / params.dynamic_range,albedo.a));
|
||||
imageStore(color_tex, ivec3(posu), vec4(outputs.data[cell_index].rgb / params.dynamic_range, albedo.a));
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
///////////////////DYNAMIC LIGHTING/////////////////////////////
|
||||
///////////////////DYNAMIC LIGHTING/////////////////////////////
|
||||
|
||||
#ifdef MODE_DYNAMIC
|
||||
|
||||
ivec2 pos_xy = ivec2(gl_GlobalInvocationID.xy);
|
||||
if (any(greaterThanEqual(pos_xy,params.rect_size))) {
|
||||
if (any(greaterThanEqual(pos_xy, params.rect_size))) {
|
||||
return; //out of bounds
|
||||
}
|
||||
|
||||
|
@ -679,47 +643,38 @@ void main() {
|
|||
uv_xy.y = params.rect_size.y - pos_xy.y - 1;
|
||||
}
|
||||
|
||||
|
||||
#ifdef MODE_DYNAMIC_LIGHTING
|
||||
|
||||
|
||||
{
|
||||
float z = params.z_base + imageLoad(depth, uv_xy).x * params.z_sign;
|
||||
|
||||
ivec3 pos = params.x_dir * (params.rect_pos.x + pos_xy.x) + params.y_dir * (params.rect_pos.y + pos_xy.y) + abs(params.z_dir) * int(z);
|
||||
|
||||
float z = params.z_base + imageLoad(depth,uv_xy).x * params.z_sign;
|
||||
vec3 normal = imageLoad(source_normal, uv_xy).xyz * 2.0 - 1.0;
|
||||
normal = vec3(params.x_dir) * normal.x * mix(1.0, -1.0, params.flip_x) + vec3(params.y_dir) * normal.y * mix(1.0, -1.0, params.flip_y) - vec3(params.z_dir) * normal.z;
|
||||
|
||||
ivec3 pos = params.x_dir * (params.rect_pos.x + pos_xy.x) + params.y_dir * (params.rect_pos.y + pos_xy.y) + abs(params.z_dir) * int(z);
|
||||
|
||||
vec3 normal = imageLoad(source_normal,uv_xy).xyz * 2.0 - 1.0;
|
||||
normal = vec3(params.x_dir) * normal.x * mix(1.0,-1.0,params.flip_x) + vec3(params.y_dir) * normal.y * mix(1.0,-1.0,params.flip_y) - vec3(params.z_dir) * normal.z;
|
||||
|
||||
|
||||
|
||||
|
||||
vec4 albedo = imageLoad(source_albedo,uv_xy);
|
||||
vec4 albedo = imageLoad(source_albedo, uv_xy);
|
||||
|
||||
//determine the position in space
|
||||
|
||||
vec3 accum = vec3(0.0);
|
||||
for(uint i=0;i<params.light_count;i++) {
|
||||
for (uint i = 0; i < params.light_count; i++) {
|
||||
|
||||
vec3 light;
|
||||
vec3 light_dir;
|
||||
if (!compute_light_at_pos(i,vec3(pos) * params.pos_multiplier,normal,light,light_dir)) {
|
||||
if (!compute_light_at_pos(i, vec3(pos) * params.pos_multiplier, normal, light, light_dir)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
light*= albedo.rgb;
|
||||
|
||||
accum+=max(0.0,dot(normal,-light_dir))*light;
|
||||
light *= albedo.rgb;
|
||||
|
||||
accum += max(0.0, dot(normal, -light_dir)) * light;
|
||||
}
|
||||
|
||||
accum+=imageLoad(emission,uv_xy).xyz;
|
||||
|
||||
imageStore(emission,uv_xy,vec4(accum,albedo.a));
|
||||
imageStore(depth,uv_xy,vec4(z));
|
||||
accum += imageLoad(emission, uv_xy).xyz;
|
||||
|
||||
imageStore(emission, uv_xy, vec4(accum, albedo.a));
|
||||
imageStore(depth, uv_xy, vec4(z));
|
||||
}
|
||||
|
||||
#endif // MODE DYNAMIC LIGHTING
|
||||
|
@ -731,9 +686,9 @@ void main() {
|
|||
float accum_z = 0.0;
|
||||
float count = 0.0;
|
||||
|
||||
for(int i=0;i<4;i++) {
|
||||
ivec2 ofs = pos_xy*2 + ivec2(i&1,i>>1) - params.prev_rect_ofs;
|
||||
if (any(lessThan(ofs,ivec2(0))) || any(greaterThanEqual(ofs,params.prev_rect_size))) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
ivec2 ofs = pos_xy * 2 + ivec2(i & 1, i >> 1) - params.prev_rect_ofs;
|
||||
if (any(lessThan(ofs, ivec2(0))) || any(greaterThanEqual(ofs, params.prev_rect_size))) {
|
||||
continue;
|
||||
}
|
||||
if (params.flip_x) {
|
||||
|
@ -743,67 +698,64 @@ void main() {
|
|||
ofs.y = params.prev_rect_size.y - ofs.y - 1;
|
||||
}
|
||||
|
||||
vec4 light = imageLoad(source_light,ofs);
|
||||
if (light.a==0.0) { //ignore empty
|
||||
vec4 light = imageLoad(source_light, ofs);
|
||||
if (light.a == 0.0) { //ignore empty
|
||||
continue;
|
||||
}
|
||||
accum += light;
|
||||
float z = imageLoad(source_depth,ofs).x;
|
||||
accum_z += z*0.5; //shrink half too
|
||||
count+=1.0;
|
||||
float z = imageLoad(source_depth, ofs).x;
|
||||
accum_z += z * 0.5; //shrink half too
|
||||
count += 1.0;
|
||||
}
|
||||
|
||||
|
||||
if (params.on_mipmap) {
|
||||
accum.rgb /= mix(8.0,count,params.propagation);
|
||||
accum.rgb /= mix(8.0, count, params.propagation);
|
||||
accum.a /= 8.0;
|
||||
} else {
|
||||
accum/=4.0;
|
||||
accum /= 4.0;
|
||||
}
|
||||
|
||||
if (count==0.0) {
|
||||
accum_z=0.0; //avoid nan
|
||||
if (count == 0.0) {
|
||||
accum_z = 0.0; //avoid nan
|
||||
} else {
|
||||
accum_z/=count;
|
||||
accum_z /= count;
|
||||
}
|
||||
|
||||
#ifdef MODE_DYNAMIC_SHRINK_WRITE
|
||||
|
||||
imageStore(light,uv_xy,accum);
|
||||
imageStore(depth,uv_xy,vec4(accum_z));
|
||||
imageStore(light, uv_xy, accum);
|
||||
imageStore(depth, uv_xy, vec4(accum_z));
|
||||
#endif
|
||||
|
||||
#ifdef MODE_DYNAMIC_SHRINK_PLOT
|
||||
|
||||
|
||||
if (accum.a<0.001) {
|
||||
if (accum.a < 0.001) {
|
||||
return; //do not blit if alpha is too low
|
||||
}
|
||||
|
||||
ivec3 pos = params.x_dir * (params.rect_pos.x + pos_xy.x) + params.y_dir * (params.rect_pos.y + pos_xy.y) + abs(params.z_dir) * int(accum_z);
|
||||
ivec3 pos = params.x_dir * (params.rect_pos.x + pos_xy.x) + params.y_dir * (params.rect_pos.y + pos_xy.y) + abs(params.z_dir) * int(accum_z);
|
||||
|
||||
float z_frac = fract(accum_z);
|
||||
|
||||
for(int i = 0; i< 2; i++) {
|
||||
for (int i = 0; i < 2; i++) {
|
||||
ivec3 pos3d = pos + abs(params.z_dir) * i;
|
||||
if (any(lessThan(pos3d,ivec3(0))) || any(greaterThanEqual(pos3d,params.limits))) {
|
||||
if (any(lessThan(pos3d, ivec3(0))) || any(greaterThanEqual(pos3d, params.limits))) {
|
||||
//skip if offlimits
|
||||
continue;
|
||||
}
|
||||
vec4 color_blit = accum * (i==0 ? 1.0 - z_frac : z_frac );
|
||||
vec4 color = imageLoad(color_texture,pos3d);
|
||||
color.rgb *=params.dynamic_range;
|
||||
vec4 color_blit = accum * (i == 0 ? 1.0 - z_frac : z_frac);
|
||||
vec4 color = imageLoad(color_texture, pos3d);
|
||||
color.rgb *= params.dynamic_range;
|
||||
|
||||
#if 0
|
||||
color.rgb = mix(color.rgb,color_blit.rgb,color_blit.a);
|
||||
color.a+=color_blit.a;
|
||||
#else
|
||||
|
||||
|
||||
float sa = 1.0 - color_blit.a;
|
||||
vec4 result;
|
||||
result.a = color.a * sa + color_blit.a;
|
||||
if (result.a==0.0) {
|
||||
if (result.a == 0.0) {
|
||||
result = vec4(0.0);
|
||||
} else {
|
||||
result.rgb = (color.rgb * color.a * sa + color_blit.rgb * color_blit.a) / result.a;
|
||||
|
@ -812,19 +764,17 @@ void main() {
|
|||
|
||||
#endif
|
||||
color.rgb /= params.dynamic_range;
|
||||
imageStore(color_texture,pos3d,color);
|
||||
imageStore(color_texture, pos3d, color);
|
||||
//imageStore(color_texture,pos3d,vec4(1,1,1,1));
|
||||
|
||||
#ifdef MODE_ANISOTROPIC
|
||||
//do not care about anisotropy for dynamic objects, just store full lit in all directions
|
||||
imageStore(aniso_pos_texture,pos3d,uvec4(0xFFFF));
|
||||
imageStore(aniso_neg_texture,pos3d,uvec4(0xFFFF));
|
||||
imageStore(aniso_pos_texture, pos3d, uvec4(0xFFFF));
|
||||
imageStore(aniso_neg_texture, pos3d, uvec4(0xFFFF));
|
||||
|
||||
#endif // ANISOTROPIC
|
||||
}
|
||||
#endif // MODE_DYNAMIC_SHRINK_PLOT
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* clang-format off */
|
||||
[vertex]
|
||||
|
||||
#version 450
|
||||
|
@ -10,21 +11,21 @@ struct CellData {
|
|||
uint emission; //rgb normalized with e as multiplier
|
||||
uint normal; //RGB normal encoded
|
||||
};
|
||||
/* clang-format on */
|
||||
|
||||
layout(set=0,binding=1,std140) buffer CellDataBuffer {
|
||||
CellData data[];
|
||||
layout(set = 0, binding = 1, std140) buffer CellDataBuffer {
|
||||
CellData data[];
|
||||
} cell_data;
|
||||
|
||||
layout (set=0,binding=2) uniform texture3D color_tex;
|
||||
layout(set = 0, binding = 2) uniform texture3D color_tex;
|
||||
|
||||
layout (set=0,binding=3) uniform sampler tex_sampler;
|
||||
layout(set = 0, binding = 3) uniform sampler tex_sampler;
|
||||
|
||||
#ifdef USE_ANISOTROPY
|
||||
layout (set=0,binding=4) uniform texture3D aniso_pos_tex;
|
||||
layout (set=0,binding=5) uniform texture3D aniso_neg_tex;
|
||||
layout(set = 0, binding = 4) uniform texture3D aniso_pos_tex;
|
||||
layout(set = 0, binding = 5) uniform texture3D aniso_neg_tex;
|
||||
#endif
|
||||
|
||||
|
||||
layout(push_constant, binding = 0, std430) uniform Params {
|
||||
|
||||
mat4 projection;
|
||||
|
@ -34,64 +35,61 @@ layout(push_constant, binding = 0, std430) uniform Params {
|
|||
uint level;
|
||||
ivec3 bounds;
|
||||
uint pad;
|
||||
|
||||
} params;
|
||||
|
||||
layout(location=0) out vec4 color_interp;
|
||||
layout(location = 0) out vec4 color_interp;
|
||||
|
||||
void main() {
|
||||
|
||||
const vec3 cube_triangles[36] = vec3[](
|
||||
vec3(-1.0f,-1.0f,-1.0f),
|
||||
vec3(-1.0f,-1.0f, 1.0f),
|
||||
vec3(-1.0f, 1.0f, 1.0f),
|
||||
vec3(1.0f, 1.0f,-1.0f),
|
||||
vec3(-1.0f,-1.0f,-1.0f),
|
||||
vec3(-1.0f, 1.0f,-1.0f),
|
||||
vec3(1.0f,-1.0f, 1.0f),
|
||||
vec3(-1.0f,-1.0f,-1.0f),
|
||||
vec3(1.0f,-1.0f,-1.0f),
|
||||
vec3(1.0f, 1.0f,-1.0f),
|
||||
vec3(1.0f,-1.0f,-1.0f),
|
||||
vec3(-1.0f,-1.0f,-1.0f),
|
||||
vec3(-1.0f,-1.0f,-1.0f),
|
||||
vec3(-1.0f, 1.0f, 1.0f),
|
||||
vec3(-1.0f, 1.0f,-1.0f),
|
||||
vec3(1.0f,-1.0f, 1.0f),
|
||||
vec3(-1.0f,-1.0f, 1.0f),
|
||||
vec3(-1.0f,-1.0f,-1.0f),
|
||||
vec3(-1.0f, 1.0f, 1.0f),
|
||||
vec3(-1.0f,-1.0f, 1.0f),
|
||||
vec3(1.0f,-1.0f, 1.0f),
|
||||
vec3(1.0f, 1.0f, 1.0f),
|
||||
vec3(1.0f,-1.0f,-1.0f),
|
||||
vec3(1.0f, 1.0f,-1.0f),
|
||||
vec3(1.0f,-1.0f,-1.0f),
|
||||
vec3(1.0f, 1.0f, 1.0f),
|
||||
vec3(1.0f,-1.0f, 1.0f),
|
||||
vec3(1.0f, 1.0f, 1.0f),
|
||||
vec3(1.0f, 1.0f,-1.0f),
|
||||
vec3(-1.0f, 1.0f,-1.0f),
|
||||
vec3(1.0f, 1.0f, 1.0f),
|
||||
vec3(-1.0f, 1.0f,-1.0f),
|
||||
vec3(-1.0f, 1.0f, 1.0f),
|
||||
vec3(1.0f, 1.0f, 1.0f),
|
||||
vec3(-1.0f, 1.0f, 1.0f),
|
||||
vec3(1.0f,-1.0f, 1.0f)
|
||||
);
|
||||
|
||||
vec3(-1.0f, -1.0f, -1.0f),
|
||||
vec3(-1.0f, -1.0f, 1.0f),
|
||||
vec3(-1.0f, 1.0f, 1.0f),
|
||||
vec3(1.0f, 1.0f, -1.0f),
|
||||
vec3(-1.0f, -1.0f, -1.0f),
|
||||
vec3(-1.0f, 1.0f, -1.0f),
|
||||
vec3(1.0f, -1.0f, 1.0f),
|
||||
vec3(-1.0f, -1.0f, -1.0f),
|
||||
vec3(1.0f, -1.0f, -1.0f),
|
||||
vec3(1.0f, 1.0f, -1.0f),
|
||||
vec3(1.0f, -1.0f, -1.0f),
|
||||
vec3(-1.0f, -1.0f, -1.0f),
|
||||
vec3(-1.0f, -1.0f, -1.0f),
|
||||
vec3(-1.0f, 1.0f, 1.0f),
|
||||
vec3(-1.0f, 1.0f, -1.0f),
|
||||
vec3(1.0f, -1.0f, 1.0f),
|
||||
vec3(-1.0f, -1.0f, 1.0f),
|
||||
vec3(-1.0f, -1.0f, -1.0f),
|
||||
vec3(-1.0f, 1.0f, 1.0f),
|
||||
vec3(-1.0f, -1.0f, 1.0f),
|
||||
vec3(1.0f, -1.0f, 1.0f),
|
||||
vec3(1.0f, 1.0f, 1.0f),
|
||||
vec3(1.0f, -1.0f, -1.0f),
|
||||
vec3(1.0f, 1.0f, -1.0f),
|
||||
vec3(1.0f, -1.0f, -1.0f),
|
||||
vec3(1.0f, 1.0f, 1.0f),
|
||||
vec3(1.0f, -1.0f, 1.0f),
|
||||
vec3(1.0f, 1.0f, 1.0f),
|
||||
vec3(1.0f, 1.0f, -1.0f),
|
||||
vec3(-1.0f, 1.0f, -1.0f),
|
||||
vec3(1.0f, 1.0f, 1.0f),
|
||||
vec3(-1.0f, 1.0f, -1.0f),
|
||||
vec3(-1.0f, 1.0f, 1.0f),
|
||||
vec3(1.0f, 1.0f, 1.0f),
|
||||
vec3(-1.0f, 1.0f, 1.0f),
|
||||
vec3(1.0f, -1.0f, 1.0f));
|
||||
|
||||
vec3 vertex = cube_triangles[gl_VertexIndex] * 0.5 + 0.5;
|
||||
#ifdef MODE_DEBUG_LIGHT_FULL
|
||||
uvec3 posu = uvec3( gl_InstanceIndex % params.bounds.x, (gl_InstanceIndex / params.bounds.x) % params.bounds.y,gl_InstanceIndex / (params.bounds.y * params.bounds.x) );
|
||||
uvec3 posu = uvec3(gl_InstanceIndex % params.bounds.x, (gl_InstanceIndex / params.bounds.x) % params.bounds.y, gl_InstanceIndex / (params.bounds.y * params.bounds.x));
|
||||
#else
|
||||
uint cell_index = gl_InstanceIndex + params.cell_offset;
|
||||
|
||||
uvec3 posu = uvec3(cell_data.data[cell_index].position&0x7FF,(cell_data.data[cell_index].position>>11)&0x3FF,cell_data.data[cell_index].position>>21);
|
||||
uvec3 posu = uvec3(cell_data.data[cell_index].position & 0x7FF, (cell_data.data[cell_index].position >> 11) & 0x3FF, cell_data.data[cell_index].position >> 21);
|
||||
#endif
|
||||
|
||||
#ifdef MODE_DEBUG_EMISSION
|
||||
color_interp.xyz = vec3(uvec3(cell_data.data[cell_index].emission & 0x1ff,(cell_data.data[cell_index].emission >> 9) & 0x1ff,(cell_data.data[cell_index].emission >> 18) & 0x1ff)) * pow(2.0, float(cell_data.data[cell_index].emission >> 27) - 15.0 - 9.0);
|
||||
color_interp.xyz = vec3(uvec3(cell_data.data[cell_index].emission & 0x1ff, (cell_data.data[cell_index].emission >> 9) & 0x1ff, (cell_data.data[cell_index].emission >> 18) & 0x1ff)) * pow(2.0, float(cell_data.data[cell_index].emission >> 27) - 15.0 - 9.0);
|
||||
#endif
|
||||
|
||||
#ifdef MODE_DEBUG_COLOR
|
||||
|
@ -121,37 +119,35 @@ void main() {
|
|||
POS_X,
|
||||
POS_Y,
|
||||
POS_Y,
|
||||
POS_Z
|
||||
);
|
||||
POS_Z);
|
||||
|
||||
color_interp.xyz = texelFetch(sampler3D(color_tex,tex_sampler),ivec3(posu),int(params.level)).xyz * params.dynamic_range;
|
||||
vec3 aniso_pos = texelFetch(sampler3D(aniso_pos_tex,tex_sampler),ivec3(posu),int(params.level)).xyz;
|
||||
vec3 aniso_neg = texelFetch(sampler3D(aniso_neg_tex,tex_sampler),ivec3(posu),int(params.level)).xyz;
|
||||
uint side = triangle_aniso[gl_VertexIndex/3];
|
||||
color_interp.xyz = texelFetch(sampler3D(color_tex, tex_sampler), ivec3(posu), int(params.level)).xyz * params.dynamic_range;
|
||||
vec3 aniso_pos = texelFetch(sampler3D(aniso_pos_tex, tex_sampler), ivec3(posu), int(params.level)).xyz;
|
||||
vec3 aniso_neg = texelFetch(sampler3D(aniso_neg_tex, tex_sampler), ivec3(posu), int(params.level)).xyz;
|
||||
uint side = triangle_aniso[gl_VertexIndex / 3];
|
||||
|
||||
float strength = 0.0;
|
||||
switch(side) {
|
||||
case POS_X: strength = aniso_pos.x; break;
|
||||
case POS_Y: strength = aniso_pos.y; break;
|
||||
case POS_Z: strength = aniso_pos.z; break;
|
||||
case NEG_X: strength = aniso_neg.x; break;
|
||||
case NEG_Y: strength = aniso_neg.y; break;
|
||||
case NEG_Z: strength = aniso_neg.z; break;
|
||||
|
||||
switch (side) {
|
||||
case POS_X: strength = aniso_pos.x; break;
|
||||
case POS_Y: strength = aniso_pos.y; break;
|
||||
case POS_Z: strength = aniso_pos.z; break;
|
||||
case NEG_X: strength = aniso_neg.x; break;
|
||||
case NEG_Y: strength = aniso_neg.y; break;
|
||||
case NEG_Z: strength = aniso_neg.z; break;
|
||||
}
|
||||
|
||||
color_interp.xyz *= strength;
|
||||
|
||||
#else
|
||||
color_interp = texelFetch(sampler3D(color_tex,tex_sampler),ivec3(posu),int(params.level));
|
||||
color_interp.xyz * params.dynamic_range;
|
||||
color_interp = texelFetch(sampler3D(color_tex, tex_sampler), ivec3(posu), int(params.level));
|
||||
color_interp.xyz *params.dynamic_range;
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
float scale = (1<<params.level);
|
||||
float scale = (1 << params.level);
|
||||
|
||||
gl_Position = params.projection * vec4((vec3(posu)+vertex)*scale,1.0);
|
||||
gl_Position = params.projection * vec4((vec3(posu) + vertex) * scale, 1.0);
|
||||
|
||||
#ifdef MODE_DEBUG_LIGHT_FULL
|
||||
if (color_interp.a == 0.0) {
|
||||
|
@ -160,17 +156,18 @@ void main() {
|
|||
#else
|
||||
color_interp.a = params.alpha;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/* clang-format off */
|
||||
[fragment]
|
||||
|
||||
#version 450
|
||||
|
||||
VERSION_DEFINES
|
||||
|
||||
layout(location=0) in vec4 color_interp;
|
||||
layout(location=0) out vec4 frag_color;
|
||||
layout(location = 0) in vec4 color_interp;
|
||||
/* clang-format on */
|
||||
layout(location = 0) out vec4 frag_color;
|
||||
|
||||
void main() {
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* clang-format off */
|
||||
[compute]
|
||||
|
||||
#version 450
|
||||
|
@ -5,21 +6,21 @@
|
|||
VERSION_DEFINES
|
||||
|
||||
layout(local_size_x = 4, local_size_y = 4, local_size_z = 4) in;
|
||||
/* clang-format on */
|
||||
|
||||
#define MAX_DISTANCE 100000
|
||||
|
||||
#define NO_CHILDREN 0xFFFFFFFF
|
||||
#define GREY_VEC vec3(0.33333,0.33333,0.33333)
|
||||
#define GREY_VEC vec3(0.33333, 0.33333, 0.33333)
|
||||
|
||||
struct CellChildren {
|
||||
uint children[8];
|
||||
};
|
||||
|
||||
layout(set=0,binding=1,std430) buffer CellChildrenBuffer {
|
||||
CellChildren data[];
|
||||
layout(set = 0, binding = 1, std430) buffer CellChildrenBuffer {
|
||||
CellChildren data[];
|
||||
} cell_children;
|
||||
|
||||
|
||||
struct CellData {
|
||||
uint position; // xyz 10 bits
|
||||
uint albedo; //rgb albedo
|
||||
|
@ -27,15 +28,13 @@ struct CellData {
|
|||
uint normal; //RGB normal encoded
|
||||
};
|
||||
|
||||
layout(set=0,binding=2,std430) buffer CellDataBuffer {
|
||||
CellData data[];
|
||||
layout(set = 0, binding = 2, std430) buffer CellDataBuffer {
|
||||
CellData data[];
|
||||
} cell_data;
|
||||
|
||||
layout (r8ui,set=0,binding=3) uniform restrict writeonly uimage3D sdf_tex;
|
||||
|
||||
layout(r8ui, set = 0, binding = 3) uniform restrict writeonly uimage3D sdf_tex;
|
||||
|
||||
layout(push_constant, binding = 0, std430) uniform Params {
|
||||
|
||||
uint offset;
|
||||
uint end;
|
||||
uint pad0;
|
||||
|
@ -47,9 +46,9 @@ void main() {
|
|||
vec3 pos = vec3(gl_GlobalInvocationID);
|
||||
float closest_dist = 100000.0;
|
||||
|
||||
for(uint i=params.offset;i<params.end;i++) {
|
||||
vec3 posu = vec3(uvec3(cell_data.data[i].position&0x7FF,(cell_data.data[i].position>>11)&0x3FF,cell_data.data[i].position>>21));
|
||||
float dist = length(pos-posu);
|
||||
for (uint i = params.offset; i < params.end; i++) {
|
||||
vec3 posu = vec3(uvec3(cell_data.data[i].position & 0x7FF, (cell_data.data[i].position >> 11) & 0x3FF, cell_data.data[i].position >> 21));
|
||||
float dist = length(pos - posu);
|
||||
if (dist < closest_dist) {
|
||||
closest_dist = dist;
|
||||
}
|
||||
|
@ -57,17 +56,16 @@ void main() {
|
|||
|
||||
uint dist_8;
|
||||
|
||||
if (closest_dist<0.0001) { // same cell
|
||||
dist_8=0; //equals to -1
|
||||
if (closest_dist < 0.0001) { // same cell
|
||||
dist_8 = 0; //equals to -1
|
||||
} else {
|
||||
dist_8 = clamp(uint(closest_dist),0,254) + 1; //conservative, 0 is 1, so <1 is considered solid
|
||||
dist_8 = clamp(uint(closest_dist), 0, 254) + 1; //conservative, 0 is 1, so <1 is considered solid
|
||||
}
|
||||
|
||||
imageStore(sdf_tex,ivec3(gl_GlobalInvocationID),uvec4(dist_8));
|
||||
imageStore(sdf_tex, ivec3(gl_GlobalInvocationID), uvec4(dist_8));
|
||||
//imageStore(sdf_tex,pos,uvec4(pos*2,0));
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
layout(push_constant, binding = 0, std430) uniform Params {
|
||||
|
||||
|
@ -75,10 +73,9 @@ layout(push_constant, binding = 0, std430) uniform Params {
|
|||
uint stack_size;
|
||||
} params;
|
||||
|
||||
|
||||
float distance_to_aabb(ivec3 pos, ivec3 aabb_pos, ivec3 aabb_size) {
|
||||
|
||||
vec3 delta = vec3(max(ivec3(0),max(aabb_pos - pos, pos - (aabb_pos + aabb_size - ivec3(1)))));
|
||||
vec3 delta = vec3(max(ivec3(0), max(aabb_pos - pos, pos - (aabb_pos + aabb_size - ivec3(1)))));
|
||||
return length(delta);
|
||||
}
|
||||
|
||||
|
@ -86,20 +83,19 @@ void main() {
|
|||
|
||||
ivec3 pos = ivec3(gl_GlobalInvocationID);
|
||||
|
||||
uint stack[10]=uint[](0,0,0,0,0,0,0,0,0,0);
|
||||
uint stack_indices[10]=uint[](0,0,0,0,0,0,0,0,0,0);
|
||||
ivec3 stack_positions[10]=ivec3[](ivec3(0),ivec3(0),ivec3(0),ivec3(0),ivec3(0),ivec3(0),ivec3(0),ivec3(0),ivec3(0),ivec3(0));
|
||||
uint stack[10] = uint[](0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
uint stack_indices[10] = uint[](0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
ivec3 stack_positions[10] = ivec3[](ivec3(0), ivec3(0), ivec3(0), ivec3(0), ivec3(0), ivec3(0), ivec3(0), ivec3(0), ivec3(0), ivec3(0));
|
||||
|
||||
const uint cell_orders[8]=uint[](
|
||||
0x11f58d1,
|
||||
0xe2e70a,
|
||||
0xd47463,
|
||||
0xbb829c,
|
||||
0x8d11f5,
|
||||
0x70ae2e,
|
||||
0x463d47,
|
||||
0x29cbb8
|
||||
);
|
||||
const uint cell_orders[8] = uint[](
|
||||
0x11f58d1,
|
||||
0xe2e70a,
|
||||
0xd47463,
|
||||
0xbb829c,
|
||||
0x8d11f5,
|
||||
0x70ae2e,
|
||||
0x463d47,
|
||||
0x29cbb8);
|
||||
|
||||
bool cell_found = false;
|
||||
bool cell_found_exact = false;
|
||||
|
@ -107,46 +103,45 @@ void main() {
|
|||
float closest_distance = MAX_DISTANCE;
|
||||
int stack_pos = 0;
|
||||
|
||||
while(true) {
|
||||
while (true) {
|
||||
|
||||
uint index = stack_indices[stack_pos]>>24;
|
||||
uint index = stack_indices[stack_pos] >> 24;
|
||||
|
||||
if (index == 8) {
|
||||
//go up
|
||||
if (stack_pos==0) {
|
||||
if (stack_pos == 0) {
|
||||
break; //done going through octree
|
||||
}
|
||||
stack_pos--;
|
||||
continue;
|
||||
}
|
||||
|
||||
stack_indices[stack_pos] = (stack_indices[stack_pos]&((1<<24)-1))|((index + 1)<<24);
|
||||
stack_indices[stack_pos] = (stack_indices[stack_pos] & ((1 << 24) - 1)) | ((index + 1) << 24);
|
||||
|
||||
|
||||
uint cell_index = (stack_indices[stack_pos]>>(index*3))&0x7;
|
||||
uint cell_index = (stack_indices[stack_pos] >> (index * 3)) & 0x7;
|
||||
uint child_cell = cell_children.data[stack[stack_pos]].children[cell_index];
|
||||
|
||||
if (child_cell == NO_CHILDREN) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ivec3 child_cell_size = params.limits >> (stack_pos+1);
|
||||
ivec3 child_cell_size = params.limits >> (stack_pos + 1);
|
||||
ivec3 child_cell_pos = stack_positions[stack_pos];
|
||||
|
||||
child_cell_pos+=mix(ivec3(0),child_cell_size,bvec3(uvec3(index&1,index&2,index&4)!=uvec3(0)));
|
||||
child_cell_pos += mix(ivec3(0), child_cell_size, bvec3(uvec3(index & 1, index & 2, index & 4) != uvec3(0)));
|
||||
|
||||
bool is_leaf = stack_pos == (params.stack_size-2);
|
||||
bool is_leaf = stack_pos == (params.stack_size - 2);
|
||||
|
||||
if (child_cell_pos==pos && is_leaf) {
|
||||
if (child_cell_pos == pos && is_leaf) {
|
||||
//we may actually end up in the exact cell.
|
||||
//if this happens, just abort
|
||||
cell_found_exact=true;
|
||||
cell_found_exact = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (cell_found) {
|
||||
//discard by distance
|
||||
float distance = distance_to_aabb(pos,child_cell_pos,child_cell_size);
|
||||
float distance = distance_to_aabb(pos, child_cell_pos, child_cell_size);
|
||||
if (distance >= closest_distance) {
|
||||
continue; //pointless, just test next child
|
||||
} else if (is_leaf) {
|
||||
|
@ -157,38 +152,33 @@ void main() {
|
|||
}
|
||||
} else if (is_leaf) {
|
||||
//first solid cell we find, save and continue
|
||||
closest_distance = distance_to_aabb(pos,child_cell_pos,child_cell_size);
|
||||
closest_distance = distance_to_aabb(pos, child_cell_pos, child_cell_size);
|
||||
closest_cell_pos = child_cell_pos;
|
||||
cell_found=true;
|
||||
cell_found = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bvec3 direction = greaterThan(( pos - ( child_cell_pos + (child_cell_size >>1) ) ) , ivec3(0) );
|
||||
bvec3 direction = greaterThan((pos - (child_cell_pos + (child_cell_size >> 1))), ivec3(0));
|
||||
uint cell_order = 0;
|
||||
cell_order|=mix(0,1,direction.x);
|
||||
cell_order|=mix(0,2,direction.y);
|
||||
cell_order|=mix(0,4,direction.z);
|
||||
cell_order |= mix(0, 1, direction.x);
|
||||
cell_order |= mix(0, 2, direction.y);
|
||||
cell_order |= mix(0, 4, direction.z);
|
||||
|
||||
stack[stack_pos+1]=child_cell;
|
||||
stack_indices[stack_pos+1]=cell_orders[cell_order]; //start counting
|
||||
stack_positions[stack_pos+1]=child_cell_pos;
|
||||
stack[stack_pos + 1] = child_cell;
|
||||
stack_indices[stack_pos + 1] = cell_orders[cell_order]; //start counting
|
||||
stack_positions[stack_pos + 1] = child_cell_pos;
|
||||
stack_pos++; //go up stack
|
||||
|
||||
}
|
||||
|
||||
uint dist_8;
|
||||
|
||||
if (cell_found_exact) {
|
||||
dist_8=0; //equals to -1
|
||||
dist_8 = 0; //equals to -1
|
||||
} else {
|
||||
float closest_distance = length(vec3(pos-closest_cell_pos));
|
||||
dist_8 = clamp(uint(closest_distance),0,254) + 1; //conservative, 0 is 1, so <1 is considered solid
|
||||
float closest_distance = length(vec3(pos - closest_cell_pos));
|
||||
dist_8 = clamp(uint(closest_distance), 0, 254) + 1; //conservative, 0 is 1, so <1 is considered solid
|
||||
}
|
||||
|
||||
imageStore(sdf_tex,pos,uvec4(dist_8));
|
||||
|
||||
imageStore(sdf_tex, pos, uvec4(dist_8));
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* clang-format off */
|
||||
[compute]
|
||||
|
||||
#version 450
|
||||
|
@ -5,16 +6,17 @@
|
|||
VERSION_DEFINES
|
||||
|
||||
layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
|
||||
/* clang-format on */
|
||||
|
||||
#define NO_CHILDREN 0xFFFFFFFF
|
||||
#define GREY_VEC vec3(0.33333,0.33333,0.33333)
|
||||
#define GREY_VEC vec3(0.33333, 0.33333, 0.33333)
|
||||
|
||||
struct CellChildren {
|
||||
uint children[8];
|
||||
};
|
||||
|
||||
layout(set=0,binding=1,std430) buffer CellChildrenBuffer {
|
||||
CellChildren data[];
|
||||
layout(set = 0, binding = 1, std430) buffer CellChildrenBuffer {
|
||||
CellChildren data[];
|
||||
} cell_children;
|
||||
|
||||
struct CellData {
|
||||
|
@ -24,8 +26,8 @@ struct CellData {
|
|||
uint normal; //RGB normal encoded
|
||||
};
|
||||
|
||||
layout(set=0,binding=2,std430) buffer CellDataBuffer {
|
||||
CellData data[];
|
||||
layout(set = 0, binding = 2, std430) buffer CellDataBuffer {
|
||||
CellData data[];
|
||||
} cell_data;
|
||||
|
||||
#define LIGHT_TYPE_DIRECTIONAL 0
|
||||
|
@ -35,7 +37,6 @@ layout(set=0,binding=2,std430) buffer CellDataBuffer {
|
|||
#ifdef MODE_COMPUTE_LIGHT
|
||||
|
||||
struct Light {
|
||||
|
||||
uint type;
|
||||
float energy;
|
||||
float radius;
|
||||
|
@ -51,15 +52,13 @@ struct Light {
|
|||
bool has_shadow;
|
||||
};
|
||||
|
||||
|
||||
layout(set=0,binding=3,std140) uniform Lights {
|
||||
Light data[MAX_LIGHTS];
|
||||
layout(set = 0, binding = 3, std140) uniform Lights {
|
||||
Light data[MAX_LIGHTS];
|
||||
} lights;
|
||||
|
||||
#endif
|
||||
|
||||
layout(push_constant, binding = 0, std430) uniform Params {
|
||||
|
||||
ivec3 limits;
|
||||
uint stack_size;
|
||||
|
||||
|
@ -71,23 +70,19 @@ layout(push_constant, binding = 0, std430) uniform Params {
|
|||
uint cell_offset;
|
||||
uint cell_count;
|
||||
uint pad[2];
|
||||
|
||||
} params;
|
||||
|
||||
|
||||
layout(set=0,binding=4,std140) uniform Outputs {
|
||||
vec4 data[];
|
||||
layout(set = 0, binding = 4, std140) uniform Outputs {
|
||||
vec4 data[];
|
||||
} output;
|
||||
|
||||
|
||||
|
||||
#ifdef MODE_COMPUTE_LIGHT
|
||||
|
||||
uint raymarch(float distance,float distance_adv,vec3 from,vec3 direction) {
|
||||
uint raymarch(float distance, float distance_adv, vec3 from, vec3 direction) {
|
||||
|
||||
uint result = NO_CHILDREN;
|
||||
|
||||
ivec3 size = ivec3(max(max(params.limits.x,params.limits.y),params.limits.z));
|
||||
ivec3 size = ivec3(max(max(params.limits.x, params.limits.y), params.limits.z));
|
||||
|
||||
while (distance > -distance_adv) { //use this to avoid precision errors
|
||||
|
||||
|
@ -95,26 +90,26 @@ uint raymarch(float distance,float distance_adv,vec3 from,vec3 direction) {
|
|||
|
||||
ivec3 pos = ivec3(from);
|
||||
|
||||
if (all(greaterThanEqual(pos,ivec3(0))) && all(lessThan(pos,size))) {
|
||||
if (all(greaterThanEqual(pos, ivec3(0))) && all(lessThan(pos, size))) {
|
||||
|
||||
ivec3 ofs = ivec3(0);
|
||||
ivec3 half_size = size / 2;
|
||||
|
||||
for (int i = 0; i < params.stack_size - 1; i++) {
|
||||
|
||||
bvec3 greater = greaterThanEqual(pos,ofs+half_size);
|
||||
bvec3 greater = greaterThanEqual(pos, ofs + half_size);
|
||||
|
||||
ofs += mix(ivec3(0),half_size,greater);
|
||||
ofs += mix(ivec3(0), half_size, greater);
|
||||
|
||||
uint child = 0; //wonder if this can be done faster
|
||||
if (greater.x) {
|
||||
child|=1;
|
||||
child |= 1;
|
||||
}
|
||||
if (greater.y) {
|
||||
child|=2;
|
||||
child |= 2;
|
||||
}
|
||||
if (greater.z) {
|
||||
child|=4;
|
||||
child |= 4;
|
||||
}
|
||||
|
||||
cell = cell_children.data[cell].children[child];
|
||||
|
@ -124,10 +119,9 @@ uint raymarch(float distance,float distance_adv,vec3 from,vec3 direction) {
|
|||
half_size >>= ivec3(1);
|
||||
}
|
||||
|
||||
if ( cell != NO_CHILDREN) {
|
||||
if (cell != NO_CHILDREN) {
|
||||
return cell; //found cell!
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
from += direction * distance_adv;
|
||||
|
@ -137,10 +131,9 @@ uint raymarch(float distance,float distance_adv,vec3 from,vec3 direction) {
|
|||
return NO_CHILDREN;
|
||||
}
|
||||
|
||||
bool compute_light_vector(uint light,uint cell, vec3 pos,out float attenuation, out vec3 light_pos) {
|
||||
bool compute_light_vector(uint light, uint cell, vec3 pos, out float attenuation, out vec3 light_pos) {
|
||||
|
||||
|
||||
if (lights.data[light].type==LIGHT_TYPE_DIRECTIONAL) {
|
||||
if (lights.data[light].type == LIGHT_TYPE_DIRECTIONAL) {
|
||||
|
||||
light_pos = pos - lights.data[light].direction * length(vec3(params.limits));
|
||||
attenuation = 1.0;
|
||||
|
@ -153,14 +146,12 @@ bool compute_light_vector(uint light,uint cell, vec3 pos,out float attenuation,
|
|||
return false;
|
||||
}
|
||||
|
||||
attenuation = pow(clamp(1.0 - distance / lights.data[light].radius, 0.0001, 1.0), lights.data[light].attenuation);
|
||||
|
||||
attenuation = pow( clamp( 1.0 - distance / lights.data[light].radius, 0.0001, 1.0), lights.data[light].attenuation );
|
||||
|
||||
|
||||
if (lights.data[light].type==LIGHT_TYPE_SPOT) {
|
||||
if (lights.data[light].type == LIGHT_TYPE_SPOT) {
|
||||
|
||||
vec3 rel = normalize(pos - light_pos);
|
||||
float angle = acos(dot(rel,lights.data[light].direction));
|
||||
float angle = acos(dot(rel, lights.data[light].direction));
|
||||
if (angle > lights.data[light].spot_angle_radians) {
|
||||
return false;
|
||||
}
|
||||
|
@ -193,53 +184,50 @@ float get_normal_advance(vec3 p_normal) {
|
|||
unorm = vec3(1.0, 0.0, 0.0);
|
||||
}
|
||||
|
||||
return 1.0 / dot(normal,unorm);
|
||||
return 1.0 / dot(normal, unorm);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
void main() {
|
||||
|
||||
uint cell_index = gl_GlobalInvocationID.x;;
|
||||
uint cell_index = gl_GlobalInvocationID.x;
|
||||
if (cell_index >= params.cell_count) {
|
||||
return;
|
||||
}
|
||||
cell_index += params.cell_offset;
|
||||
|
||||
uvec3 posu = uvec3(cell_data.data[cell_index].position&0x7FF,(cell_data.data[cell_index].position>>11)&0x3FF,cell_data.data[cell_index].position>>21);
|
||||
uvec3 posu = uvec3(cell_data.data[cell_index].position & 0x7FF, (cell_data.data[cell_index].position >> 11) & 0x3FF, cell_data.data[cell_index].position >> 21);
|
||||
vec4 albedo = unpackUnorm4x8(cell_data.data[cell_index].albedo);
|
||||
|
||||
#ifdef MODE_COMPUTE_LIGHT
|
||||
|
||||
vec3 pos = vec3(posu) + vec3(0.5);
|
||||
|
||||
vec3 emission = vec3(ivec3(cell_data.data[cell_index].emission&0x3FF,(cell_data.data[cell_index].emission>>10)&0x7FF,cell_data.data[cell_index].emission>>21)) * params.emission_scale;
|
||||
vec3 emission = vec3(ivec3(cell_data.data[cell_index].emission & 0x3FF, (cell_data.data[cell_index].emission >> 10) & 0x7FF, cell_data.data[cell_index].emission >> 21)) * params.emission_scale;
|
||||
vec4 normal = unpackSnorm4x8(cell_data.data[cell_index].normal);
|
||||
|
||||
#ifdef MODE_ANISOTROPIC
|
||||
vec3 accum[6]=vec3[](vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));
|
||||
const vec3 accum_dirs[6]=vec3[](vec3(1.0,0.0,0.0),vec3(-1.0,0.0,0.0),vec3(0.0,1.0,0.0),vec3(0.0,-1.0,0.0),vec3(0.0,0.0,1.0),vec3(0.0,0.0,-1.0));
|
||||
vec3 accum[6] = vec3[](vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));
|
||||
const vec3 accum_dirs[6] = vec3[](vec3(1.0, 0.0, 0.0), vec3(-1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0), vec3(0.0, -1.0, 0.0), vec3(0.0, 0.0, 1.0), vec3(0.0, 0.0, -1.0));
|
||||
#else
|
||||
vec3 accum = vec3(0.0);
|
||||
#endif
|
||||
|
||||
for(uint i=0;i<params.light_count;i++) {
|
||||
for (uint i = 0; i < params.light_count; i++) {
|
||||
|
||||
float attenuation;
|
||||
vec3 light_pos;
|
||||
|
||||
if (!compute_light_vector(i,cell_index,pos,attenuation,light_pos)) {
|
||||
if (!compute_light_vector(i, cell_index, pos, attenuation, light_pos)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
vec3 light_dir = pos - light_pos;
|
||||
float distance = length(light_dir);
|
||||
light_dir=normalize(light_dir);
|
||||
light_dir = normalize(light_dir);
|
||||
|
||||
if (length(normal.xyz) > 0.2 && dot(normal.xyz,light_dir)>=0) {
|
||||
if (length(normal.xyz) > 0.2 && dot(normal.xyz, light_dir) >= 0) {
|
||||
continue; //not facing the light
|
||||
}
|
||||
|
||||
|
@ -247,15 +235,12 @@ void main() {
|
|||
|
||||
float distance_adv = get_normal_advance(light_dir);
|
||||
|
||||
|
||||
distance += distance_adv - mod(distance, distance_adv); //make it reach the center of the box always
|
||||
|
||||
vec3 from = pos - light_dir * distance; //approximate
|
||||
from -= sign(light_dir)*0.45; //go near the edge towards the light direction to avoid self occlusion
|
||||
from -= sign(light_dir) * 0.45; //go near the edge towards the light direction to avoid self occlusion
|
||||
|
||||
|
||||
|
||||
uint result = raymarch(distance,distance_adv,from,light_dir);
|
||||
uint result = raymarch(distance, distance_adv, from, light_dir);
|
||||
|
||||
if (result != cell_index) {
|
||||
continue; //was occluded
|
||||
|
@ -265,89 +250,81 @@ void main() {
|
|||
vec3 light = lights.data[i].color * albedo.rgb * attenuation * lights.data[i].energy;
|
||||
|
||||
#ifdef MODE_ANISOTROPIC
|
||||
for(uint j=0;j<6;j++) {
|
||||
accum[j]+=max(0.0,dot(accum_dir,-light_dir))*light+emission;
|
||||
for (uint j = 0; j < 6; j++) {
|
||||
accum[j] += max(0.0, dot(accum_dir, -light_dir)) * light + emission;
|
||||
}
|
||||
#else
|
||||
if (length(normal.xyz) > 0.2) {
|
||||
accum+=max(0.0,dot(normal.xyz,-light_dir))*light+emission;
|
||||
accum += max(0.0, dot(normal.xyz, -light_dir)) * light + emission;
|
||||
} else {
|
||||
//all directions
|
||||
accum+=light+emission;
|
||||
accum += light + emission;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#ifdef MODE_ANISOTROPIC
|
||||
|
||||
output.data[cell_index*6+0]=vec4(accum[0],0.0);
|
||||
output.data[cell_index*6+1]=vec4(accum[1],0.0);
|
||||
output.data[cell_index*6+2]=vec4(accum[2],0.0);
|
||||
output.data[cell_index*6+3]=vec4(accum[3],0.0);
|
||||
output.data[cell_index*6+4]=vec4(accum[4],0.0);
|
||||
output.data[cell_index*6+5]=vec4(accum[5],0.0);
|
||||
output.data[cell_index * 6 + 0] = vec4(accum[0], 0.0);
|
||||
output.data[cell_index * 6 + 1] = vec4(accum[1], 0.0);
|
||||
output.data[cell_index * 6 + 2] = vec4(accum[2], 0.0);
|
||||
output.data[cell_index * 6 + 3] = vec4(accum[3], 0.0);
|
||||
output.data[cell_index * 6 + 4] = vec4(accum[4], 0.0);
|
||||
output.data[cell_index * 6 + 5] = vec4(accum[5], 0.0);
|
||||
#else
|
||||
output.data[cell_index]=vec4(accum,0.0);
|
||||
output.data[cell_index] = vec4(accum, 0.0);
|
||||
|
||||
#endif
|
||||
|
||||
#endif //MODE_COMPUTE_LIGHT
|
||||
|
||||
|
||||
#ifdef MODE_UPDATE_MIPMAPS
|
||||
|
||||
{
|
||||
#ifdef MODE_ANISOTROPIC
|
||||
vec3 light_accum[6] = vec3[](vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));
|
||||
vec3 light_accum[6] = vec3[](vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));
|
||||
#else
|
||||
vec3 light_accum = vec3(0.0);
|
||||
#endif
|
||||
float count = 0.0;
|
||||
for(uint i=0;i<8;i++) {
|
||||
for (uint i = 0; i < 8; i++) {
|
||||
uint child_index = cell_children.data[cell_index].children[i];
|
||||
if (child_index==NO_CHILDREN) {
|
||||
if (child_index == NO_CHILDREN) {
|
||||
continue;
|
||||
}
|
||||
#ifdef MODE_ANISOTROPIC
|
||||
light_accum[1] += output.data[child_index*6+0].rgb;
|
||||
light_accum[2] += output.data[child_index*6+1].rgb;
|
||||
light_accum[3] += output.data[child_index*6+2].rgb;
|
||||
light_accum[4] += output.data[child_index*6+3].rgb;
|
||||
light_accum[5] += output.data[child_index*6+4].rgb;
|
||||
light_accum[6] += output.data[child_index*6+5].rgb;
|
||||
light_accum[1] += output.data[child_index * 6 + 0].rgb;
|
||||
light_accum[2] += output.data[child_index * 6 + 1].rgb;
|
||||
light_accum[3] += output.data[child_index * 6 + 2].rgb;
|
||||
light_accum[4] += output.data[child_index * 6 + 3].rgb;
|
||||
light_accum[5] += output.data[child_index * 6 + 4].rgb;
|
||||
light_accum[6] += output.data[child_index * 6 + 5].rgb;
|
||||
|
||||
#else
|
||||
light_accum += output.data[child_index].rgb;
|
||||
|
||||
#endif
|
||||
|
||||
count+=1.0;
|
||||
count += 1.0;
|
||||
}
|
||||
|
||||
float divisor = mix(8.0,count,params.propagation);
|
||||
float divisor = mix(8.0, count, params.propagation);
|
||||
#ifdef MODE_ANISOTROPIC
|
||||
output.data[cell_index*6+0]=vec4(light_accum[0] / divisor,0.0);
|
||||
output.data[cell_index*6+1]=vec4(light_accum[1] / divisor,0.0);
|
||||
output.data[cell_index*6+2]=vec4(light_accum[2] / divisor,0.0);
|
||||
output.data[cell_index*6+3]=vec4(light_accum[3] / divisor,0.0);
|
||||
output.data[cell_index*6+4]=vec4(light_accum[4] / divisor,0.0);
|
||||
output.data[cell_index*6+5]=vec4(light_accum[5] / divisor,0.0);
|
||||
output.data[cell_index * 6 + 0] = vec4(light_accum[0] / divisor, 0.0);
|
||||
output.data[cell_index * 6 + 1] = vec4(light_accum[1] / divisor, 0.0);
|
||||
output.data[cell_index * 6 + 2] = vec4(light_accum[2] / divisor, 0.0);
|
||||
output.data[cell_index * 6 + 3] = vec4(light_accum[3] / divisor, 0.0);
|
||||
output.data[cell_index * 6 + 4] = vec4(light_accum[4] / divisor, 0.0);
|
||||
output.data[cell_index * 6 + 5] = vec4(light_accum[5] / divisor, 0.0);
|
||||
|
||||
#else
|
||||
output.data[cell_index]=vec4(light_accum / divisor,0.0);
|
||||
output.data[cell_index] = vec4(light_accum / divisor, 0.0);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MODE_WRITE_TEXTURE
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,3 @@
|
|||
|
||||
#define M_PI 3.14159265359
|
||||
#define ROUGHNESS_MAX_LOD 5
|
||||
|
||||
|
@ -7,11 +6,8 @@ layout(push_constant, binding = 0, std430) uniform DrawCall {
|
|||
uint pad[3]; //16 bits minimum size
|
||||
} draw_call;
|
||||
|
||||
|
||||
|
||||
/* Set 0 Scene data that never changes, ever */
|
||||
|
||||
|
||||
#define SAMPLER_NEAREST_CLAMP 0
|
||||
#define SAMPLER_LINEAR_CLAMP 1
|
||||
#define SAMPLER_NEAREST_WITH_MIMPAMPS_CLAMP 2
|
||||
|
@ -29,7 +25,7 @@ layout(set = 0, binding = 1) uniform sampler material_samplers[12];
|
|||
|
||||
layout(set = 0, binding = 2) uniform sampler shadow_sampler;
|
||||
|
||||
layout(set=0,binding=3,std140) uniform SceneData {
|
||||
layout(set = 0, binding = 3, std140) uniform SceneData {
|
||||
|
||||
mat4 projection_matrix;
|
||||
mat4 inv_projection_matrix;
|
||||
|
@ -44,7 +40,6 @@ layout(set=0,binding=3,std140) uniform SceneData {
|
|||
float z_offset;
|
||||
float z_slope_scale;
|
||||
|
||||
|
||||
float time;
|
||||
float reflection_multiplier; // one normally, zero when rendering reflections
|
||||
|
||||
|
@ -74,14 +69,12 @@ layout(set=0,binding=3,std140) uniform SceneData {
|
|||
|
||||
float ambient_energy;
|
||||
float bg_energy;
|
||||
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
vec2 shadow_atlas_pixel_size;
|
||||
vec2 directional_shadow_pixel_size;
|
||||
|
||||
|
||||
float z_far;
|
||||
|
||||
float subsurface_scatter_width;
|
||||
|
@ -108,17 +101,16 @@ layout(set=0,binding=3,std140) uniform SceneData {
|
|||
#define INSTANCE_FLAGS_FORWARD_SPOT_LIGHT_SHIFT 6
|
||||
#define INSTANCE_FLAGS_FORWARD_DECAL_SHIFT 9
|
||||
|
||||
#define INSTANCE_FLAGS_MULTIMESH (1 << 12)
|
||||
#define INSTANCE_FLAGS_MULTIMESH_FORMAT_2D (1 << 13)
|
||||
#define INSTANCE_FLAGS_MULTIMESH_HAS_COLOR (1 << 14)
|
||||
#define INSTANCE_FLAGS_MULTIMESH_HAS_CUSTOM_DATA (1 << 15)
|
||||
#define INSTANCE_FLAGS_MULTIMESH (1 << 12)
|
||||
#define INSTANCE_FLAGS_MULTIMESH_FORMAT_2D (1 << 13)
|
||||
#define INSTANCE_FLAGS_MULTIMESH_HAS_COLOR (1 << 14)
|
||||
#define INSTANCE_FLAGS_MULTIMESH_HAS_CUSTOM_DATA (1 << 15)
|
||||
#define INSTANCE_FLAGS_MULTIMESH_STRIDE_SHIFT 16
|
||||
//3 bits of stride
|
||||
#define INSTANCE_FLAGS_MULTIMESH_STRIDE_MASK 0x7
|
||||
|
||||
#define INSTANCE_FLAGS_SKELETON (1 << 19)
|
||||
|
||||
|
||||
struct InstanceData {
|
||||
mat4 transform;
|
||||
mat4 normal_transform;
|
||||
|
@ -133,13 +125,11 @@ struct InstanceData {
|
|||
uint decal_indices[4];
|
||||
};
|
||||
|
||||
|
||||
layout(set=0,binding=4,std430) buffer Instances {
|
||||
InstanceData data[];
|
||||
layout(set = 0, binding = 4, std430) buffer Instances {
|
||||
InstanceData data[];
|
||||
} instances;
|
||||
|
||||
struct LightData { //this structure needs to be 128 bits
|
||||
|
||||
vec3 position;
|
||||
float inv_radius;
|
||||
vec3 direction;
|
||||
|
@ -152,7 +142,7 @@ struct LightData { //this structure needs to be 128 bits
|
|||
mat4 shadow_matrix;
|
||||
};
|
||||
|
||||
layout(set=0,binding=5,std140) uniform Lights {
|
||||
layout(set = 0, binding = 5, std140) uniform Lights {
|
||||
LightData data[MAX_LIGHT_DATA_STRUCTS];
|
||||
} lights;
|
||||
|
||||
|
@ -168,12 +158,11 @@ struct ReflectionData {
|
|||
// notes: for ambientblend, use distance to edge to blend between already existing global environment
|
||||
};
|
||||
|
||||
layout(set=0,binding=6,std140) uniform ReflectionProbeData {
|
||||
layout(set = 0, binding = 6, std140) uniform ReflectionProbeData {
|
||||
ReflectionData data[MAX_REFLECTION_DATA_STRUCTS];
|
||||
} reflections;
|
||||
|
||||
struct DirectionalLightData {
|
||||
|
||||
vec3 direction;
|
||||
float energy;
|
||||
vec3 color;
|
||||
|
@ -189,10 +178,9 @@ struct DirectionalLightData {
|
|||
mat4 shadow_matrix2;
|
||||
mat4 shadow_matrix3;
|
||||
mat4 shadow_matrix4;
|
||||
|
||||
};
|
||||
|
||||
layout(set=0,binding=7,std140) uniform DirectionalLights {
|
||||
layout(set = 0, binding = 7, std140) uniform DirectionalLights {
|
||||
DirectionalLightData data[MAX_DIRECTIONAL_LIGHT_DATA_STRUCTS];
|
||||
} directional_lights;
|
||||
|
||||
|
@ -212,20 +200,18 @@ struct GIProbeData {
|
|||
uint pad2;
|
||||
};
|
||||
|
||||
layout(set=0,binding=8,std140) uniform GIProbes {
|
||||
layout(set = 0, binding = 8, std140) uniform GIProbes {
|
||||
GIProbeData data[MAX_GI_PROBES];
|
||||
} gi_probes;
|
||||
|
||||
layout(set=0,binding=9) uniform texture3D gi_probe_textures[MAX_GI_PROBE_TEXTURES];
|
||||
|
||||
layout(set = 0, binding = 9) uniform texture3D gi_probe_textures[MAX_GI_PROBE_TEXTURES];
|
||||
|
||||
/* Set 1, Scene data that changes per render pass */
|
||||
|
||||
|
||||
layout(set=1,binding=0) uniform texture2D depth_buffer;
|
||||
layout(set=1,binding=1) uniform texture2D color_buffer;
|
||||
layout(set=1,binding=2) uniform texture2D normal_buffer;
|
||||
layout(set=1,binding=3) uniform texture2D roughness_limit;
|
||||
layout(set = 1, binding = 0) uniform texture2D depth_buffer;
|
||||
layout(set = 1, binding = 1) uniform texture2D color_buffer;
|
||||
layout(set = 1, binding = 2) uniform texture2D normal_buffer;
|
||||
layout(set = 1, binding = 3) uniform texture2D roughness_limit;
|
||||
|
||||
#ifdef USE_RADIANCE_CUBEMAP_ARRAY
|
||||
|
||||
|
@ -237,20 +223,16 @@ layout(set = 1, binding = 4) uniform textureCube radiance_cubemap;
|
|||
|
||||
#endif
|
||||
|
||||
layout(set = 1, binding = 5) uniform textureCubeArray reflection_atlas;
|
||||
|
||||
layout(set=1,binding=5) uniform textureCubeArray reflection_atlas;
|
||||
|
||||
layout(set=1,binding=6) uniform texture2D shadow_atlas;
|
||||
|
||||
layout(set=1,binding=7) uniform texture2D directional_shadow_atlas;
|
||||
layout(set = 1, binding = 6) uniform texture2D shadow_atlas;
|
||||
|
||||
layout(set = 1, binding = 7) uniform texture2D directional_shadow_atlas;
|
||||
|
||||
/* Set 2 Skeleton & Instancing (Multimesh) */
|
||||
|
||||
layout(set=2,binding=0,std430) buffer Transforms {
|
||||
vec4 data[];
|
||||
layout(set = 2, binding = 0, std430) buffer Transforms {
|
||||
vec4 data[];
|
||||
} transforms;
|
||||
|
||||
/* Set 3 User Material */
|
||||
|
||||
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
/* clang-format off */
|
||||
[vertex]
|
||||
/* clang-format on */
|
||||
|
||||
#version 450
|
||||
|
||||
/* clang-format off */
|
||||
VERSION_DEFINES
|
||||
/* clang-format on */
|
||||
|
||||
layout(location =0) out vec2 uv_interp;
|
||||
layout(location = 0) out vec2 uv_interp;
|
||||
/* clang-format on */
|
||||
|
||||
layout(push_constant, binding = 1, std430) uniform Params {
|
||||
mat3 orientation;
|
||||
|
@ -17,33 +15,28 @@ layout(push_constant, binding = 1, std430) uniform Params {
|
|||
float alpha;
|
||||
float depth;
|
||||
float pad;
|
||||
|
||||
} params;
|
||||
|
||||
void main() {
|
||||
|
||||
vec2 base_arr[4] = vec2[](vec2(-1.0,-1.0),vec2(-1.0,1.0),vec2(1.0,1.0),vec2(1.0,-1.0));
|
||||
vec2 base_arr[4] = vec2[](vec2(-1.0, -1.0), vec2(-1.0, 1.0), vec2(1.0, 1.0), vec2(1.0, -1.0));
|
||||
uv_interp = base_arr[gl_VertexIndex];
|
||||
gl_Position = vec4(uv_interp,params.depth,1.0);
|
||||
|
||||
gl_Position = vec4(uv_interp, params.depth, 1.0);
|
||||
}
|
||||
|
||||
/* clang-format off */
|
||||
[fragment]
|
||||
/* clang-format on */
|
||||
|
||||
#version 450
|
||||
|
||||
/* clang-format off */
|
||||
VERSION_DEFINES
|
||||
/* clang-format on */
|
||||
|
||||
#define M_PI 3.14159265359
|
||||
|
||||
layout(location =0) in vec2 uv_interp;
|
||||
|
||||
layout( set=0, binding=0 ) uniform sampler2D source_panorama;
|
||||
layout(location = 0) in vec2 uv_interp;
|
||||
/* clang-format on */
|
||||
|
||||
layout(set = 0, binding = 0) uniform sampler2D source_panorama;
|
||||
|
||||
layout(push_constant, binding = 1, std430) uniform Params {
|
||||
mat3 orientation;
|
||||
|
@ -52,10 +45,8 @@ layout(push_constant, binding = 1, std430) uniform Params {
|
|||
float alpha;
|
||||
float depth;
|
||||
float pad;
|
||||
|
||||
} params;
|
||||
|
||||
|
||||
vec4 texturePanorama(sampler2D pano, vec3 normal) {
|
||||
|
||||
vec2 st = vec2(
|
||||
|
@ -70,10 +61,8 @@ vec4 texturePanorama(sampler2D pano, vec3 normal) {
|
|||
return texture(pano, st);
|
||||
}
|
||||
|
||||
|
||||
layout(location = 0) out vec4 frag_color;
|
||||
|
||||
|
||||
void main() {
|
||||
|
||||
vec3 cube_normal;
|
||||
|
@ -85,5 +74,4 @@ void main() {
|
|||
|
||||
frag_color.rgb = texturePanorama(source_panorama, normalize(cube_normal.xyz)).rgb;
|
||||
frag_color.a = params.alpha;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,40 +1,34 @@
|
|||
/* clang-format off */
|
||||
[vertex]
|
||||
/* clang-format on */
|
||||
|
||||
#version 450
|
||||
|
||||
/* clang-format off */
|
||||
VERSION_DEFINES
|
||||
/* clang-format on */
|
||||
|
||||
layout(location = 0) out vec2 uv_interp;
|
||||
/* clang-format on */
|
||||
|
||||
void main() {
|
||||
|
||||
vec2 base_arr[4] = vec2[](vec2(0.0,0.0),vec2(0.0,1.0),vec2(1.0,1.0),vec2(1.0,0.0));
|
||||
vec2 base_arr[4] = vec2[](vec2(0.0, 0.0), vec2(0.0, 1.0), vec2(1.0, 1.0), vec2(1.0, 0.0));
|
||||
uv_interp = base_arr[gl_VertexIndex];
|
||||
gl_Position = vec4( uv_interp *2.0 - 1.0, 0.0, 1.0);
|
||||
gl_Position = vec4(uv_interp * 2.0 - 1.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
/* clang-format off */
|
||||
[fragment]
|
||||
|
||||
/* clang-format on */
|
||||
|
||||
|
||||
#version 450
|
||||
|
||||
/* clang-format off */
|
||||
VERSION_DEFINES
|
||||
|
||||
layout(location = 0) in vec2 uv_interp;
|
||||
/* clang-format on */
|
||||
|
||||
layout(location =0) in vec2 uv_interp;
|
||||
|
||||
layout( set=0, binding=0 ) uniform sampler2D source_color;
|
||||
layout( set=1, binding=0 ) uniform sampler2D source_auto_exposure;
|
||||
layout( set=2, binding=0 ) uniform sampler2D source_glow;
|
||||
layout( set=3, binding=0 ) uniform sampler3D color_correction;
|
||||
layout(set = 0, binding = 0) uniform sampler2D source_color;
|
||||
layout(set = 1, binding = 0) uniform sampler2D source_auto_exposure;
|
||||
layout(set = 2, binding = 0) uniform sampler2D source_glow;
|
||||
layout(set = 3, binding = 0) uniform sampler3D color_correction;
|
||||
|
||||
layout(push_constant, binding = 1, std430) uniform Params {
|
||||
vec3 bcs;
|
||||
|
@ -54,7 +48,6 @@ layout(push_constant, binding = 1, std430) uniform Params {
|
|||
float exposure;
|
||||
float white;
|
||||
float auto_exposure_grey;
|
||||
|
||||
} params;
|
||||
|
||||
layout(location = 0) out vec4 frag_color;
|
||||
|
@ -95,7 +88,6 @@ float h1(float a) {
|
|||
return 1.0f + w3(a) / (w2(a) + w3(a));
|
||||
}
|
||||
|
||||
|
||||
vec4 texture2D_bicubic(sampler2D tex, vec2 uv, int p_lod) {
|
||||
float lod = float(p_lod);
|
||||
vec2 tex_size = vec2(params.glow_texture_size >> p_lod);
|
||||
|
@ -168,7 +160,7 @@ vec3 tonemap_reinhard(vec3 color, float white) {
|
|||
|
||||
vec3 linear_to_srgb(vec3 color) {
|
||||
//if going to srgb, clamp from 0 to 1.
|
||||
color = clamp(color,vec3(0.0),vec3(1.0));
|
||||
color = clamp(color, vec3(0.0), vec3(1.0));
|
||||
const vec3 a = vec3(0.055f);
|
||||
return mix((vec3(1.0f) + a) * pow(color.rgb, vec3(1.0f / 2.4f)) - a, 12.92f * color.rgb, lessThan(color.rgb, vec3(0.0031308f)));
|
||||
}
|
||||
|
@ -180,11 +172,11 @@ vec3 linear_to_srgb(vec3 color) {
|
|||
|
||||
vec3 apply_tonemapping(vec3 color, float white) { // inputs are LINEAR, always outputs clamped [0;1] color
|
||||
|
||||
if (params.tonemapper==TONEMAPPER_LINEAR) {
|
||||
if (params.tonemapper == TONEMAPPER_LINEAR) {
|
||||
return color;
|
||||
} else if (params.tonemapper==TONEMAPPER_REINHARD) {
|
||||
} else if (params.tonemapper == TONEMAPPER_REINHARD) {
|
||||
return tonemap_reinhard(color, white);
|
||||
} else if (params.tonemapper==TONEMAPPER_FILMIC) {
|
||||
} else if (params.tonemapper == TONEMAPPER_FILMIC) {
|
||||
return tonemap_filmic(color, white);
|
||||
} else { //aces
|
||||
return tonemap_aces(color, white);
|
||||
|
@ -194,31 +186,31 @@ vec3 apply_tonemapping(vec3 color, float white) { // inputs are LINEAR, always o
|
|||
vec3 gather_glow(sampler2D tex, vec2 uv) { // sample all selected glow levels
|
||||
vec3 glow = vec3(0.0f);
|
||||
|
||||
if (bool(params.glow_level_flags&(1<<0))) {
|
||||
if (bool(params.glow_level_flags & (1 << 0))) {
|
||||
glow += GLOW_TEXTURE_SAMPLE(tex, uv, 1).rgb;
|
||||
}
|
||||
|
||||
if (bool(params.glow_level_flags&(1<<1))) {
|
||||
if (bool(params.glow_level_flags & (1 << 1))) {
|
||||
glow += GLOW_TEXTURE_SAMPLE(tex, uv, 2).rgb;
|
||||
}
|
||||
|
||||
if (bool(params.glow_level_flags&(1<<2))) {
|
||||
if (bool(params.glow_level_flags & (1 << 2))) {
|
||||
glow += GLOW_TEXTURE_SAMPLE(tex, uv, 3).rgb;
|
||||
}
|
||||
|
||||
if (bool(params.glow_level_flags&(1<<3))) {
|
||||
if (bool(params.glow_level_flags & (1 << 3))) {
|
||||
glow += GLOW_TEXTURE_SAMPLE(tex, uv, 4).rgb;
|
||||
}
|
||||
|
||||
if (bool(params.glow_level_flags&(1<<4))) {
|
||||
if (bool(params.glow_level_flags & (1 << 4))) {
|
||||
glow += GLOW_TEXTURE_SAMPLE(tex, uv, 5).rgb;
|
||||
}
|
||||
|
||||
if (bool(params.glow_level_flags&(1<<5))) {
|
||||
if (bool(params.glow_level_flags & (1 << 5))) {
|
||||
glow += GLOW_TEXTURE_SAMPLE(tex, uv, 6).rgb;
|
||||
}
|
||||
|
||||
if (bool(params.glow_level_flags&(1<<6))) {
|
||||
if (bool(params.glow_level_flags & (1 << 6))) {
|
||||
glow += GLOW_TEXTURE_SAMPLE(tex, uv, 7).rgb;
|
||||
}
|
||||
|
||||
|
@ -231,12 +223,12 @@ vec3 gather_glow(sampler2D tex, vec2 uv) { // sample all selected glow levels
|
|||
#define GLOW_MODE_REPLACE 3
|
||||
|
||||
vec3 apply_glow(vec3 color, vec3 glow) { // apply glow using the selected blending mode
|
||||
if (params.glow_mode==GLOW_MODE_ADD) {
|
||||
if (params.glow_mode == GLOW_MODE_ADD) {
|
||||
return color + glow;
|
||||
} else if (params.glow_mode==GLOW_MODE_SCREEN) {
|
||||
} else if (params.glow_mode == GLOW_MODE_SCREEN) {
|
||||
//need color clamping
|
||||
return max((color + glow) - (color * glow), vec3(0.0));
|
||||
} else if ( params.glow_mode==GLOW_MODE_SOFTLIGHT) {
|
||||
} else if (params.glow_mode == GLOW_MODE_SOFTLIGHT) {
|
||||
//need color clamping
|
||||
glow = glow * vec3(0.5f) + vec3(0.5f);
|
||||
|
||||
|
@ -258,7 +250,7 @@ vec3 apply_bcs(vec3 color, vec3 bcs) {
|
|||
}
|
||||
|
||||
vec3 apply_color_correction(vec3 color, sampler3D correction_tex) {
|
||||
return texture(correction_tex,color).rgb;
|
||||
return texture(correction_tex, color).rgb;
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
|
Loading…
Reference in New Issue