-Fixed SCREEN_TEXTURE and other related 2D shader parameters.
-Fixded BackBuffercopy object
This commit is contained in:
parent
90592ccf03
commit
3ce046ee0c
28 changed files with 200 additions and 78 deletions
|
@ -28,10 +28,10 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
#include "rasterizer_canvas_gles3.h"
|
||||
#include "servers/visual/visual_server_raster.h"
|
||||
|
||||
#include "global_config.h"
|
||||
#include "os/os.h"
|
||||
#include "rasterizer_scene_gles3.h"
|
||||
#include "servers/visual/visual_server_raster.h"
|
||||
#ifndef GLES_OVER_GL
|
||||
#define glClearDepth glClearDepthf
|
||||
#endif
|
||||
|
@ -172,6 +172,11 @@ void RasterizerCanvasGLES3::canvas_begin() {
|
|||
state.canvas_shader.set_uniform(CanvasShaderGLES3::FINAL_MODULATE, Color(1, 1, 1, 1));
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES3::MODELVIEW_MATRIX, Transform2D());
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES3::EXTRA_MATRIX, Transform2D());
|
||||
if (storage->frame.current_rt) {
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES3::SCREEN_PIXEL_SIZE, Vector2(1.0 / storage->frame.current_rt->width, 1.0 / storage->frame.current_rt->height));
|
||||
} else {
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES3::SCREEN_PIXEL_SIZE, Vector2(1.0, 1.0));
|
||||
}
|
||||
|
||||
//state.canvas_shader.set_uniform(CanvasShaderGLES3::PROJECTION_MATRIX,state.vp);
|
||||
//state.canvas_shader.set_uniform(CanvasShaderGLES3::MODELVIEW_MATRIX,Transform());
|
||||
|
@ -282,7 +287,11 @@ void RasterizerCanvasGLES3::_set_texture_rect_mode(bool p_enable, bool p_ninepat
|
|||
state.canvas_shader.set_uniform(CanvasShaderGLES3::FINAL_MODULATE, state.canvas_item_modulate);
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES3::MODELVIEW_MATRIX, state.final_transform);
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES3::EXTRA_MATRIX, state.extra_matrix);
|
||||
|
||||
if (storage->frame.current_rt) {
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES3::SCREEN_PIXEL_SIZE, Vector2(1.0 / storage->frame.current_rt->width, 1.0 / storage->frame.current_rt->height));
|
||||
} else {
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES3::SCREEN_PIXEL_SIZE, Vector2(1.0, 1.0));
|
||||
}
|
||||
state.using_texture_rect = p_enable;
|
||||
state.using_ninepatch = p_ninepatch;
|
||||
}
|
||||
|
@ -822,6 +831,78 @@ void RasterizerGLES2::_canvas_item_setup_shader_params(ShaderMaterial *material,
|
|||
|
||||
#endif
|
||||
|
||||
void RasterizerCanvasGLES3::_copy_texscreen(const Rect2 &p_rect) {
|
||||
|
||||
state.canvas_texscreen_used = true;
|
||||
//blur diffuse into effect mipmaps using separatable convolution
|
||||
//storage->shaders.copy.set_conditional(CopyShaderGLES3::GAUSSIAN_HORIZONTAL,true);
|
||||
|
||||
Vector2 wh(storage->frame.current_rt->width, storage->frame.current_rt->height);
|
||||
|
||||
Color blur_section(p_rect.position.x / wh.x, p_rect.position.y / wh.y, p_rect.size.x / wh.x, p_rect.size.y / wh.y);
|
||||
|
||||
if (p_rect != Rect2()) {
|
||||
|
||||
scene_render->state.effect_blur_shader.set_conditional(EffectBlurShaderGLES3::USE_BLUR_SECTION, true);
|
||||
storage->shaders.copy.set_conditional(CopyShaderGLES3::USE_COPY_SECTION, true);
|
||||
}
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->effects.mip_maps[0].sizes[0].fbo);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->color);
|
||||
|
||||
storage->shaders.copy.bind();
|
||||
storage->shaders.copy.set_uniform(CopyShaderGLES3::COPY_SECTION, blur_section);
|
||||
|
||||
scene_render->_copy_screen();
|
||||
|
||||
for (int i = 0; i < storage->frame.current_rt->effects.mip_maps[1].sizes.size(); i++) {
|
||||
|
||||
int vp_w = storage->frame.current_rt->effects.mip_maps[1].sizes[i].width;
|
||||
int vp_h = storage->frame.current_rt->effects.mip_maps[1].sizes[i].height;
|
||||
glViewport(0, 0, vp_w, vp_h);
|
||||
//horizontal pass
|
||||
scene_render->state.effect_blur_shader.set_conditional(EffectBlurShaderGLES3::GAUSSIAN_HORIZONTAL, true);
|
||||
scene_render->state.effect_blur_shader.bind();
|
||||
scene_render->state.effect_blur_shader.set_uniform(EffectBlurShaderGLES3::PIXEL_SIZE, Vector2(1.0 / vp_w, 1.0 / vp_h));
|
||||
scene_render->state.effect_blur_shader.set_uniform(EffectBlurShaderGLES3::LOD, float(i));
|
||||
scene_render->state.effect_blur_shader.set_uniform(EffectBlurShaderGLES3::BLUR_SECTION, blur_section);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->effects.mip_maps[0].color); //previous level, since mipmaps[0] starts one level bigger
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->effects.mip_maps[1].sizes[i].fbo);
|
||||
|
||||
scene_render->_copy_screen();
|
||||
|
||||
scene_render->state.effect_blur_shader.set_conditional(EffectBlurShaderGLES3::GAUSSIAN_HORIZONTAL, false);
|
||||
|
||||
//vertical pass
|
||||
scene_render->state.effect_blur_shader.set_conditional(EffectBlurShaderGLES3::GAUSSIAN_VERTICAL, true);
|
||||
scene_render->state.effect_blur_shader.bind();
|
||||
scene_render->state.effect_blur_shader.set_uniform(EffectBlurShaderGLES3::PIXEL_SIZE, Vector2(1.0 / vp_w, 1.0 / vp_h));
|
||||
scene_render->state.effect_blur_shader.set_uniform(EffectBlurShaderGLES3::LOD, float(i));
|
||||
scene_render->state.effect_blur_shader.set_uniform(EffectBlurShaderGLES3::BLUR_SECTION, blur_section);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->effects.mip_maps[1].color);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->effects.mip_maps[0].sizes[i + 1].fbo); //next level, since mipmaps[0] starts one level bigger
|
||||
|
||||
scene_render->_copy_screen();
|
||||
|
||||
scene_render->state.effect_blur_shader.set_conditional(EffectBlurShaderGLES3::GAUSSIAN_VERTICAL, false);
|
||||
}
|
||||
|
||||
scene_render->state.effect_blur_shader.set_conditional(EffectBlurShaderGLES3::USE_BLUR_SECTION, false);
|
||||
storage->shaders.copy.set_conditional(CopyShaderGLES3::USE_COPY_SECTION, false);
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->fbo); //back to front
|
||||
glViewport(0, 0, storage->frame.current_rt->width, storage->frame.current_rt->height);
|
||||
state.canvas_shader.bind(); //back to canvas
|
||||
|
||||
if (state.using_texture_rect) {
|
||||
state.using_texture_rect = false;
|
||||
_set_texture_rect_mode(state.using_texture_rect, state.using_ninepatch);
|
||||
}
|
||||
}
|
||||
|
||||
void RasterizerCanvasGLES3::canvas_render_items(Item *p_item_list, int p_z, const Color &p_modulate, Light *p_light) {
|
||||
|
||||
Item *current_clip = NULL;
|
||||
|
@ -875,44 +956,17 @@ void RasterizerCanvasGLES3::canvas_render_items(Item *p_item_list, int p_z, cons
|
|||
glDisable(GL_SCISSOR_TEST);
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
if (ci->copy_back_buffer && framebuffer.active && framebuffer.scale==1) {
|
||||
|
||||
Rect2 rect;
|
||||
int x,y;
|
||||
if (ci->copy_back_buffer) {
|
||||
|
||||
if (ci->copy_back_buffer->full) {
|
||||
|
||||
x = viewport.x;
|
||||
y = window_size.height-(viewport.height+viewport.y);
|
||||
_copy_texscreen(Rect2());
|
||||
} else {
|
||||
x = viewport.x+ci->copy_back_buffer->screen_rect.pos.x;
|
||||
y = window_size.height-(viewport.y+ci->copy_back_buffer->screen_rect.pos.y+ci->copy_back_buffer->screen_rect.size.y);
|
||||
_copy_texscreen(ci->copy_back_buffer->rect);
|
||||
}
|
||||
glActiveTexture(GL_TEXTURE0+max_texture_units-1);
|
||||
glBindTexture(GL_TEXTURE_2D,framebuffer.sample_color);
|
||||
|
||||
#ifdef GLEW_ENABLED
|
||||
if (current_rt) {
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT0);
|
||||
} else {
|
||||
glReadBuffer(GL_BACK);
|
||||
}
|
||||
#endif
|
||||
if (current_rt) {
|
||||
glCopyTexSubImage2D(GL_TEXTURE_2D,0,viewport.x,viewport.y,viewport.x,viewport.y,viewport.width,viewport.height);
|
||||
//window_size.height-(viewport.height+viewport.y)
|
||||
} else {
|
||||
glCopyTexSubImage2D(GL_TEXTURE_2D,0,x,y,x,y,viewport.width,viewport.height);
|
||||
}
|
||||
|
||||
canvas_texscreen_used=true;
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//begin rect
|
||||
Item *material_owner = ci->material_owner ? ci->material_owner : ci;
|
||||
|
||||
|
@ -934,6 +988,11 @@ void RasterizerCanvasGLES3::canvas_render_items(Item *p_item_list, int p_z, cons
|
|||
|
||||
if (shader_ptr && shader_ptr != shader_cache) {
|
||||
|
||||
if (shader_ptr->canvas_item.uses_screen_texture && !state.canvas_texscreen_used) {
|
||||
//copy if not copied before
|
||||
_copy_texscreen(Rect2());
|
||||
}
|
||||
|
||||
state.canvas_shader.set_custom_shader(shader_ptr->custom_code_id);
|
||||
state.canvas_shader.bind();
|
||||
|
||||
|
@ -1046,7 +1105,11 @@ void RasterizerCanvasGLES3::canvas_render_items(Item *p_item_list, int p_z, cons
|
|||
state.canvas_shader.set_uniform(CanvasShaderGLES3::FINAL_MODULATE, state.canvas_item_modulate);
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES3::MODELVIEW_MATRIX, state.final_transform);
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES3::EXTRA_MATRIX, state.extra_matrix);
|
||||
|
||||
if (storage->frame.current_rt) {
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES3::SCREEN_PIXEL_SIZE, Vector2(1.0 / storage->frame.current_rt->width, 1.0 / storage->frame.current_rt->height));
|
||||
} else {
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES3::SCREEN_PIXEL_SIZE, Vector2(1.0, 1.0));
|
||||
}
|
||||
if (unshaded || (state.canvas_item_modulate.a > 0.001 && (!shader_cache || shader_cache->canvas_item.light_mode != RasterizerStorageGLES3::Shader::CanvasItem::LIGHT_MODE_LIGHT_ONLY) && !ci->light_masked))
|
||||
_canvas_item_render_commands(ci, current_clip, reclip);
|
||||
|
||||
|
@ -1376,6 +1439,12 @@ void RasterizerCanvasGLES3::reset_canvas() {
|
|||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
|
||||
//use for reading from screen
|
||||
if (storage->frame.current_rt) {
|
||||
glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 3);
|
||||
glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->effects.mip_maps[0].color);
|
||||
}
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, storage->resources.white_tex);
|
||||
|
||||
|
@ -1543,7 +1612,7 @@ void RasterizerCanvasGLES3::initialize() {
|
|||
glBindBuffer(GL_UNIFORM_BUFFER, 0);
|
||||
|
||||
state.canvas_shader.init();
|
||||
state.canvas_shader.set_base_material_tex_index(1);
|
||||
state.canvas_shader.set_base_material_tex_index(2);
|
||||
state.canvas_shadow_shader.init();
|
||||
|
||||
state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_RGBA_SHADOWS, storage->config.use_rgba_2d_shadows);
|
||||
|
|
|
@ -34,6 +34,8 @@
|
|||
#include "servers/visual/rasterizer.h"
|
||||
#include "shaders/canvas_shadow.glsl.gen.h"
|
||||
|
||||
class RasterizerSceneGLES3;
|
||||
|
||||
class RasterizerCanvasGLES3 : public RasterizerCanvas {
|
||||
public:
|
||||
struct CanvasItemUBO {
|
||||
|
@ -42,6 +44,8 @@ public:
|
|||
float time;
|
||||
};
|
||||
|
||||
RasterizerSceneGLES3 *scene_render;
|
||||
|
||||
struct Data {
|
||||
|
||||
GLuint canvas_quad_vertices;
|
||||
|
@ -118,6 +122,7 @@ public:
|
|||
_FORCE_INLINE_ void _draw_gui_primitive(int p_points, const Vector2 *p_vertices, const Color *p_colors, const Vector2 *p_uvs);
|
||||
_FORCE_INLINE_ void _draw_polygon(const int *p_indices, int p_index_count, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor);
|
||||
_FORCE_INLINE_ void _canvas_item_render_commands(Item *p_item, Item *current_clip, bool &reclip);
|
||||
_FORCE_INLINE_ void _copy_texscreen(const Rect2 &p_rect);
|
||||
|
||||
virtual void canvas_render_items(Item *p_item_list, int p_z, const Color &p_modulate, Light *p_light);
|
||||
virtual void canvas_debug_viewport_shadows(Light *p_lights_with_shadow);
|
||||
|
|
|
@ -412,6 +412,7 @@ RasterizerGLES3::RasterizerGLES3() {
|
|||
canvas = memnew(RasterizerCanvasGLES3);
|
||||
scene = memnew(RasterizerSceneGLES3);
|
||||
canvas->storage = storage;
|
||||
canvas->scene_render = scene;
|
||||
storage->canvas = canvas;
|
||||
scene->storage = storage;
|
||||
storage->scene = scene;
|
||||
|
|
|
@ -1445,6 +1445,8 @@ void RasterizerStorageGLES3::_update_shader(Shader *p_shader) const {
|
|||
|
||||
p_shader->canvas_item.light_mode = Shader::CanvasItem::LIGHT_MODE_NORMAL;
|
||||
p_shader->canvas_item.blend_mode = Shader::CanvasItem::BLEND_MODE_MIX;
|
||||
p_shader->canvas_item.uses_screen_texture = false;
|
||||
p_shader->canvas_item.uses_screen_uv = false;
|
||||
|
||||
shaders.actions_canvas.render_mode_values["blend_add"] = Pair<int *, int>(&p_shader->canvas_item.blend_mode, Shader::CanvasItem::BLEND_MODE_ADD);
|
||||
shaders.actions_canvas.render_mode_values["blend_mix"] = Pair<int *, int>(&p_shader->canvas_item.blend_mode, Shader::CanvasItem::BLEND_MODE_MIX);
|
||||
|
@ -1455,6 +1457,10 @@ void RasterizerStorageGLES3::_update_shader(Shader *p_shader) const {
|
|||
shaders.actions_canvas.render_mode_values["unshaded"] = Pair<int *, int>(&p_shader->canvas_item.light_mode, Shader::CanvasItem::LIGHT_MODE_UNSHADED);
|
||||
shaders.actions_canvas.render_mode_values["light_only"] = Pair<int *, int>(&p_shader->canvas_item.light_mode, Shader::CanvasItem::LIGHT_MODE_LIGHT_ONLY);
|
||||
|
||||
shaders.actions_canvas.usage_flag_pointers["SCREEN_UV"] = &p_shader->canvas_item.uses_screen_uv;
|
||||
shaders.actions_canvas.usage_flag_pointers["SCREEN_PIXEL_SIZE"] = &p_shader->canvas_item.uses_screen_uv;
|
||||
shaders.actions_canvas.usage_flag_pointers["SCREEN_TEXTURE"] = &p_shader->canvas_item.uses_screen_texture;
|
||||
|
||||
actions = &shaders.actions_canvas;
|
||||
actions->uniforms = &p_shader->uniforms;
|
||||
|
||||
|
|
|
@ -401,6 +401,8 @@ public:
|
|||
};
|
||||
|
||||
int light_mode;
|
||||
bool uses_screen_texture;
|
||||
bool uses_screen_uv;
|
||||
|
||||
} canvas_item;
|
||||
|
||||
|
|
|
@ -680,7 +680,8 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() {
|
|||
actions[VS::SHADER_CANVAS_ITEM].renames["TEXTURE_PIXEL_SIZE"] = "color_texpixel_size";
|
||||
actions[VS::SHADER_CANVAS_ITEM].renames["SCREEN_UV"] = "screen_uv";
|
||||
actions[VS::SHADER_CANVAS_ITEM].renames["SCREEN_TEXTURE"] = "screen_texture";
|
||||
actions[VS::SHADER_CANVAS_ITEM].renames["POSITION"] = "(gl_FragCoord.xy)";
|
||||
actions[VS::SHADER_CANVAS_ITEM].renames["SCREEN_PIXEL_SIZE"] = "screen_pixel_size";
|
||||
actions[VS::SHADER_CANVAS_ITEM].renames["FRAGCOORD"] = "gl_FragCoord";
|
||||
actions[VS::SHADER_CANVAS_ITEM].renames["POINT_COORD"] = "gl_PointCoord";
|
||||
|
||||
actions[VS::SHADER_CANVAS_ITEM].renames["LIGHT_VEC"] = "light_vec";
|
||||
|
@ -694,6 +695,7 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() {
|
|||
actions[VS::SHADER_CANVAS_ITEM].usage_defines["COLOR"] = "#define COLOR_USED\n";
|
||||
actions[VS::SHADER_CANVAS_ITEM].usage_defines["SCREEN_TEXTURE"] = "#define SCREEN_TEXTURE_USED\n";
|
||||
actions[VS::SHADER_CANVAS_ITEM].usage_defines["SCREEN_UV"] = "#define SCREEN_UV_USED\n";
|
||||
actions[VS::SHADER_CANVAS_ITEM].usage_defines["SCREEN_PIXEL_SIZE"] = "@SCREEN_UV";
|
||||
actions[VS::SHADER_CANVAS_ITEM].usage_defines["NORMAL"] = "#define NORMAL_USED\n";
|
||||
actions[VS::SHADER_CANVAS_ITEM].usage_defines["NORMALMAP"] = "#define NORMALMAP_USED\n";
|
||||
actions[VS::SHADER_CANVAS_ITEM].usage_defines["SHADOW_COLOR"] = "#define SHADOW_COLOR_USED\n";
|
||||
|
|
|
@ -289,16 +289,17 @@ ShaderGLES3::Version *ShaderGLES3::get_current_version() {
|
|||
#endif
|
||||
|
||||
strings.push_back(vertex_code0.get_data());
|
||||
|
||||
if (cc) {
|
||||
code_globals = cc->vertex_globals.ascii();
|
||||
strings.push_back(code_globals.get_data());
|
||||
material_string = cc->uniforms.ascii();
|
||||
strings.push_back(material_string.get_data());
|
||||
}
|
||||
|
||||
strings.push_back(vertex_code1.get_data());
|
||||
|
||||
if (cc) {
|
||||
material_string = cc->uniforms.ascii();
|
||||
strings.push_back(material_string.get_data());
|
||||
code_globals = cc->vertex_globals.ascii();
|
||||
strings.push_back(code_globals.get_data());
|
||||
}
|
||||
|
||||
strings.push_back(vertex_code2.get_data());
|
||||
|
@ -387,15 +388,15 @@ ShaderGLES3::Version *ShaderGLES3::get_current_version() {
|
|||
|
||||
strings.push_back(fragment_code0.get_data());
|
||||
if (cc) {
|
||||
code_globals = cc->fragment_globals.ascii();
|
||||
strings.push_back(code_globals.get_data());
|
||||
material_string = cc->uniforms.ascii();
|
||||
strings.push_back(material_string.get_data());
|
||||
}
|
||||
|
||||
strings.push_back(fragment_code1.get_data());
|
||||
|
||||
if (cc) {
|
||||
material_string = cc->uniforms.ascii();
|
||||
strings.push_back(material_string.get_data());
|
||||
code_globals = cc->fragment_globals.ascii();
|
||||
strings.push_back(code_globals.get_data());
|
||||
}
|
||||
|
||||
strings.push_back(fragment_code2.get_data());
|
||||
|
@ -617,21 +618,21 @@ void ShaderGLES3::setup(const char **p_conditional_defines, int p_conditional_co
|
|||
String material_tag = "\nMATERIAL_UNIFORMS";
|
||||
String code_tag = "\nVERTEX_SHADER_CODE";
|
||||
String code = vertex_code;
|
||||
int cpos = code.find(globals_tag);
|
||||
int cpos = code.find(material_tag);
|
||||
if (cpos == -1) {
|
||||
vertex_code0 = code.ascii();
|
||||
} else {
|
||||
vertex_code0 = code.substr(0, cpos).ascii();
|
||||
code = code.substr(cpos + globals_tag.length(), code.length());
|
||||
code = code.substr(cpos + material_tag.length(), code.length());
|
||||
|
||||
cpos = code.find(material_tag);
|
||||
cpos = code.find(globals_tag);
|
||||
|
||||
if (cpos == -1) {
|
||||
vertex_code1 = code.ascii();
|
||||
} else {
|
||||
|
||||
vertex_code1 = code.substr(0, cpos).ascii();
|
||||
String code2 = code.substr(cpos + material_tag.length(), code.length());
|
||||
String code2 = code.substr(cpos + globals_tag.length(), code.length());
|
||||
|
||||
cpos = code2.find(code_tag);
|
||||
if (cpos == -1) {
|
||||
|
@ -651,14 +652,14 @@ void ShaderGLES3::setup(const char **p_conditional_defines, int p_conditional_co
|
|||
String code_tag = "\nFRAGMENT_SHADER_CODE";
|
||||
String light_code_tag = "\nLIGHT_SHADER_CODE";
|
||||
String code = fragment_code;
|
||||
int cpos = code.find(globals_tag);
|
||||
int cpos = code.find(material_tag);
|
||||
if (cpos == -1) {
|
||||
fragment_code0 = code.ascii();
|
||||
} else {
|
||||
fragment_code0 = code.substr(0, cpos).ascii();
|
||||
//print_line("CODE0:\n"+String(fragment_code0.get_data()));
|
||||
code = code.substr(cpos + globals_tag.length(), code.length());
|
||||
cpos = code.find(material_tag);
|
||||
code = code.substr(cpos + material_tag.length(), code.length());
|
||||
cpos = code.find(globals_tag);
|
||||
|
||||
if (cpos == -1) {
|
||||
fragment_code1 = code.ascii();
|
||||
|
@ -667,7 +668,7 @@ void ShaderGLES3::setup(const char **p_conditional_defines, int p_conditional_co
|
|||
fragment_code1 = code.substr(0, cpos).ascii();
|
||||
//print_line("CODE1:\n"+String(fragment_code1.get_data()));
|
||||
|
||||
String code2 = code.substr(cpos + material_tag.length(), code.length());
|
||||
String code2 = code.substr(cpos + globals_tag.length(), code.length());
|
||||
cpos = code2.find(light_code_tag);
|
||||
|
||||
if (cpos == -1) {
|
||||
|
|
|
@ -90,7 +90,6 @@ uniform int h_frames;
|
|||
uniform int v_frames;
|
||||
#endif
|
||||
|
||||
VERTEX_SHADER_GLOBALS
|
||||
|
||||
#if defined(USE_MATERIAL)
|
||||
|
||||
|
@ -102,6 +101,8 @@ MATERIAL_UNIFORMS
|
|||
|
||||
#endif
|
||||
|
||||
VERTEX_SHADER_GLOBALS
|
||||
|
||||
void main() {
|
||||
|
||||
vec4 vertex_color = color_attrib;
|
||||
|
@ -211,6 +212,11 @@ uniform sampler2D screen_texture; // texunit:-3
|
|||
|
||||
#endif
|
||||
|
||||
#if defined(SCREEN_UV_USED)
|
||||
|
||||
uniform vec2 screen_pixel_size;
|
||||
#endif
|
||||
|
||||
layout(std140) uniform CanvasItemData {
|
||||
|
||||
highp mat4 projection_matrix;
|
||||
|
@ -256,7 +262,7 @@ const bool at_light_pass = false;
|
|||
|
||||
uniform mediump vec4 final_modulate;
|
||||
|
||||
FRAGMENT_SHADER_GLOBALS
|
||||
|
||||
|
||||
|
||||
layout(location=0) out mediump vec4 frag_color;
|
||||
|
@ -272,6 +278,7 @@ MATERIAL_UNIFORMS
|
|||
|
||||
#endif
|
||||
|
||||
FRAGMENT_SHADER_GLOBALS
|
||||
|
||||
void light_compute(inout vec3 light,vec3 light_vec,float light_height,vec4 light_color,vec2 light_uv,vec4 shadow,vec3 normal,vec2 uv,vec2 screen_uv,vec4 color) {
|
||||
|
||||
|
@ -410,8 +417,8 @@ void main() {
|
|||
|
||||
|
||||
|
||||
#if defined(ENABLE_SCREEN_UV)
|
||||
vec2 screen_uv = gl_FragCoord.xy*screen_uv_mult;
|
||||
#if defined(SCREEN_UV_USED)
|
||||
vec2 screen_uv = gl_FragCoord.xy*screen_pixel_size;
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -17,6 +17,12 @@ out vec2 uv_interp;
|
|||
|
||||
out vec2 uv2_interp;
|
||||
|
||||
#ifdef USE_COPY_SECTION
|
||||
|
||||
uniform vec4 copy_section;
|
||||
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
|
||||
#if defined(USE_CUBEMAP) || defined(USE_PANORAMA)
|
||||
|
@ -30,6 +36,13 @@ void main() {
|
|||
#endif
|
||||
uv2_interp = uv2_in;
|
||||
gl_Position = vertex_attrib;
|
||||
|
||||
#ifdef USE_COPY_SECTION
|
||||
|
||||
uv_interp = copy_section.xy + uv_interp * copy_section.zw;
|
||||
gl_Position.xy = (copy_section.xy + (gl_Position.xy * 0.5 + 0.5) * copy_section.zw) * 2.0 - 1.0;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
[fragment]
|
||||
|
|
|
@ -6,11 +6,21 @@ layout(location=4) in vec2 uv_in;
|
|||
|
||||
out vec2 uv_interp;
|
||||
|
||||
#ifdef USE_BLUR_SECTION
|
||||
|
||||
uniform vec4 blur_section;
|
||||
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
|
||||
uv_interp = uv_in;
|
||||
uv_interp = uv_in;
|
||||
gl_Position = vertex_attrib;
|
||||
#ifdef USE_BLUR_SECTION
|
||||
|
||||
uv_interp = blur_section.xy + uv_interp * blur_section.zw;
|
||||
gl_Position.xy = (blur_section.xy + (gl_Position.xy * 0.5 + 0.5) * blur_section.zw) * 2.0 - 1.0;
|
||||
#endif
|
||||
}
|
||||
|
||||
[fragment]
|
||||
|
|
|
@ -47,7 +47,6 @@ out highp vec4 out_xform_1; //tfb:
|
|||
out highp vec4 out_xform_2; //tfb:
|
||||
out highp vec4 out_xform_3; //tfb:
|
||||
|
||||
VERTEX_SHADER_GLOBALS
|
||||
|
||||
#if defined(USE_MATERIAL)
|
||||
|
||||
|
@ -59,6 +58,9 @@ MATERIAL_UNIFORMS
|
|||
|
||||
#endif
|
||||
|
||||
|
||||
VERTEX_SHADER_GLOBALS
|
||||
|
||||
uint hash(uint x) {
|
||||
|
||||
x = ((x >> uint(16)) ^ x) * uint(0x45d9f3b);
|
||||
|
@ -233,7 +235,6 @@ VERTEX_SHADER_CODE
|
|||
|
||||
//any code here is never executed, stuff is filled just so it works
|
||||
|
||||
FRAGMENT_SHADER_GLOBALS
|
||||
|
||||
#if defined(USE_MATERIAL)
|
||||
|
||||
|
@ -245,6 +246,8 @@ MATERIAL_UNIFORMS
|
|||
|
||||
#endif
|
||||
|
||||
FRAGMENT_SHADER_GLOBALS
|
||||
|
||||
void main() {
|
||||
|
||||
{
|
||||
|
|
|
@ -146,7 +146,7 @@ out vec3 binormal_interp;
|
|||
#endif
|
||||
|
||||
|
||||
VERTEX_SHADER_GLOBALS
|
||||
|
||||
|
||||
|
||||
#if defined(USE_MATERIAL)
|
||||
|
@ -159,6 +159,8 @@ MATERIAL_UNIFORMS
|
|||
|
||||
#endif
|
||||
|
||||
VERTEX_SHADER_GLOBALS
|
||||
|
||||
#ifdef RENDER_DEPTH_DUAL_PARABOLOID
|
||||
|
||||
out highp float dp_clip;
|
||||
|
@ -418,8 +420,6 @@ layout(std140) uniform Radiance { //ubo:2
|
|||
/* Material Uniforms */
|
||||
|
||||
|
||||
FRAGMENT_SHADER_GLOBALS
|
||||
|
||||
|
||||
#if defined(USE_MATERIAL)
|
||||
|
||||
|
@ -431,6 +431,7 @@ MATERIAL_UNIFORMS
|
|||
|
||||
#endif
|
||||
|
||||
FRAGMENT_SHADER_GLOBALS
|
||||
|
||||
layout(std140) uniform SceneData {
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
#include "os/keyboard.h"
|
||||
#include "os/os.h"
|
||||
#include "scene/main/node.h"
|
||||
#include "scene/main/scene_main_loop.h"
|
||||
#include "scene/main/scene_tree.h"
|
||||
#include "scene/main/viewport.h"
|
||||
#include "translations.gen.h"
|
||||
#include "version.h"
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
#include "input_map.h"
|
||||
#include "io/resource_loader.h"
|
||||
#include "scene/main/scene_main_loop.h"
|
||||
#include "scene/main/scene_tree.h"
|
||||
#include "servers/audio_server.h"
|
||||
|
||||
#include "io/resource_loader.h"
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include "performance.h"
|
||||
#include "message_queue.h"
|
||||
#include "os/os.h"
|
||||
#include "scene/main/scene_main_loop.h"
|
||||
#include "scene/main/scene_tree.h"
|
||||
#include "servers/physics_2d_server.h"
|
||||
#include "servers/physics_server.h"
|
||||
#include "servers/visual_server.h"
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
#include "scene/gui/tab_container.h"
|
||||
#include "scene/gui/texture_rect.h"
|
||||
#include "scene/gui/tree.h"
|
||||
#include "scene/main/scene_main_loop.h"
|
||||
#include "scene/main/scene_tree.h"
|
||||
|
||||
#include "scene/3d/camera.h"
|
||||
#include "scene/main/viewport.h"
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#include "os/file_access.h"
|
||||
#include "os/os.h"
|
||||
|
||||
#include "scene/main/scene_main_loop.h"
|
||||
#include "scene/main/scene_tree.h"
|
||||
#include "scene/resources/scene_format_text.h"
|
||||
|
||||
#if defined(TOOLS_ENABLED) && defined(DEBUG_METHODS_ENABLED)
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include "io/resource_loader.h"
|
||||
#include "os/os.h"
|
||||
#include "scene/main/node.h"
|
||||
#include "scene/main/scene_main_loop.h"
|
||||
#include "scene/main/scene_tree.h"
|
||||
#include "visual_script_nodes.h"
|
||||
|
||||
//////////////////////////////////////////
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include "os/input.h"
|
||||
#include "os/os.h"
|
||||
#include "scene/main/node.h"
|
||||
#include "scene/main/scene_main_loop.h"
|
||||
#include "scene/main/scene_tree.h"
|
||||
|
||||
//////////////////////////////////////////
|
||||
////////////////FUNCTION//////////////////
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
#include "os/os.h"
|
||||
#include "scene/main/node.h"
|
||||
#include "scene/main/scene_main_loop.h"
|
||||
#include "scene/main/scene_tree.h"
|
||||
#include "visual_script_nodes.h"
|
||||
|
||||
//////////////////////////////////////////
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#define CANVAS_ITEM_H
|
||||
|
||||
#include "scene/main/node.h"
|
||||
#include "scene/main/scene_main_loop.h"
|
||||
#include "scene/main/scene_tree.h"
|
||||
#include "scene/resources/material.h"
|
||||
#include "scene/resources/shader.h"
|
||||
#include "scene/resources/texture.h"
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#define SPATIAL_H
|
||||
|
||||
#include "scene/main/node.h"
|
||||
#include "scene/main/scene_main_loop.h"
|
||||
#include "scene/main/scene_tree.h"
|
||||
|
||||
/**
|
||||
@author Juan Linietsky <reduzio@gmail.com>
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#include "map.h"
|
||||
#include "object.h"
|
||||
#include "path_db.h"
|
||||
#include "scene/main/scene_main_loop.h"
|
||||
#include "scene/main/scene_tree.h"
|
||||
#include "script_language.h"
|
||||
|
||||
class Viewport;
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
#include "scene_main_loop.h"
|
||||
#include "scene_tree.h"
|
||||
|
||||
#include "global_config.h"
|
||||
#include "message_queue.h"
|
|
@ -129,7 +129,7 @@
|
|||
#include "scene/animation/animation_tree_player.h"
|
||||
#include "scene/animation/tween.h"
|
||||
#include "scene/main/resource_preloader.h"
|
||||
#include "scene/main/scene_main_loop.h"
|
||||
#include "scene/main/scene_tree.h"
|
||||
#include "scene/resources/packed_scene.h"
|
||||
|
||||
#include "scene/resources/mesh_data_tool.h"
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include "shape.h"
|
||||
|
||||
#include "os/os.h"
|
||||
#include "scene/main/scene_main_loop.h"
|
||||
#include "scene/main/scene_tree.h"
|
||||
#include "scene/resources/mesh.h"
|
||||
#include "servers/physics_server.h"
|
||||
|
||||
|
|
|
@ -102,7 +102,6 @@ ShaderTypes::ShaderTypes() {
|
|||
shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["SSS_STRENGTH"] = ShaderLanguage::TYPE_FLOAT;
|
||||
shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["AO"] = ShaderLanguage::TYPE_FLOAT;
|
||||
shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["EMISSION"] = ShaderLanguage::TYPE_VEC3;
|
||||
shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["SPECIAL"] = ShaderLanguage::TYPE_FLOAT;
|
||||
shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["DISCARD"] = ShaderLanguage::TYPE_BOOL;
|
||||
shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["SCREEN_TEXTURE"] = ShaderLanguage::TYPE_SAMPLER2D;
|
||||
shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["DEPTH_TEXTURE"] = ShaderLanguage::TYPE_SAMPLER2D;
|
||||
|
@ -156,7 +155,7 @@ ShaderTypes::ShaderTypes() {
|
|||
shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"]["AT_LIGHT_PASS"] = ShaderLanguage::TYPE_BOOL;
|
||||
|
||||
shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["SRC_COLOR"] = ShaderLanguage::TYPE_VEC4;
|
||||
shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["POSITION"] = ShaderLanguage::TYPE_VEC2;
|
||||
shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["FRAGCOORD"] = ShaderLanguage::TYPE_VEC4;
|
||||
shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["NORMAL"] = ShaderLanguage::TYPE_VEC3;
|
||||
shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["NORMALMAP"] = ShaderLanguage::TYPE_VEC3;
|
||||
shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["NORMALMAP_DEPTH"] = ShaderLanguage::TYPE_FLOAT;
|
||||
|
@ -165,9 +164,12 @@ ShaderTypes::ShaderTypes() {
|
|||
shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["TEXTURE"] = ShaderLanguage::TYPE_SAMPLER2D;
|
||||
shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["TEXTURE_PIXEL_SIZE"] = ShaderLanguage::TYPE_VEC2;
|
||||
shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["SCREEN_UV"] = ShaderLanguage::TYPE_VEC2;
|
||||
shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["SCREEN_PIXEL_SIZE"] = ShaderLanguage::TYPE_VEC2;
|
||||
shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["POINT_COORD"] = ShaderLanguage::TYPE_VEC2;
|
||||
shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["TIME"] = ShaderLanguage::TYPE_FLOAT;
|
||||
shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["AT_LIGHT_PASS"] = ShaderLanguage::TYPE_BOOL;
|
||||
shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["SCREEN_TEXTURE"] = ShaderLanguage::TYPE_SAMPLER2D;
|
||||
shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"]["SCREEN_UV"] = ShaderLanguage::TYPE_VEC2;
|
||||
|
||||
shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["POSITION"] = ShaderLanguage::TYPE_VEC2;
|
||||
shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["NORMAL"] = ShaderLanguage::TYPE_VEC3;
|
||||
|
|
Loading…
Reference in a new issue