mirror of
https://github.com/Relintai/pandemonium_engine_minimal.git
synced 2024-11-17 22:17:19 +01:00
Cleaned up remaining spatial shader code.
This commit is contained in:
parent
bc8638d4d0
commit
54835d006b
@ -465,7 +465,6 @@ protected:
|
||||
public:
|
||||
RasterizerStorage *get_storage() { return &storage; }
|
||||
RasterizerCanvas *get_canvas() { return &canvas; }
|
||||
RasterizerScene *get_scene() { return &scene; }
|
||||
|
||||
void set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter = true) {}
|
||||
void set_shader_time_scale(float p_scale) {}
|
||||
|
@ -33,7 +33,6 @@
|
||||
#include "core/os/os.h"
|
||||
#include "core/config/project_settings.h"
|
||||
#include "drivers/gles_common/rasterizer_asserts.h"
|
||||
#include "rasterizer_scene_gles2.h"
|
||||
#include "servers/rendering/rendering_server_raster.h"
|
||||
|
||||
#ifndef GLES_OVER_GL
|
||||
|
@ -94,8 +94,6 @@ public:
|
||||
|
||||
typedef void Texture;
|
||||
|
||||
RasterizerSceneGLES2 *scene_render;
|
||||
|
||||
RasterizerStorageGLES2 *storage;
|
||||
|
||||
// allow user to choose api usage
|
||||
|
@ -34,7 +34,6 @@
|
||||
#include "core/os/os.h"
|
||||
#include "drivers/gles2/rasterizer_gles2.h"
|
||||
#include "drivers/gles_common/rasterizer_asserts.h"
|
||||
#include "rasterizer_scene_gles2.h"
|
||||
#include "servers/rendering/rendering_server_raster.h"
|
||||
|
||||
static const GLenum gl_primitive[] = {
|
||||
|
@ -33,8 +33,6 @@
|
||||
#include "drivers/gles_common/rasterizer_canvas_batcher.h"
|
||||
#include "rasterizer_canvas_base_gles2.h"
|
||||
|
||||
class RasterizerSceneGLES2;
|
||||
|
||||
class RasterizerCanvasGLES2 : public RasterizerCanvasBaseGLES2, public RasterizerCanvasBatcher<RasterizerCanvasGLES2, RasterizerStorageGLES2> {
|
||||
friend class RasterizerCanvasBatcher<RasterizerCanvasGLES2, RasterizerStorageGLES2>;
|
||||
|
||||
|
@ -156,10 +156,6 @@ RasterizerCanvas *RasterizerGLES2::get_canvas() {
|
||||
return canvas;
|
||||
}
|
||||
|
||||
RasterizerScene *RasterizerGLES2::get_scene() {
|
||||
return scene;
|
||||
}
|
||||
|
||||
Error RasterizerGLES2::is_viable() {
|
||||
#ifdef GLAD_ENABLED
|
||||
if (!gladLoadGL()) {
|
||||
@ -264,7 +260,6 @@ void RasterizerGLES2::initialize() {
|
||||
print_line("OpenGL ES 2.0 Renderer: " + RenderingServer::get_singleton()->get_video_adapter_name());
|
||||
storage->initialize();
|
||||
canvas->initialize();
|
||||
scene->initialize();
|
||||
}
|
||||
|
||||
void RasterizerGLES2::begin_frame(double frame_step) {
|
||||
@ -289,8 +284,6 @@ void RasterizerGLES2::begin_frame(double frame_step) {
|
||||
|
||||
storage->info.render_final = storage->info.render;
|
||||
storage->info.render.reset();
|
||||
|
||||
scene->iteration();
|
||||
}
|
||||
|
||||
void RasterizerGLES2::set_current_render_target(RID p_render_target) {
|
||||
@ -526,19 +519,15 @@ bool RasterizerGLES2::gl_check_errors() {
|
||||
RasterizerGLES2::RasterizerGLES2() {
|
||||
storage = memnew(RasterizerStorageGLES2);
|
||||
canvas = memnew(RasterizerCanvasGLES2);
|
||||
scene = memnew(RasterizerSceneGLES2);
|
||||
|
||||
canvas->storage = storage;
|
||||
canvas->scene_render = scene;
|
||||
storage->canvas = canvas;
|
||||
scene->storage = storage;
|
||||
storage->scene = scene;
|
||||
|
||||
time_total = 0;
|
||||
time_scale = 1;
|
||||
}
|
||||
|
||||
RasterizerGLES2::~RasterizerGLES2() {
|
||||
memdelete(scene);
|
||||
memdelete(canvas);
|
||||
|
||||
// Storage needs to be deleted after canvas as canvas destructor frees RIDs
|
||||
|
@ -31,7 +31,6 @@
|
||||
/*************************************************************************/
|
||||
|
||||
#include "rasterizer_canvas_gles2.h"
|
||||
#include "rasterizer_scene_gles2.h"
|
||||
#include "rasterizer_storage_gles2.h"
|
||||
#include "servers/rendering/rasterizer.h"
|
||||
|
||||
@ -40,7 +39,6 @@ class RasterizerGLES2 : public Rasterizer {
|
||||
|
||||
RasterizerStorageGLES2 *storage;
|
||||
RasterizerCanvasGLES2 *canvas;
|
||||
RasterizerSceneGLES2 *scene;
|
||||
|
||||
double time_total;
|
||||
float time_scale;
|
||||
@ -48,7 +46,6 @@ class RasterizerGLES2 : public Rasterizer {
|
||||
public:
|
||||
virtual RasterizerStorage *get_storage();
|
||||
virtual RasterizerCanvas *get_canvas();
|
||||
virtual RasterizerScene *get_scene();
|
||||
|
||||
virtual void set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter = true);
|
||||
virtual void set_shader_time_scale(float p_scale);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,326 +0,0 @@
|
||||
#ifndef RASTERIZERSCENEGLES2_H
|
||||
#define RASTERIZERSCENEGLES2_H
|
||||
/*************************************************************************/
|
||||
/* rasterizer_scene_gles2.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 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. */
|
||||
/*************************************************************************/
|
||||
|
||||
/* Must come before shaders or the Windows build fails... */
|
||||
#include "rasterizer_storage_gles2.h"
|
||||
|
||||
#include "shaders/cube_to_dp.glsl.gen.h"
|
||||
#include "shaders/effect_blur.glsl.gen.h"
|
||||
#include "shaders/scene.glsl.gen.h"
|
||||
#include "shaders/tonemap.glsl.gen.h"
|
||||
/*
|
||||
|
||||
|
||||
#include "drivers/gles3/shaders/exposure.glsl.gen.h"
|
||||
#include "drivers/gles3/shaders/resolve.glsl.gen.h"
|
||||
#include "drivers/gles3/shaders/scene.glsl.gen.h"
|
||||
#include "drivers/gles3/shaders/screen_space_reflection.glsl.gen.h"
|
||||
#include "drivers/gles3/shaders/ssao.glsl.gen.h"
|
||||
#include "drivers/gles3/shaders/ssao_blur.glsl.gen.h"
|
||||
#include "drivers/gles3/shaders/ssao_minify.glsl.gen.h"
|
||||
#include "drivers/gles3/shaders/subsurf_scattering.glsl.gen.h"
|
||||
|
||||
*/
|
||||
|
||||
class RasterizerSceneGLES2 : public RasterizerScene {
|
||||
public:
|
||||
enum {
|
||||
INSTANCE_ATTRIB_BASE = 8,
|
||||
INSTANCE_BONE_BASE = 13,
|
||||
};
|
||||
|
||||
RID default_material;
|
||||
RID default_material_twosided;
|
||||
RID default_shader;
|
||||
RID default_shader_twosided;
|
||||
|
||||
RID default_worldcoord_material;
|
||||
RID default_worldcoord_material_twosided;
|
||||
RID default_worldcoord_shader;
|
||||
RID default_worldcoord_shader_twosided;
|
||||
|
||||
RID default_overdraw_material;
|
||||
RID default_overdraw_shader;
|
||||
|
||||
uint64_t render_pass;
|
||||
uint64_t scene_pass;
|
||||
uint32_t current_material_index;
|
||||
uint32_t current_geometry_index;
|
||||
uint32_t current_light_index;
|
||||
uint32_t current_shader_index;
|
||||
|
||||
private:
|
||||
uint32_t _light_counter;
|
||||
static const GLenum gl_primitive[];
|
||||
static const GLenum _cube_side_enum[6];
|
||||
|
||||
public:
|
||||
RasterizerStorageGLES2 *storage;
|
||||
struct State {
|
||||
bool texscreen_copied;
|
||||
int current_blend_mode;
|
||||
float current_line_width;
|
||||
int current_depth_draw;
|
||||
bool current_depth_test;
|
||||
GLuint current_main_tex;
|
||||
|
||||
SceneShaderGLES2 scene_shader;
|
||||
CubeToDpShaderGLES2 cube_to_dp_shader;
|
||||
TonemapShaderGLES2 tonemap_shader;
|
||||
EffectBlurShaderGLES2 effect_blur_shader;
|
||||
|
||||
GLuint sky_verts;
|
||||
|
||||
GLuint immediate_buffer;
|
||||
Color default_ambient;
|
||||
Color default_bg;
|
||||
|
||||
bool cull_front;
|
||||
bool cull_disabled;
|
||||
|
||||
bool used_screen_texture;
|
||||
bool shadow_is_dual_parabolloid;
|
||||
float dual_parbolloid_direction;
|
||||
float dual_parbolloid_zfar;
|
||||
|
||||
bool render_no_shadows;
|
||||
|
||||
Vector2 viewport_size;
|
||||
|
||||
Vector2 screen_pixel_size;
|
||||
} state;
|
||||
|
||||
/* RENDER LIST */
|
||||
|
||||
enum LightMode {
|
||||
LIGHTMODE_NORMAL,
|
||||
LIGHTMODE_UNSHADED,
|
||||
};
|
||||
|
||||
struct RenderList {
|
||||
enum {
|
||||
MAX_LIGHTS = 255,
|
||||
DEFAULT_MAX_ELEMENTS = 65536
|
||||
};
|
||||
|
||||
int max_elements;
|
||||
|
||||
struct Element {
|
||||
RasterizerScene::InstanceBase *instance;
|
||||
|
||||
RasterizerStorageGLES2::Geometry *geometry;
|
||||
RasterizerStorageGLES2::Material *material;
|
||||
RasterizerStorageGLES2::GeometryOwner *owner;
|
||||
|
||||
bool use_accum; //is this an add pass for multipass
|
||||
bool *use_accum_ptr;
|
||||
bool front_facing;
|
||||
|
||||
union {
|
||||
//TODO: should be endian swapped on big endian
|
||||
struct {
|
||||
int32_t depth_layer : 16;
|
||||
int32_t priority : 16;
|
||||
};
|
||||
|
||||
uint32_t depth_key;
|
||||
};
|
||||
|
||||
union {
|
||||
struct {
|
||||
//from least significant to most significant in sort, TODO: should be endian swapped on big endian
|
||||
|
||||
uint64_t geometry_index : 14;
|
||||
uint64_t instancing : 1;
|
||||
uint64_t skeleton : 1;
|
||||
uint64_t shader_index : 10;
|
||||
uint64_t material_index : 10;
|
||||
uint64_t light_index : 8;
|
||||
uint64_t light_type2 : 1; // if 1==0 : nolight/directional, else omni/spot
|
||||
uint64_t refprobe_1_index : 8;
|
||||
uint64_t refprobe_0_index : 8;
|
||||
uint64_t light_type1 : 1; //no light, directional is 0, omni spot is 1
|
||||
uint64_t light_mode : 2; // LightMode enum
|
||||
};
|
||||
|
||||
uint64_t sort_key;
|
||||
};
|
||||
};
|
||||
|
||||
Element *base_elements;
|
||||
Element **elements;
|
||||
|
||||
int element_count;
|
||||
int alpha_element_count;
|
||||
|
||||
void clear() {
|
||||
element_count = 0;
|
||||
alpha_element_count = 0;
|
||||
}
|
||||
|
||||
// sorts
|
||||
|
||||
struct SortByKey {
|
||||
_FORCE_INLINE_ bool operator()(const Element *A, const Element *B) const {
|
||||
if (A->depth_key == B->depth_key) {
|
||||
return A->sort_key < B->sort_key;
|
||||
} else {
|
||||
return A->depth_key < B->depth_key;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void sort_by_key(bool p_alpha) {
|
||||
SortArray<Element *, SortByKey> sorter;
|
||||
|
||||
if (p_alpha) {
|
||||
sorter.sort(&elements[max_elements - alpha_element_count], alpha_element_count);
|
||||
} else {
|
||||
sorter.sort(elements, element_count);
|
||||
}
|
||||
}
|
||||
|
||||
struct SortByDepth {
|
||||
_FORCE_INLINE_ bool operator()(const Element *A, const Element *B) const {
|
||||
return A->instance->depth < B->instance->depth;
|
||||
}
|
||||
};
|
||||
|
||||
void sort_by_depth(bool p_alpha) { //used for shadows
|
||||
|
||||
SortArray<Element *, SortByDepth> sorter;
|
||||
if (p_alpha) {
|
||||
sorter.sort(&elements[max_elements - alpha_element_count], alpha_element_count);
|
||||
} else {
|
||||
sorter.sort(elements, element_count);
|
||||
}
|
||||
}
|
||||
|
||||
struct SortByReverseDepthAndPriority {
|
||||
_FORCE_INLINE_ bool operator()(const Element *A, const Element *B) const {
|
||||
if (A->priority == B->priority) {
|
||||
return A->instance->depth > B->instance->depth;
|
||||
} else {
|
||||
return A->priority < B->priority;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void sort_by_reverse_depth_and_priority(bool p_alpha) { //used for alpha
|
||||
|
||||
SortArray<Element *, SortByReverseDepthAndPriority> sorter;
|
||||
if (p_alpha) {
|
||||
sorter.sort(&elements[max_elements - alpha_element_count], alpha_element_count);
|
||||
} else {
|
||||
sorter.sort(elements, element_count);
|
||||
}
|
||||
}
|
||||
|
||||
// element adding and stuff
|
||||
|
||||
_FORCE_INLINE_ Element *add_element() {
|
||||
if (element_count + alpha_element_count >= max_elements) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
elements[element_count] = &base_elements[element_count];
|
||||
return elements[element_count++];
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Element *add_alpha_element() {
|
||||
if (element_count + alpha_element_count >= max_elements) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int idx = max_elements - alpha_element_count - 1;
|
||||
elements[idx] = &base_elements[idx];
|
||||
alpha_element_count++;
|
||||
return elements[idx];
|
||||
}
|
||||
|
||||
void init() {
|
||||
element_count = 0;
|
||||
alpha_element_count = 0;
|
||||
|
||||
elements = memnew_arr(Element *, max_elements);
|
||||
base_elements = memnew_arr(Element, max_elements);
|
||||
|
||||
for (int i = 0; i < max_elements; i++) {
|
||||
elements[i] = &base_elements[i];
|
||||
}
|
||||
}
|
||||
|
||||
RenderList() {
|
||||
max_elements = DEFAULT_MAX_ELEMENTS;
|
||||
}
|
||||
|
||||
~RenderList() {
|
||||
memdelete_arr(elements);
|
||||
memdelete_arr(base_elements);
|
||||
}
|
||||
};
|
||||
|
||||
RenderList render_list;
|
||||
|
||||
void _add_geometry(RasterizerStorageGLES2::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES2::GeometryOwner *p_owner, int p_material, bool p_depth_pass);
|
||||
void _add_geometry_with_material(RasterizerStorageGLES2::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES2::GeometryOwner *p_owner, RasterizerStorageGLES2::Material *p_material, bool p_depth_pass);
|
||||
|
||||
void _copy_texture_to_buffer(GLuint p_texture, GLuint p_buffer);
|
||||
void _fill_render_list(InstanceBase **p_cull_result, int p_cull_count, bool p_depth_pass);
|
||||
void _render_render_list(RenderList::Element **p_elements, int p_element_count,
|
||||
const Transform &p_view_transform,
|
||||
const Projection &p_projection,
|
||||
const int p_eye,
|
||||
bool p_reverse_cull,
|
||||
bool p_alpha_pass);
|
||||
|
||||
_FORCE_INLINE_ void _set_cull(bool p_front, bool p_disabled, bool p_reverse_cull);
|
||||
_FORCE_INLINE_ bool _setup_material(RasterizerStorageGLES2::Material *p_material, bool p_alpha_pass, Size2i p_skeleton_tex_size = Size2i(0, 0));
|
||||
_FORCE_INLINE_ void _setup_geometry(RenderList::Element *p_element);
|
||||
_FORCE_INLINE_ void _render_geometry(RenderList::Element *p_element);
|
||||
|
||||
void _post_process(const Projection &p_cam_projection);
|
||||
|
||||
virtual void render_scene(const Transform &p_cam_transform, const Projection &p_cam_projection, const int p_eye, bool p_cam_ortogonal, InstanceBase **p_cull_result, int p_cull_count);
|
||||
virtual bool free(RID p_rid);
|
||||
|
||||
virtual void set_scene_pass(uint64_t p_pass);
|
||||
virtual void set_debug_draw_mode(RS::ViewportDebugDraw p_debug_draw);
|
||||
|
||||
void iteration();
|
||||
void initialize();
|
||||
void finalize();
|
||||
RasterizerSceneGLES2();
|
||||
~RasterizerSceneGLES2();
|
||||
};
|
||||
|
||||
#endif // RASTERIZERSCENEGLES2_H
|
@ -33,7 +33,6 @@
|
||||
#include "core/config/project_settings.h"
|
||||
#include "core/math/transform.h"
|
||||
#include "rasterizer_canvas_gles2.h"
|
||||
#include "rasterizer_scene_gles2.h"
|
||||
#include "servers/rendering/rendering_server_canvas.h"
|
||||
#include "servers/rendering/rendering_server_globals.h"
|
||||
#include "servers/rendering/shader_language.h"
|
||||
@ -1155,8 +1154,8 @@ RID RasterizerStorageGLES2::texture_create_radiance_cubemap(RID p_source, int p_
|
||||
|
||||
RID RasterizerStorageGLES2::shader_create() {
|
||||
Shader *shader = memnew(Shader);
|
||||
shader->mode = RS::SHADER_SPATIAL;
|
||||
shader->shader = &scene->state.scene_shader;
|
||||
shader->mode = RS::SHADER_CANVAS_ITEM;
|
||||
shader->shader = &canvas->state.canvas_shader;
|
||||
RID rid = shader_owner.make_rid(shader);
|
||||
_shader_make_dirty(shader);
|
||||
shader->self = rid;
|
||||
@ -1181,12 +1180,10 @@ void RasterizerStorageGLES2::shader_set_code(RID p_shader, const String &p_code)
|
||||
String mode_string = ShaderLanguage::get_shader_type(p_code);
|
||||
RS::ShaderMode mode;
|
||||
|
||||
if (mode_string == "canvas_item") {
|
||||
mode = RS::SHADER_CANVAS_ITEM;
|
||||
} else if (mode_string == "particles") {
|
||||
if (mode_string == "particles") {
|
||||
mode = RS::SHADER_PARTICLES;
|
||||
} else {
|
||||
mode = RS::SHADER_SPATIAL;
|
||||
mode = RS::SHADER_CANVAS_ITEM;
|
||||
}
|
||||
|
||||
if (shader->custom_code_id && mode != shader->mode) {
|
||||
@ -1199,9 +1196,6 @@ void RasterizerStorageGLES2::shader_set_code(RID p_shader, const String &p_code)
|
||||
// TODO handle all shader types
|
||||
if (mode == RS::SHADER_CANVAS_ITEM) {
|
||||
shader->shader = &canvas->state.canvas_shader;
|
||||
|
||||
} else if (mode == RS::SHADER_SPATIAL) {
|
||||
shader->shader = &scene->state.scene_shader;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
@ -1279,79 +1273,6 @@ void RasterizerStorageGLES2::_update_shader(Shader *p_shader) const {
|
||||
actions->uniforms = &p_shader->uniforms;
|
||||
} break;
|
||||
|
||||
case RS::SHADER_SPATIAL: {
|
||||
p_shader->spatial.blend_mode = Shader::Spatial::BLEND_MODE_MIX;
|
||||
p_shader->spatial.depth_draw_mode = Shader::Spatial::DEPTH_DRAW_OPAQUE;
|
||||
p_shader->spatial.cull_mode = Shader::Spatial::CULL_MODE_BACK;
|
||||
p_shader->spatial.uses_alpha = false;
|
||||
p_shader->spatial.uses_alpha_scissor = false;
|
||||
p_shader->spatial.uses_discard = false;
|
||||
p_shader->spatial.unshaded = false;
|
||||
p_shader->spatial.no_depth_test = false;
|
||||
p_shader->spatial.uses_sss = false;
|
||||
p_shader->spatial.uses_time = false;
|
||||
p_shader->spatial.uses_vertex_lighting = false;
|
||||
p_shader->spatial.uses_screen_texture = false;
|
||||
p_shader->spatial.uses_depth_texture = false;
|
||||
p_shader->spatial.uses_vertex = false;
|
||||
p_shader->spatial.uses_tangent = false;
|
||||
p_shader->spatial.uses_ensure_correct_normals = false;
|
||||
p_shader->spatial.writes_modelview_or_projection = false;
|
||||
p_shader->spatial.uses_world_coordinates = false;
|
||||
|
||||
shaders.actions_scene.render_mode_values["blend_add"] = Pair<int *, int>(&p_shader->spatial.blend_mode, Shader::Spatial::BLEND_MODE_ADD);
|
||||
shaders.actions_scene.render_mode_values["blend_mix"] = Pair<int *, int>(&p_shader->spatial.blend_mode, Shader::Spatial::BLEND_MODE_MIX);
|
||||
shaders.actions_scene.render_mode_values["blend_sub"] = Pair<int *, int>(&p_shader->spatial.blend_mode, Shader::Spatial::BLEND_MODE_SUB);
|
||||
shaders.actions_scene.render_mode_values["blend_mul"] = Pair<int *, int>(&p_shader->spatial.blend_mode, Shader::Spatial::BLEND_MODE_MUL);
|
||||
|
||||
shaders.actions_scene.render_mode_values["depth_draw_opaque"] = Pair<int *, int>(&p_shader->spatial.depth_draw_mode, Shader::Spatial::DEPTH_DRAW_OPAQUE);
|
||||
shaders.actions_scene.render_mode_values["depth_draw_always"] = Pair<int *, int>(&p_shader->spatial.depth_draw_mode, Shader::Spatial::DEPTH_DRAW_ALWAYS);
|
||||
shaders.actions_scene.render_mode_values["depth_draw_never"] = Pair<int *, int>(&p_shader->spatial.depth_draw_mode, Shader::Spatial::DEPTH_DRAW_NEVER);
|
||||
shaders.actions_scene.render_mode_values["depth_draw_alpha_prepass"] = Pair<int *, int>(&p_shader->spatial.depth_draw_mode, Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS);
|
||||
|
||||
shaders.actions_scene.render_mode_values["cull_front"] = Pair<int *, int>(&p_shader->spatial.cull_mode, Shader::Spatial::CULL_MODE_FRONT);
|
||||
shaders.actions_scene.render_mode_values["cull_back"] = Pair<int *, int>(&p_shader->spatial.cull_mode, Shader::Spatial::CULL_MODE_BACK);
|
||||
shaders.actions_scene.render_mode_values["cull_disabled"] = Pair<int *, int>(&p_shader->spatial.cull_mode, Shader::Spatial::CULL_MODE_DISABLED);
|
||||
|
||||
shaders.actions_scene.render_mode_flags["unshaded"] = &p_shader->spatial.unshaded;
|
||||
shaders.actions_scene.render_mode_flags["depth_test_disable"] = &p_shader->spatial.no_depth_test;
|
||||
|
||||
shaders.actions_scene.render_mode_flags["vertex_lighting"] = &p_shader->spatial.uses_vertex_lighting;
|
||||
|
||||
shaders.actions_scene.render_mode_flags["world_vertex_coords"] = &p_shader->spatial.uses_world_coordinates;
|
||||
|
||||
shaders.actions_scene.render_mode_flags["ensure_correct_normals"] = &p_shader->spatial.uses_ensure_correct_normals;
|
||||
|
||||
shaders.actions_scene.usage_flag_pointers["ALPHA"] = &p_shader->spatial.uses_alpha;
|
||||
shaders.actions_scene.usage_flag_pointers["ALPHA_SCISSOR"] = &p_shader->spatial.uses_alpha_scissor;
|
||||
|
||||
shaders.actions_scene.usage_flag_pointers["SSS_STRENGTH"] = &p_shader->spatial.uses_sss;
|
||||
shaders.actions_scene.usage_flag_pointers["DISCARD"] = &p_shader->spatial.uses_discard;
|
||||
shaders.actions_scene.usage_flag_pointers["SCREEN_TEXTURE"] = &p_shader->spatial.uses_screen_texture;
|
||||
shaders.actions_scene.usage_flag_pointers["DEPTH_TEXTURE"] = &p_shader->spatial.uses_depth_texture;
|
||||
shaders.actions_scene.usage_flag_pointers["TIME"] = &p_shader->spatial.uses_time;
|
||||
|
||||
// Use of any of these BUILTINS indicate the need for transformed tangents.
|
||||
// This is needed to know when to transform tangents in software skinning.
|
||||
shaders.actions_scene.usage_flag_pointers["TANGENT"] = &p_shader->spatial.uses_tangent;
|
||||
shaders.actions_scene.usage_flag_pointers["NORMALMAP"] = &p_shader->spatial.uses_tangent;
|
||||
|
||||
shaders.actions_scene.write_flag_pointers["MODELVIEW_MATRIX"] = &p_shader->spatial.writes_modelview_or_projection;
|
||||
shaders.actions_scene.write_flag_pointers["PROJECTION_MATRIX"] = &p_shader->spatial.writes_modelview_or_projection;
|
||||
shaders.actions_scene.write_flag_pointers["VERTEX"] = &p_shader->spatial.uses_vertex;
|
||||
|
||||
actions = &shaders.actions_scene;
|
||||
actions->uniforms = &p_shader->uniforms;
|
||||
|
||||
if (p_shader->spatial.uses_screen_texture && p_shader->spatial.uses_depth_texture) {
|
||||
ERR_PRINT_ONCE("Using both SCREEN_TEXTURE and DEPTH_TEXTURE is not supported in GLES2");
|
||||
}
|
||||
|
||||
if (p_shader->spatial.uses_depth_texture && !config.support_depth_texture) {
|
||||
ERR_PRINT_ONCE("Using DEPTH_TEXTURE is not permitted on this hardware, operation will fail.");
|
||||
}
|
||||
} break;
|
||||
|
||||
default: {
|
||||
return;
|
||||
} break;
|
||||
@ -1802,39 +1723,6 @@ void RasterizerStorageGLES2::_update_material(Material *p_material) {
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
bool can_cast_shadow = false;
|
||||
bool is_animated = false;
|
||||
|
||||
if (p_material->shader && p_material->shader->mode == RS::SHADER_SPATIAL) {
|
||||
if (p_material->shader->spatial.blend_mode == Shader::Spatial::BLEND_MODE_MIX &&
|
||||
(!(p_material->shader->spatial.uses_alpha && !p_material->shader->spatial.uses_alpha_scissor) || p_material->shader->spatial.depth_draw_mode == Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS)) {
|
||||
can_cast_shadow = true;
|
||||
}
|
||||
|
||||
if (p_material->shader->spatial.uses_discard && p_material->shader->uses_fragment_time) {
|
||||
is_animated = true;
|
||||
}
|
||||
|
||||
if (p_material->shader->spatial.uses_vertex && p_material->shader->uses_vertex_time) {
|
||||
is_animated = true;
|
||||
}
|
||||
|
||||
if (can_cast_shadow != p_material->can_cast_shadow_cache || is_animated != p_material->is_animated_cache) {
|
||||
p_material->can_cast_shadow_cache = can_cast_shadow;
|
||||
p_material->is_animated_cache = is_animated;
|
||||
|
||||
for (RBMap<Geometry *, int>::Element *E = p_material->geometry_owners.front(); E; E = E->next()) {
|
||||
E->key()->material_changed_notify();
|
||||
}
|
||||
|
||||
for (RBMap<RasterizerScene::InstanceBase *, int>::Element *E = p_material->instance_owners.front(); E; E = E->next()) {
|
||||
E->key()->base_changed(false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// uniforms and other things will be set in the use_material method in ShaderGLES2
|
||||
|
||||
if (p_material->shader && p_material->shader->texture_count > 0) {
|
||||
@ -4605,9 +4493,6 @@ void RasterizerStorageGLES2::initialize() {
|
||||
glGetIntegerv(GL_MAX_VIEWPORT_DIMS, config.max_viewport_dimensions);
|
||||
|
||||
shaders.copy.init();
|
||||
shaders.cubemap_filter.init();
|
||||
bool ggx_hq = GLOBAL_GET("rendering/quality/reflections/high_quality_ggx");
|
||||
shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES2::LOW_QUALITY, !ggx_hq);
|
||||
|
||||
{
|
||||
// quad for copying stuff
|
||||
|
@ -40,16 +40,13 @@
|
||||
#include "shader_gles2.h"
|
||||
|
||||
#include "shaders/copy.glsl.gen.h"
|
||||
#include "shaders/cubemap_filter.glsl.gen.h"
|
||||
|
||||
class RasterizerCanvasGLES2;
|
||||
class RasterizerSceneGLES2;
|
||||
|
||||
#define WRAPPED_GL_ACTIVE_TEXTURE storage->gl_wrapper.gl_active_texture
|
||||
class RasterizerStorageGLES2 : public RasterizerStorage {
|
||||
public:
|
||||
RasterizerCanvasGLES2 *canvas;
|
||||
RasterizerSceneGLES2 *scene;
|
||||
|
||||
static GLuint system_fbo;
|
||||
|
||||
@ -130,7 +127,6 @@ public:
|
||||
ShaderCompilerGLES2 compiler;
|
||||
|
||||
CopyShaderGLES2 copy;
|
||||
CubemapFilterShaderGLES2 cubemap_filter;
|
||||
|
||||
ShaderCompilerGLES2::IdentifierActions actions_canvas;
|
||||
ShaderCompilerGLES2::IdentifierActions actions_scene;
|
||||
|
@ -1098,158 +1098,6 @@ ShaderCompilerGLES2::ShaderCompilerGLES2() {
|
||||
actions[RS::SHADER_CANVAS_ITEM].usage_defines["isnan"] = "#define IS_NAN_USED\n";
|
||||
actions[RS::SHADER_CANVAS_ITEM].usage_defines["trunc"] = "#define TRUNC_USED\n";
|
||||
|
||||
/** SPATIAL SHADER **/
|
||||
|
||||
actions[RS::SHADER_SPATIAL].renames["WORLD_MATRIX"] = "world_transform";
|
||||
actions[RS::SHADER_SPATIAL].renames["INV_CAMERA_MATRIX"] = "camera_inverse_matrix";
|
||||
actions[RS::SHADER_SPATIAL].renames["CAMERA_MATRIX"] = "camera_matrix";
|
||||
actions[RS::SHADER_SPATIAL].renames["PROJECTION_MATRIX"] = "projection_matrix";
|
||||
actions[RS::SHADER_SPATIAL].renames["INV_PROJECTION_MATRIX"] = "projection_inverse_matrix";
|
||||
actions[RS::SHADER_SPATIAL].renames["MODELVIEW_MATRIX"] = "modelview";
|
||||
|
||||
actions[RS::SHADER_SPATIAL].renames["VIEW_INDEX"] = "view_index";
|
||||
actions[RS::SHADER_SPATIAL].renames["VIEW_MONO_LEFT"] = "0";
|
||||
actions[RS::SHADER_SPATIAL].renames["VIEW_RIGHT"] = "1";
|
||||
|
||||
actions[RS::SHADER_SPATIAL].renames["VERTEX"] = "vertex.xyz";
|
||||
actions[RS::SHADER_SPATIAL].renames["NORMAL"] = "normal";
|
||||
actions[RS::SHADER_SPATIAL].renames["TANGENT"] = "tangent";
|
||||
actions[RS::SHADER_SPATIAL].renames["BINORMAL"] = "binormal";
|
||||
actions[RS::SHADER_SPATIAL].renames["POSITION"] = "position";
|
||||
actions[RS::SHADER_SPATIAL].renames["UV"] = "uv_interp";
|
||||
actions[RS::SHADER_SPATIAL].renames["UV2"] = "uv2_interp";
|
||||
actions[RS::SHADER_SPATIAL].renames["COLOR"] = "color_interp";
|
||||
actions[RS::SHADER_SPATIAL].renames["POINT_SIZE"] = "point_size";
|
||||
// gl_InstanceID and VERTEX_ID is not available in OpenGL ES 2.0
|
||||
actions[RS::SHADER_SPATIAL].renames["INSTANCE_ID"] = "0";
|
||||
actions[RS::SHADER_SPATIAL].renames["VERTEX_ID"] = "0";
|
||||
|
||||
//builtins
|
||||
|
||||
actions[RS::SHADER_SPATIAL].renames["TIME"] = "time";
|
||||
actions[RS::SHADER_SPATIAL].renames["VIEWPORT_SIZE"] = "viewport_size";
|
||||
|
||||
actions[RS::SHADER_SPATIAL].renames["FRAGCOORD"] = "gl_FragCoord";
|
||||
actions[RS::SHADER_SPATIAL].renames["FRONT_FACING"] = "gl_FrontFacing";
|
||||
actions[RS::SHADER_SPATIAL].renames["NORMALMAP"] = "normalmap";
|
||||
actions[RS::SHADER_SPATIAL].renames["NORMALMAP_DEPTH"] = "normaldepth";
|
||||
actions[RS::SHADER_SPATIAL].renames["ALBEDO"] = "albedo";
|
||||
actions[RS::SHADER_SPATIAL].renames["ALPHA"] = "alpha";
|
||||
actions[RS::SHADER_SPATIAL].renames["METALLIC"] = "metallic";
|
||||
actions[RS::SHADER_SPATIAL].renames["SPECULAR"] = "specular";
|
||||
actions[RS::SHADER_SPATIAL].renames["ROUGHNESS"] = "roughness";
|
||||
actions[RS::SHADER_SPATIAL].renames["RIM"] = "rim";
|
||||
actions[RS::SHADER_SPATIAL].renames["RIM_TINT"] = "rim_tint";
|
||||
actions[RS::SHADER_SPATIAL].renames["CLEARCOAT"] = "clearcoat";
|
||||
actions[RS::SHADER_SPATIAL].renames["CLEARCOAT_GLOSS"] = "clearcoat_gloss";
|
||||
actions[RS::SHADER_SPATIAL].renames["ANISOTROPY"] = "anisotropy";
|
||||
actions[RS::SHADER_SPATIAL].renames["ANISOTROPY_FLOW"] = "anisotropy_flow";
|
||||
actions[RS::SHADER_SPATIAL].renames["SSS_STRENGTH"] = "sss_strength";
|
||||
actions[RS::SHADER_SPATIAL].renames["TRANSMISSION"] = "transmission";
|
||||
actions[RS::SHADER_SPATIAL].renames["AO"] = "ao";
|
||||
actions[RS::SHADER_SPATIAL].renames["AO_LIGHT_AFFECT"] = "ao_light_affect";
|
||||
actions[RS::SHADER_SPATIAL].renames["EMISSION"] = "emission";
|
||||
actions[RS::SHADER_SPATIAL].renames["POINT_COORD"] = "gl_PointCoord";
|
||||
actions[RS::SHADER_SPATIAL].renames["INSTANCE_CUSTOM"] = "instance_custom";
|
||||
actions[RS::SHADER_SPATIAL].renames["SCREEN_UV"] = "screen_uv";
|
||||
actions[RS::SHADER_SPATIAL].renames["SCREEN_TEXTURE"] = "screen_texture";
|
||||
actions[RS::SHADER_SPATIAL].renames["DEPTH_TEXTURE"] = "depth_texture";
|
||||
// Defined in GLES3, but not available in GLES2
|
||||
//actions[RS::SHADER_SPATIAL].renames["DEPTH"] = "gl_FragDepth";
|
||||
actions[RS::SHADER_SPATIAL].renames["ALPHA_SCISSOR"] = "alpha_scissor";
|
||||
actions[RS::SHADER_SPATIAL].renames["OUTPUT_IS_SRGB"] = "SHADER_IS_SRGB";
|
||||
actions[RS::SHADER_SPATIAL].renames["NODE_POSITION_WORLD"] = "world_transform[3].xyz";
|
||||
actions[RS::SHADER_SPATIAL].renames["CAMERA_POSITION_WORLD"] = "camera_matrix[3].xyz";
|
||||
actions[RS::SHADER_SPATIAL].renames["CAMERA_DIRECTION_WORLD"] = "camera_inverse_matrix[3].xyz";
|
||||
actions[RS::SHADER_SPATIAL].renames["NODE_POSITION_VIEW"] = "(camera_inverse_matrix * world_transform)[3].xyz";
|
||||
|
||||
//for light
|
||||
actions[RS::SHADER_SPATIAL].renames["VIEW"] = "view";
|
||||
actions[RS::SHADER_SPATIAL].renames["LIGHT_COLOR"] = "light_color";
|
||||
actions[RS::SHADER_SPATIAL].renames["LIGHT"] = "light";
|
||||
actions[RS::SHADER_SPATIAL].renames["ATTENUATION"] = "attenuation";
|
||||
actions[RS::SHADER_SPATIAL].renames["DIFFUSE_LIGHT"] = "diffuse_light";
|
||||
actions[RS::SHADER_SPATIAL].renames["SPECULAR_LIGHT"] = "specular_light";
|
||||
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["TANGENT"] = "#define ENABLE_TANGENT_INTERP\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["BINORMAL"] = "@TANGENT";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["RIM"] = "#define LIGHT_USE_RIM\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["RIM_TINT"] = "@RIM";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["CLEARCOAT"] = "#define LIGHT_USE_CLEARCOAT\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["CLEARCOAT_GLOSS"] = "@CLEARCOAT";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["ANISOTROPY"] = "#define LIGHT_USE_ANISOTROPY\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["ANISOTROPY_FLOW"] = "@ANISOTROPY";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["AO"] = "#define ENABLE_AO\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["AO_LIGHT_AFFECT"] = "#define ENABLE_AO\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["UV"] = "#define ENABLE_UV_INTERP\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["UV2"] = "#define ENABLE_UV2_INTERP\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["NORMALMAP"] = "#define ENABLE_NORMALMAP\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["NORMALMAP_DEPTH"] = "@NORMALMAP";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["COLOR"] = "#define ENABLE_COLOR_INTERP\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["INSTANCE_CUSTOM"] = "#define ENABLE_INSTANCE_CUSTOM\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["ALPHA_SCISSOR"] = "#define ALPHA_SCISSOR_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["POSITION"] = "#define OVERRIDE_POSITION\n";
|
||||
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["SSS_STRENGTH"] = "#define ENABLE_SSS\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["TRANSMISSION"] = "#define TRANSMISSION_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["SCREEN_TEXTURE"] = "#define SCREEN_TEXTURE_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["DEPTH_TEXTURE"] = "#define DEPTH_TEXTURE_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["SCREEN_UV"] = "#define SCREEN_UV_USED\n";
|
||||
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["DIFFUSE_LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["SPECULAR_LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n";
|
||||
|
||||
// Ported from GLES3
|
||||
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["sinh"] = "#define SINH_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["cosh"] = "#define COSH_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["tanh"] = "#define TANH_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["asinh"] = "#define ASINH_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["acosh"] = "#define ACOSH_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["atanh"] = "#define ATANH_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["determinant"] = "#define DETERMINANT_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["transpose"] = "#define TRANSPOSE_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["outerProduct"] = "#define OUTER_PRODUCT_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["round"] = "#define ROUND_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["roundEven"] = "#define ROUND_EVEN_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["inverse"] = "#define INVERSE_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["isinf"] = "#define IS_INF_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["isnan"] = "#define IS_NAN_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["trunc"] = "#define TRUNC_USED\n";
|
||||
|
||||
actions[RS::SHADER_SPATIAL].render_mode_defines["skip_vertex_transform"] = "#define SKIP_TRANSFORM_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].render_mode_defines["world_vertex_coords"] = "#define VERTEX_WORLD_COORDS_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].render_mode_defines["ensure_correct_normals"] = "#define ENSURE_CORRECT_NORMALS\n";
|
||||
// Defined in GLES3, might not be possible in GLES2 as gl_FrontFacing is not available
|
||||
//actions[RS::SHADER_SPATIAL].render_mode_defines["cull_front"] = "#define DO_SIDE_CHECK\n";
|
||||
//actions[RS::SHADER_SPATIAL].render_mode_defines["cull_disabled"] = "#define DO_SIDE_CHECK\n";
|
||||
|
||||
bool force_lambert = GLOBAL_GET("rendering/quality/shading/force_lambert_over_burley");
|
||||
|
||||
if (!force_lambert) {
|
||||
actions[RS::SHADER_SPATIAL].render_mode_defines["diffuse_burley"] = "#define DIFFUSE_BURLEY\n";
|
||||
}
|
||||
|
||||
actions[RS::SHADER_SPATIAL].render_mode_defines["diffuse_oren_nayar"] = "#define DIFFUSE_OREN_NAYAR\n";
|
||||
actions[RS::SHADER_SPATIAL].render_mode_defines["diffuse_lambert_wrap"] = "#define DIFFUSE_LAMBERT_WRAP\n";
|
||||
actions[RS::SHADER_SPATIAL].render_mode_defines["diffuse_toon"] = "#define DIFFUSE_TOON\n";
|
||||
|
||||
bool force_blinn = GLOBAL_GET("rendering/quality/shading/force_blinn_over_ggx");
|
||||
|
||||
if (!force_blinn) {
|
||||
actions[RS::SHADER_SPATIAL].render_mode_defines["specular_schlick_ggx"] = "#define SPECULAR_SCHLICK_GGX\n";
|
||||
} else {
|
||||
actions[RS::SHADER_SPATIAL].render_mode_defines["specular_schlick_ggx"] = "#define SPECULAR_BLINN\n";
|
||||
}
|
||||
|
||||
actions[RS::SHADER_SPATIAL].render_mode_defines["specular_blinn"] = "#define SPECULAR_BLINN\n";
|
||||
actions[RS::SHADER_SPATIAL].render_mode_defines["specular_phong"] = "#define SPECULAR_PHONG\n";
|
||||
actions[RS::SHADER_SPATIAL].render_mode_defines["specular_toon"] = "#define SPECULAR_TOON\n";
|
||||
actions[RS::SHADER_SPATIAL].render_mode_defines["specular_disabled"] = "#define SPECULAR_DISABLED\n";
|
||||
actions[RS::SHADER_SPATIAL].render_mode_defines["shadows_disabled"] = "#define SHADOWS_DISABLED\n";
|
||||
actions[RS::SHADER_SPATIAL].render_mode_defines["ambient_light_disabled"] = "#define AMBIENT_LIGHT_DISABLED\n";
|
||||
actions[RS::SHADER_SPATIAL].render_mode_defines["shadow_to_opacity"] = "#define USE_SHADOW_TO_OPACITY\n";
|
||||
|
||||
// No defines for particle shaders in GLES2, there are no GPU particles
|
||||
|
||||
vertex_name = "vertex";
|
||||
|
@ -6,10 +6,6 @@ if "GLES2_GLSL" in env["BUILDERS"]:
|
||||
env.GLES2_GLSL("copy.glsl")
|
||||
env.GLES2_GLSL("canvas.glsl")
|
||||
env.GLES2_GLSL("canvas_shadow.glsl")
|
||||
env.GLES2_GLSL("scene.glsl")
|
||||
env.GLES2_GLSL("cubemap_filter.glsl")
|
||||
env.GLES2_GLSL("cube_to_dp.glsl")
|
||||
env.GLES2_GLSL("effect_blur.glsl")
|
||||
env.GLES2_GLSL("tonemap.glsl")
|
||||
env.GLES2_GLSL("lens_distorted.glsl")
|
||||
env.Depends(Glob("*.glsl.gen.h"), "#gles_builders.py")
|
||||
|
@ -1,100 +0,0 @@
|
||||
/* clang-format off */
|
||||
[vertex]
|
||||
|
||||
#ifdef USE_GLES_OVER_GL
|
||||
#define lowp
|
||||
#define mediump
|
||||
#define highp
|
||||
#else
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
attribute highp vec4 vertex_attrib; // attrib:0
|
||||
/* clang-format on */
|
||||
attribute vec2 uv_in; // attrib:4
|
||||
|
||||
varying vec2 uv_interp;
|
||||
|
||||
void main() {
|
||||
uv_interp = uv_in;
|
||||
gl_Position = vertex_attrib;
|
||||
}
|
||||
|
||||
/* clang-format off */
|
||||
[fragment]
|
||||
|
||||
#ifdef USE_GLES_OVER_GL
|
||||
#define lowp
|
||||
#define mediump
|
||||
#define highp
|
||||
#else
|
||||
#if defined(USE_HIGHP_PRECISION)
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
#else
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
uniform highp samplerCube source_cube; //texunit:0
|
||||
/* clang-format on */
|
||||
varying vec2 uv_interp;
|
||||
|
||||
uniform bool z_flip;
|
||||
uniform highp float z_far;
|
||||
uniform highp float z_near;
|
||||
uniform highp float bias;
|
||||
|
||||
void main() {
|
||||
highp vec3 normal = vec3(uv_interp * 2.0 - 1.0, 0.0);
|
||||
/*
|
||||
if (z_flip) {
|
||||
normal.z = 0.5 - 0.5 * ((normal.x * normal.x) + (normal.y * normal.y));
|
||||
} else {
|
||||
normal.z = -0.5 + 0.5 * ((normal.x * normal.x) + (normal.y * normal.y));
|
||||
}
|
||||
*/
|
||||
|
||||
//normal.z = sqrt(1.0 - dot(normal.xy, normal.xy));
|
||||
//normal.xy *= 1.0 + normal.z;
|
||||
|
||||
normal.z = 0.5 - 0.5 * ((normal.x * normal.x) + (normal.y * normal.y));
|
||||
normal = normalize(normal);
|
||||
/*
|
||||
normal.z = 0.5;
|
||||
normal = normalize(normal);
|
||||
*/
|
||||
|
||||
if (!z_flip) {
|
||||
normal.z = -normal.z;
|
||||
}
|
||||
|
||||
//normal = normalize(vec3( uv_interp * 2.0 - 1.0, 1.0 ));
|
||||
float depth = textureCube(source_cube, normal).r;
|
||||
|
||||
// absolute values for direction cosines, bigger value equals closer to basis axis
|
||||
vec3 unorm = abs(normal);
|
||||
|
||||
if ((unorm.x >= unorm.y) && (unorm.x >= unorm.z)) {
|
||||
// x code
|
||||
unorm = normal.x > 0.0 ? vec3(1.0, 0.0, 0.0) : vec3(-1.0, 0.0, 0.0);
|
||||
} else if ((unorm.y > unorm.x) && (unorm.y >= unorm.z)) {
|
||||
// y code
|
||||
unorm = normal.y > 0.0 ? vec3(0.0, 1.0, 0.0) : vec3(0.0, -1.0, 0.0);
|
||||
} else if ((unorm.z > unorm.x) && (unorm.z > unorm.y)) {
|
||||
// z code
|
||||
unorm = normal.z > 0.0 ? vec3(0.0, 0.0, 1.0) : vec3(0.0, 0.0, -1.0);
|
||||
} else {
|
||||
// oh-no we messed up code
|
||||
// has to be
|
||||
unorm = vec3(1.0, 0.0, 0.0);
|
||||
}
|
||||
|
||||
float depth_fix = 1.0 / dot(normal, unorm);
|
||||
|
||||
depth = 2.0 * depth - 1.0;
|
||||
float linear_depth = 2.0 * z_near * z_far / (z_far + z_near - depth * (z_far - z_near));
|
||||
gl_FragDepth = (linear_depth * depth_fix + bias) / z_far;
|
||||
}
|
@ -1,231 +0,0 @@
|
||||
/* clang-format off */
|
||||
[vertex]
|
||||
|
||||
#ifdef USE_GLES_OVER_GL
|
||||
#define lowp
|
||||
#define mediump
|
||||
#define highp
|
||||
#else
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
#endif
|
||||
|
||||
attribute highp vec2 vertex; // attrib:0
|
||||
/* clang-format on */
|
||||
attribute highp vec2 uv; // attrib:4
|
||||
|
||||
varying highp vec2 uv_interp;
|
||||
|
||||
void main() {
|
||||
uv_interp = uv;
|
||||
gl_Position = vec4(vertex, 0, 1);
|
||||
}
|
||||
|
||||
/* clang-format off */
|
||||
[fragment]
|
||||
|
||||
// texture2DLodEXT and textureCubeLodEXT are fragment shader specific.
|
||||
// Do not copy these defines in the vertex section.
|
||||
#ifndef USE_GLES_OVER_GL
|
||||
#ifdef GL_EXT_shader_texture_lod
|
||||
#extension GL_EXT_shader_texture_lod : enable
|
||||
#define texture2DLod(img, coord, lod) texture2DLodEXT(img, coord, lod)
|
||||
#define textureCubeLod(img, coord, lod) textureCubeLodEXT(img, coord, lod)
|
||||
#endif
|
||||
#endif // !USE_GLES_OVER_GL
|
||||
|
||||
#ifdef GL_ARB_shader_texture_lod
|
||||
#extension GL_ARB_shader_texture_lod : enable
|
||||
#endif
|
||||
|
||||
#if !defined(GL_EXT_shader_texture_lod) && !defined(GL_ARB_shader_texture_lod)
|
||||
#define texture2DLod(img, coord, lod) texture2D(img, coord, lod)
|
||||
#define textureCubeLod(img, coord, lod) textureCube(img, coord, lod)
|
||||
#endif
|
||||
|
||||
#ifdef USE_GLES_OVER_GL
|
||||
#define lowp
|
||||
#define mediump
|
||||
#define highp
|
||||
#else
|
||||
#if defined(USE_HIGHP_PRECISION)
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
#else
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_SOURCE_PANORAMA
|
||||
uniform sampler2D source_panorama; //texunit:0
|
||||
#else
|
||||
uniform samplerCube source_cube; //texunit:0
|
||||
#endif
|
||||
/* clang-format on */
|
||||
|
||||
uniform int face_id;
|
||||
uniform float roughness;
|
||||
varying highp vec2 uv_interp;
|
||||
|
||||
uniform sampler2D radical_inverse_vdc_cache; // texunit:1
|
||||
|
||||
#define M_PI 3.14159265359
|
||||
|
||||
#ifdef LOW_QUALITY
|
||||
|
||||
#define SAMPLE_COUNT 64
|
||||
|
||||
#else
|
||||
|
||||
#define SAMPLE_COUNT 512
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_SOURCE_PANORAMA
|
||||
|
||||
vec4 texturePanorama(sampler2D pano, vec3 normal) {
|
||||
vec2 st = vec2(
|
||||
atan(normal.x, normal.z),
|
||||
acos(normal.y));
|
||||
|
||||
if (st.x < 0.0)
|
||||
st.x += M_PI * 2.0;
|
||||
|
||||
st /= vec2(M_PI * 2.0, M_PI);
|
||||
|
||||
return texture2DLod(pano, st, 0.0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
vec3 texelCoordToVec(vec2 uv, int faceID) {
|
||||
mat3 faceUvVectors[6];
|
||||
|
||||
// -x
|
||||
faceUvVectors[0][0] = vec3(0.0, 0.0, 1.0); // u -> +z
|
||||
faceUvVectors[0][1] = vec3(0.0, -1.0, 0.0); // v -> -y
|
||||
faceUvVectors[0][2] = vec3(-1.0, 0.0, 0.0); // -x face
|
||||
|
||||
// +x
|
||||
faceUvVectors[1][0] = vec3(0.0, 0.0, -1.0); // u -> -z
|
||||
faceUvVectors[1][1] = vec3(0.0, -1.0, 0.0); // v -> -y
|
||||
faceUvVectors[1][2] = vec3(1.0, 0.0, 0.0); // +x face
|
||||
|
||||
// -y
|
||||
faceUvVectors[2][0] = vec3(1.0, 0.0, 0.0); // u -> +x
|
||||
faceUvVectors[2][1] = vec3(0.0, 0.0, -1.0); // v -> -z
|
||||
faceUvVectors[2][2] = vec3(0.0, -1.0, 0.0); // -y face
|
||||
|
||||
// +y
|
||||
faceUvVectors[3][0] = vec3(1.0, 0.0, 0.0); // u -> +x
|
||||
faceUvVectors[3][1] = vec3(0.0, 0.0, 1.0); // v -> +z
|
||||
faceUvVectors[3][2] = vec3(0.0, 1.0, 0.0); // +y face
|
||||
|
||||
// -z
|
||||
faceUvVectors[4][0] = vec3(-1.0, 0.0, 0.0); // u -> -x
|
||||
faceUvVectors[4][1] = vec3(0.0, -1.0, 0.0); // v -> -y
|
||||
faceUvVectors[4][2] = vec3(0.0, 0.0, -1.0); // -z face
|
||||
|
||||
// +z
|
||||
faceUvVectors[5][0] = vec3(1.0, 0.0, 0.0); // u -> +x
|
||||
faceUvVectors[5][1] = vec3(0.0, -1.0, 0.0); // v -> -y
|
||||
faceUvVectors[5][2] = vec3(0.0, 0.0, 1.0); // +z face
|
||||
|
||||
// out = u * s_faceUv[0] + v * s_faceUv[1] + s_faceUv[2].
|
||||
vec3 result;
|
||||
for (int i = 0; i < 6; i++) {
|
||||
if (i == faceID) {
|
||||
result = (faceUvVectors[i][0] * uv.x) + (faceUvVectors[i][1] * uv.y) + faceUvVectors[i][2];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return normalize(result);
|
||||
}
|
||||
|
||||
vec3 ImportanceSampleGGX(vec2 Xi, float Roughness, vec3 N) {
|
||||
float a = Roughness * Roughness; // DISNEY'S ROUGHNESS [see Burley'12 siggraph]
|
||||
|
||||
// Compute distribution direction
|
||||
float Phi = 2.0 * M_PI * Xi.x;
|
||||
float CosTheta = sqrt((1.0 - Xi.y) / (1.0 + (a * a - 1.0) * Xi.y));
|
||||
float SinTheta = sqrt(1.0 - CosTheta * CosTheta);
|
||||
|
||||
// Convert to spherical direction
|
||||
vec3 H;
|
||||
H.x = SinTheta * cos(Phi);
|
||||
H.y = SinTheta * sin(Phi);
|
||||
H.z = CosTheta;
|
||||
|
||||
vec3 UpVector = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
|
||||
vec3 TangentX = normalize(cross(UpVector, N));
|
||||
vec3 TangentY = cross(N, TangentX);
|
||||
|
||||
// Tangent to world space
|
||||
return TangentX * H.x + TangentY * H.y + N * H.z;
|
||||
}
|
||||
|
||||
float radical_inverse_VdC(int i) {
|
||||
return texture2D(radical_inverse_vdc_cache, vec2(float(i) / 512.0, 0.0)).x;
|
||||
}
|
||||
|
||||
vec2 Hammersley(int i, int N) {
|
||||
return vec2(float(i) / float(N), radical_inverse_VdC(i));
|
||||
}
|
||||
|
||||
uniform bool z_flip;
|
||||
|
||||
void main() {
|
||||
vec3 color = vec3(0.0);
|
||||
|
||||
vec2 uv = (uv_interp * 2.0) - 1.0;
|
||||
vec3 N = texelCoordToVec(uv, face_id);
|
||||
|
||||
#ifdef USE_DIRECT_WRITE
|
||||
|
||||
#ifdef USE_SOURCE_PANORAMA
|
||||
|
||||
gl_FragColor = vec4(texturePanorama(source_panorama, N).rgb, 1.0);
|
||||
#else
|
||||
|
||||
gl_FragColor = vec4(textureCube(source_cube, N).rgb, 1.0);
|
||||
#endif //USE_SOURCE_PANORAMA
|
||||
|
||||
#else
|
||||
|
||||
vec4 sum = vec4(0.0);
|
||||
|
||||
for (int sample_num = 0; sample_num < SAMPLE_COUNT; sample_num++) {
|
||||
vec2 xi = Hammersley(sample_num, SAMPLE_COUNT);
|
||||
|
||||
vec3 H = ImportanceSampleGGX(xi, roughness, N);
|
||||
vec3 V = N;
|
||||
vec3 L = (2.0 * dot(V, H) * H - V);
|
||||
|
||||
float NdotL = clamp(dot(N, L), 0.0, 1.0);
|
||||
|
||||
if (NdotL > 0.0) {
|
||||
|
||||
#ifdef USE_SOURCE_PANORAMA
|
||||
vec3 val = texturePanorama(source_panorama, L).rgb;
|
||||
#else
|
||||
vec3 val = textureCubeLod(source_cube, L, 0.0).rgb;
|
||||
#endif
|
||||
//mix using Linear, to approximate high end back-end
|
||||
val = mix(pow((val + vec3(0.055)) * (1.0 / (1.0 + 0.055)), vec3(2.4)), val * (1.0 / 12.92), vec3(lessThan(val, vec3(0.04045))));
|
||||
|
||||
sum.rgb += val * NdotL;
|
||||
|
||||
sum.a += NdotL;
|
||||
}
|
||||
}
|
||||
|
||||
sum /= sum.a;
|
||||
|
||||
vec3 a = vec3(0.055);
|
||||
sum.rgb = mix((vec3(1.0) + a) * pow(sum.rgb, vec3(1.0 / 2.4)) - a, 12.92 * sum.rgb, vec3(lessThan(sum.rgb, vec3(0.0031308))));
|
||||
|
||||
gl_FragColor = vec4(sum.rgb, 1.0);
|
||||
#endif
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -651,7 +651,7 @@ void ArrayMesh::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
if (surfaces[i].is_2d) {
|
||||
p_list->push_back(PropertyInfo(Variant::OBJECT, "surface_" + itos(i + 1) + "/material", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,CanvasItemMaterial", PROPERTY_USAGE_EDITOR));
|
||||
} else {
|
||||
p_list->push_back(PropertyInfo(Variant::OBJECT, "surface_" + itos(i + 1) + "/material", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,SpatialMaterial", PROPERTY_USAGE_EDITOR));
|
||||
p_list->push_back(PropertyInfo(Variant::OBJECT, "surface_" + itos(i + 1) + "/material", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial", PROPERTY_USAGE_EDITOR));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -893,7 +893,6 @@ public:
|
||||
|
||||
virtual RasterizerStorage *get_storage() = 0;
|
||||
virtual RasterizerCanvas *get_canvas() = 0;
|
||||
virtual RasterizerScene *get_scene() = 0;
|
||||
|
||||
virtual void set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter = true) = 0;
|
||||
virtual void set_shader_time_scale(float p_scale) = 0;
|
||||
|
@ -224,7 +224,6 @@ RenderingServerRaster::RenderingServerRaster() {
|
||||
RSG::rasterizer = Rasterizer::create();
|
||||
RSG::storage = RSG::rasterizer->get_storage();
|
||||
RSG::canvas_render = RSG::rasterizer->get_canvas();
|
||||
RSG::scene_render = RSG::rasterizer->get_scene();
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
black_margin[i] = 0;
|
||||
|
@ -51,165 +51,6 @@ static ShaderLanguage::BuiltInInfo constt(ShaderLanguage::DataType p_type) {
|
||||
ShaderTypes::ShaderTypes() {
|
||||
singleton = this;
|
||||
|
||||
/*************** SPATIAL ***********************/
|
||||
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["global"].built_ins["TIME"] = constt(ShaderLanguage::TYPE_FLOAT);
|
||||
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["VERTEX"] = ShaderLanguage::TYPE_VEC3;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["NORMAL"] = ShaderLanguage::TYPE_VEC3;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["TANGENT"] = ShaderLanguage::TYPE_VEC3;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["BINORMAL"] = ShaderLanguage::TYPE_VEC3;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["POSITION"] = ShaderLanguage::TYPE_VEC4;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["UV"] = ShaderLanguage::TYPE_VEC2;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["UV2"] = ShaderLanguage::TYPE_VEC2;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["COLOR"] = ShaderLanguage::TYPE_VEC4;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["POINT_SIZE"] = ShaderLanguage::TYPE_FLOAT;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["INSTANCE_ID"] = constt(ShaderLanguage::TYPE_INT);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["INSTANCE_CUSTOM"] = constt(ShaderLanguage::TYPE_VEC4);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["VERTEX_ID"] = constt(ShaderLanguage::TYPE_INT);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["ROUGHNESS"] = ShaderLanguage::TYPE_FLOAT;
|
||||
|
||||
//builtins
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["WORLD_MATRIX"] = ShaderLanguage::TYPE_MAT4;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["INV_CAMERA_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["CAMERA_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["PROJECTION_MATRIX"] = ShaderLanguage::TYPE_MAT4;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["MODELVIEW_MATRIX"] = ShaderLanguage::TYPE_MAT4;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["INV_PROJECTION_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["VIEW_INDEX"] = constt(ShaderLanguage::TYPE_INT);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["VIEW_MONO_LEFT"] = constt(ShaderLanguage::TYPE_INT);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["VIEW_RIGHT"] = constt(ShaderLanguage::TYPE_INT);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["VIEWPORT_SIZE"] = constt(ShaderLanguage::TYPE_VEC2);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["OUTPUT_IS_SRGB"] = constt(ShaderLanguage::TYPE_BOOL);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["NODE_POSITION_WORLD"] = ShaderLanguage::TYPE_VEC3;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["CAMERA_POSITION_WORLD"] = ShaderLanguage::TYPE_VEC3;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["CAMERA_DIRECTION_WORLD"] = ShaderLanguage::TYPE_VEC3;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["NODE_POSITION_VIEW"] = ShaderLanguage::TYPE_VEC3;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["vertex"].main_function = true;
|
||||
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["VERTEX"] = constt(ShaderLanguage::TYPE_VEC3);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["FRAGCOORD"] = constt(ShaderLanguage::TYPE_VEC4);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["FRONT_FACING"] = constt(ShaderLanguage::TYPE_BOOL);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["NORMAL"] = ShaderLanguage::TYPE_VEC3;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["TANGENT"] = ShaderLanguage::TYPE_VEC3;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["BINORMAL"] = ShaderLanguage::TYPE_VEC3;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["VIEW"] = constt(ShaderLanguage::TYPE_VEC3);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["NORMALMAP"] = ShaderLanguage::TYPE_VEC3;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["NORMALMAP_DEPTH"] = ShaderLanguage::TYPE_FLOAT;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["UV"] = constt(ShaderLanguage::TYPE_VEC2);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["UV2"] = constt(ShaderLanguage::TYPE_VEC2);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["COLOR"] = constt(ShaderLanguage::TYPE_VEC4);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["ALBEDO"] = ShaderLanguage::TYPE_VEC3;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["ALPHA"] = ShaderLanguage::TYPE_FLOAT;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["METALLIC"] = ShaderLanguage::TYPE_FLOAT;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["SPECULAR"] = ShaderLanguage::TYPE_FLOAT;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["ROUGHNESS"] = ShaderLanguage::TYPE_FLOAT;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["RIM"] = ShaderLanguage::TYPE_FLOAT;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["RIM_TINT"] = ShaderLanguage::TYPE_FLOAT;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["CLEARCOAT"] = ShaderLanguage::TYPE_FLOAT;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["CLEARCOAT_GLOSS"] = ShaderLanguage::TYPE_FLOAT;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["ANISOTROPY"] = ShaderLanguage::TYPE_FLOAT;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["ANISOTROPY_FLOW"] = ShaderLanguage::TYPE_VEC2;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["SSS_STRENGTH"] = ShaderLanguage::TYPE_FLOAT;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["TRANSMISSION"] = ShaderLanguage::TYPE_VEC3;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["AO"] = ShaderLanguage::TYPE_FLOAT;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["AO_LIGHT_AFFECT"] = ShaderLanguage::TYPE_FLOAT;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["EMISSION"] = ShaderLanguage::TYPE_VEC3;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["SCREEN_TEXTURE"] = ShaderLanguage::TYPE_SAMPLER2D;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["DEPTH_TEXTURE"] = ShaderLanguage::TYPE_SAMPLER2D;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["DEPTH"] = ShaderLanguage::TYPE_FLOAT;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["SCREEN_UV"] = ShaderLanguage::TYPE_VEC2;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["POINT_COORD"] = constt(ShaderLanguage::TYPE_VEC2);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["ALPHA_SCISSOR"] = ShaderLanguage::TYPE_FLOAT;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["VIEW_INDEX"] = constt(ShaderLanguage::TYPE_INT);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["VIEW_MONO_LEFT"] = constt(ShaderLanguage::TYPE_INT);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["VIEW_RIGHT"] = constt(ShaderLanguage::TYPE_INT);
|
||||
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["OUTPUT_IS_SRGB"] = constt(ShaderLanguage::TYPE_BOOL);
|
||||
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["WORLD_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["INV_CAMERA_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["CAMERA_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["PROJECTION_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["INV_PROJECTION_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["VIEWPORT_SIZE"] = constt(ShaderLanguage::TYPE_VEC2);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["NODE_POSITION_WORLD"] = ShaderLanguage::TYPE_VEC3;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["CAMERA_POSITION_WORLD"] = ShaderLanguage::TYPE_VEC3;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["CAMERA_DIRECTION_WORLD"] = ShaderLanguage::TYPE_VEC3;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["NODE_POSITION_VIEW"] = ShaderLanguage::TYPE_VEC3;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].can_discard = true;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].main_function = true;
|
||||
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["WORLD_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["INV_CAMERA_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["CAMERA_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["PROJECTION_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["INV_PROJECTION_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["VIEWPORT_SIZE"] = constt(ShaderLanguage::TYPE_VEC2);
|
||||
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["FRAGCOORD"] = constt(ShaderLanguage::TYPE_VEC4);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["NORMAL"] = constt(ShaderLanguage::TYPE_VEC3);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["UV"] = constt(ShaderLanguage::TYPE_VEC2);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["UV2"] = constt(ShaderLanguage::TYPE_VEC2);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["VIEW"] = constt(ShaderLanguage::TYPE_VEC3);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["LIGHT"] = constt(ShaderLanguage::TYPE_VEC3);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["LIGHT_COLOR"] = constt(ShaderLanguage::TYPE_VEC3);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["ATTENUATION"] = constt(ShaderLanguage::TYPE_VEC3);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["ALBEDO"] = constt(ShaderLanguage::TYPE_VEC3);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["TRANSMISSION"] = constt(ShaderLanguage::TYPE_VEC3);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["METALLIC"] = constt(ShaderLanguage::TYPE_FLOAT);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["ROUGHNESS"] = constt(ShaderLanguage::TYPE_FLOAT);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["DIFFUSE_LIGHT"] = ShaderLanguage::TYPE_VEC3;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["SPECULAR_LIGHT"] = ShaderLanguage::TYPE_VEC3;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["OUTPUT_IS_SRGB"] = constt(ShaderLanguage::TYPE_BOOL);
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["ALPHA"] = ShaderLanguage::TYPE_FLOAT;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["light"].can_discard = true;
|
||||
shader_modes[RS::SHADER_SPATIAL].functions["light"].main_function = true;
|
||||
|
||||
//order used puts first enum mode (default) first
|
||||
shader_modes[RS::SHADER_SPATIAL].modes.push_back("blend_mix");
|
||||
shader_modes[RS::SHADER_SPATIAL].modes.push_back("blend_add");
|
||||
shader_modes[RS::SHADER_SPATIAL].modes.push_back("blend_sub");
|
||||
shader_modes[RS::SHADER_SPATIAL].modes.push_back("blend_mul");
|
||||
|
||||
shader_modes[RS::SHADER_SPATIAL].modes.push_back("depth_draw_opaque");
|
||||
shader_modes[RS::SHADER_SPATIAL].modes.push_back("depth_draw_always");
|
||||
shader_modes[RS::SHADER_SPATIAL].modes.push_back("depth_draw_never");
|
||||
shader_modes[RS::SHADER_SPATIAL].modes.push_back("depth_draw_alpha_prepass");
|
||||
|
||||
shader_modes[RS::SHADER_SPATIAL].modes.push_back("depth_test_disable");
|
||||
|
||||
shader_modes[RS::SHADER_SPATIAL].modes.push_back("cull_back");
|
||||
shader_modes[RS::SHADER_SPATIAL].modes.push_back("cull_front");
|
||||
shader_modes[RS::SHADER_SPATIAL].modes.push_back("cull_disabled");
|
||||
|
||||
shader_modes[RS::SHADER_SPATIAL].modes.push_back("unshaded");
|
||||
|
||||
shader_modes[RS::SHADER_SPATIAL].modes.push_back("diffuse_lambert");
|
||||
shader_modes[RS::SHADER_SPATIAL].modes.push_back("diffuse_lambert_wrap");
|
||||
shader_modes[RS::SHADER_SPATIAL].modes.push_back("diffuse_oren_nayar");
|
||||
shader_modes[RS::SHADER_SPATIAL].modes.push_back("diffuse_burley");
|
||||
shader_modes[RS::SHADER_SPATIAL].modes.push_back("diffuse_toon");
|
||||
|
||||
shader_modes[RS::SHADER_SPATIAL].modes.push_back("specular_schlick_ggx");
|
||||
shader_modes[RS::SHADER_SPATIAL].modes.push_back("specular_blinn");
|
||||
shader_modes[RS::SHADER_SPATIAL].modes.push_back("specular_phong");
|
||||
shader_modes[RS::SHADER_SPATIAL].modes.push_back("specular_toon");
|
||||
shader_modes[RS::SHADER_SPATIAL].modes.push_back("specular_disabled");
|
||||
|
||||
shader_modes[RS::SHADER_SPATIAL].modes.push_back("skip_vertex_transform");
|
||||
shader_modes[RS::SHADER_SPATIAL].modes.push_back("world_vertex_coords");
|
||||
shader_modes[RS::SHADER_SPATIAL].modes.push_back("ensure_correct_normals");
|
||||
|
||||
shader_modes[RS::SHADER_SPATIAL].modes.push_back("shadows_disabled");
|
||||
shader_modes[RS::SHADER_SPATIAL].modes.push_back("ambient_light_disabled");
|
||||
shader_modes[RS::SHADER_SPATIAL].modes.push_back("shadow_to_opacity");
|
||||
|
||||
shader_modes[RS::SHADER_SPATIAL].modes.push_back("vertex_lighting");
|
||||
|
||||
shader_modes[RS::SHADER_SPATIAL].modes.push_back("async_visible");
|
||||
shader_modes[RS::SHADER_SPATIAL].modes.push_back("async_hidden");
|
||||
|
||||
/************ CANVAS ITEM **************************/
|
||||
|
||||
shader_modes[RS::SHADER_CANVAS_ITEM].functions["global"].built_ins["TIME"] = constt(ShaderLanguage::TYPE_FLOAT);
|
||||
|
@ -1617,7 +1617,6 @@ void RenderingServer::_bind_methods() {
|
||||
BIND_ENUM_CONSTANT(TEXTURE_FLAG_USED_FOR_STREAMING);
|
||||
BIND_ENUM_CONSTANT(TEXTURE_FLAGS_DEFAULT);
|
||||
|
||||
BIND_ENUM_CONSTANT(SHADER_SPATIAL);
|
||||
BIND_ENUM_CONSTANT(SHADER_CANVAS_ITEM);
|
||||
BIND_ENUM_CONSTANT(SHADER_PARTICLES);
|
||||
BIND_ENUM_CONSTANT(SHADER_MAX);
|
||||
|
@ -179,8 +179,6 @@ public:
|
||||
/* SHADER API */
|
||||
|
||||
enum ShaderMode {
|
||||
|
||||
SHADER_SPATIAL,
|
||||
SHADER_CANVAS_ITEM,
|
||||
SHADER_PARTICLES,
|
||||
SHADER_MAX
|
||||
|
Loading…
Reference in New Issue
Block a user