From 22d83bc9f655d5ae7a1b49709c4c1b663725daf5 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Mon, 3 Oct 2016 16:33:42 -0300 Subject: Begining of GLES3 renderer: -Most 2D drawing is implemented -Missing shaders -Missing all 3D -Editor needs to be set on update always to be used, otherwise it does not refresh -Large parts of editor not working --- drivers/gles3/shader_gles3.cpp | 754 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 754 insertions(+) create mode 100644 drivers/gles3/shader_gles3.cpp (limited to 'drivers/gles3/shader_gles3.cpp') diff --git a/drivers/gles3/shader_gles3.cpp b/drivers/gles3/shader_gles3.cpp new file mode 100644 index 0000000000..f8c0234943 --- /dev/null +++ b/drivers/gles3/shader_gles3.cpp @@ -0,0 +1,754 @@ +/*************************************************************************/ +/* shader_gles2.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#include "shader_gles3.h" + + +#include "print_string.h" + +//#define DEBUG_OPENGL + +#ifdef DEBUG_OPENGL + +#define DEBUG_TEST_ERROR(m_section)\ +{\ + uint32_t err = glGetError();\ + if (err) {\ + print_line("OpenGL Error #"+itos(err)+" at: "+m_section);\ + }\ +} +#else + +#define DEBUG_TEST_ERROR(m_section) + +#endif + +ShaderGLES3 *ShaderGLES3::active=NULL; + + + +//#define DEBUG_SHADER + +#ifdef DEBUG_SHADER + +#define DEBUG_PRINT(m_text) print_line(m_text); + +#else + +#define DEBUG_PRINT(m_text) + +#endif + + +void ShaderGLES3::bind_uniforms() { + + if (!uniforms_dirty) { + return; + }; + + // upload default uniforms + const Map::Element *E =uniform_defaults.front(); + + while(E) { + int idx=E->key(); + int location=version->uniform_location[idx]; + + if (location<0) { + E=E->next(); + continue; + + } + + const Variant &v=E->value(); + _set_uniform_variant(location, v); + //print_line("uniform "+itos(location)+" value "+v+ " type "+Variant::get_type_name(v.get_type())); + E=E->next(); + }; + + const Map::Element* C = uniform_cameras.front(); + while (C) { + + int location = version->uniform_location[C->key()]; + if (location<0) { + C=C->next(); + continue; + } + + glUniformMatrix4fv(location,1,false,&(C->get().matrix[0][0])); + C = C->next(); + }; + + uniforms_dirty = false; +}; + +GLint ShaderGLES3::get_uniform_location(int p_idx) const { + + ERR_FAIL_COND_V(!version, -1); + + return version->uniform_location[p_idx]; +}; + +bool ShaderGLES3::bind() { + + if (active!=this || !version || new_conditional_version.key!=conditional_version.key) { + conditional_version=new_conditional_version; + version = get_current_version(); + } else { + + return false; + } + + ERR_FAIL_COND_V(!version,false); + + glUseProgram( version->id ); + + DEBUG_TEST_ERROR("Use Program"); + + active=this; + uniforms_dirty = true; +/* + * why on earth is this code here? + for (int i=0;i& p_code) { + + + int line=1; + String total_code; + + for(int i=0;i lines = String(total_code).split("\n"); + + for(int j=0;jversion==_v->code_version) + return _v; + } else { + return _v; + } + + } + + + + if (!_v) + version_map[conditional_version]=Version(); + + + Version &v = version_map[conditional_version]; + + if (!_v) { + + v.uniform_location = memnew_arr( GLint, uniform_count ); + + } else { + if (v.ok) { + //bye bye shaders + glDeleteShader( v.vert_id ); + glDeleteShader( v.frag_id ); + glDeleteProgram( v.id ); + v.id=0; + } + + } + + v.ok=false; + /* SETUP CONDITIONALS */ + + Vector strings; +#ifdef GLEW_ENABLED + //strings.push_back("#version 330\n"); + strings.push_back("#version 300 es\n"); +#else + strings.push_back("#version 300 es\n"); //ATI requieres this before anything +#endif + + + int define_line_ofs=1; + + for(int j=0;j0 ) { + //do custom code related stuff + + ERR_FAIL_COND_V( !custom_code_map.has( conditional_version.code_version ), NULL ); + cc=&custom_code_map[conditional_version.code_version]; + v.code_version=cc->version; + define_line_ofs+=2; + } + + + /* CREATE PROGRAM */ + + v.id = glCreateProgram(); + + ERR_FAIL_COND_V(v.id==0, NULL); + + /* VERTEX SHADER */ + + + if (cc) { + for(int i=0;icustom_defines.size();i++) { + + strings.push_back(cc->custom_defines[i]); + DEBUG_PRINT("CD #"+itos(i)+": "+String(cc->custom_defines[i])); + } + } + + int strings_base_size=strings.size(); + + //vertex precision is high + strings.push_back("precision highp float;\n"); + strings.push_back("precision highp int;\n"); + +#if 0 + if (cc) { + + String _code_string = "#define VERTEX_SHADER_CODE "+cc->vertex+"\n"; + String _code_globals = "#define VERTEX_SHADER_GLOBALS "+cc->vertex_globals+"\n"; + + code_string=_code_string.ascii(); + code_globals=_code_globals.ascii(); + DEBUG_PRINT( code_globals.get_data() ); + DEBUG_PRINT( code_string.get_data() ); + strings.push_back(code_globals); + strings.push_back(code_string); + } +#endif + + + strings.push_back(vertex_code0.get_data()); + if (cc) { + code_globals=cc->vertex_globals.ascii(); + strings.push_back(code_globals.get_data()); + } + strings.push_back(vertex_code1.get_data()); + + if (cc) { + code_string=cc->vertex.ascii(); + strings.push_back(code_string.get_data()); + } + + strings.push_back(vertex_code2.get_data()); +#ifdef DEBUG_SHADER + + DEBUG_PRINT("\nVertex Code:\n\n"+String(code_string.get_data())); + for(int i=0;ifragment+"\n"; + String _code_globals = "#define FRAGMENT_SHADER_GLOBALS "+cc->fragment_globals+"\n"; + + code_string=_code_string.ascii(); + code_globals=_code_globals.ascii(); + DEBUG_PRINT( code_globals.get_data() ); + DEBUG_PRINT( code_string.get_data() ); + strings.push_back(code_globals); + strings.push_back(code_string); + } +#endif + + + strings.push_back(fragment_code0.get_data()); + if (cc) { + code_globals=cc->fragment_globals.ascii(); + strings.push_back(code_globals.get_data()); + } + strings.push_back(fragment_code1.get_data()); + + if (cc) { + code_string=cc->fragment.ascii(); + strings.push_back(code_string.get_data()); + } + + strings.push_back(fragment_code2.get_data()); + + if (cc) { + code_string2=cc->light.ascii(); + strings.push_back(code_string2.get_data()); + } + + strings.push_back(fragment_code3.get_data()); + +#ifdef DEBUG_SHADER + DEBUG_PRINT("\nFragment Code:\n\n"+String(code_string.get_data())); + for(int i=0;i=0) { + if (texunit_pairs[i].index<0) { + glUniform1i(loc,max_image_units+texunit_pairs[i].index); //negative, goes down + } else { + + glUniform1i(loc,texunit_pairs[i].index); + } + } + } + + // assign uniform block bind points + for (int i=0;i=0) + glUniformBlockBinding(v.id,loc,ubo_pairs[i].index); + } + + if ( cc ) { + + v.custom_uniform_locations.resize(cc->custom_uniforms.size()); + for(int i=0;icustom_uniforms.size();i++) { + + v.custom_uniform_locations[i]=glGetUniformLocation(v.id,String(cc->custom_uniforms[i]).ascii().get_data()); + } + } + + glUseProgram(0); + + + v.ok=true; + + return &v; +} + +GLint ShaderGLES3::get_uniform_location(const String& p_name) const { + + ERR_FAIL_COND_V(!version,-1); + return glGetUniformLocation(version->id,p_name.ascii().get_data()); +} + + +void ShaderGLES3::setup(const char** p_conditional_defines, int p_conditional_count,const char** p_uniform_names,int p_uniform_count, const AttributePair* p_attribute_pairs, int p_attribute_count, const TexUnitPair *p_texunit_pairs, int p_texunit_pair_count, const UBOPair *p_ubo_pairs, int p_ubo_pair_count,const char*p_vertex_code, const char *p_fragment_code,int p_vertex_code_start,int p_fragment_code_start) { + + ERR_FAIL_COND(version); + conditional_version.key=0; + new_conditional_version.key=0; + uniform_count=p_uniform_count; + conditional_count=p_conditional_count; + conditional_defines=p_conditional_defines; + uniform_names=p_uniform_names; + vertex_code=p_vertex_code; + fragment_code=p_fragment_code; + texunit_pairs=p_texunit_pairs; + texunit_pair_count=p_texunit_pair_count; + vertex_code_start=p_vertex_code_start; + fragment_code_start=p_fragment_code_start; + attribute_pairs=p_attribute_pairs; + attribute_pair_count=p_attribute_count; + ubo_pairs=p_ubo_pairs; + ubo_count=p_ubo_pair_count; + + //split vertex and shader code (thank you, retarded shader compiler programmers from you know what company). + { + String globals_tag="\nVERTEX_SHADER_GLOBALS"; + String code_tag="\nVERTEX_SHADER_CODE"; + String code = vertex_code; + int cpos = code.find(globals_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()); + + cpos = code.find(code_tag); + + if (cpos==-1) { + vertex_code1=code.ascii(); + } else { + + vertex_code1=code.substr(0,cpos).ascii(); + vertex_code2=code.substr(cpos+code_tag.length(),code.length()).ascii(); + } + } + } + + { + String globals_tag="\nFRAGMENT_SHADER_GLOBALS"; + String code_tag="\nFRAGMENT_SHADER_CODE"; + String light_code_tag="\nLIGHT_SHADER_CODE"; + String code = fragment_code; + int cpos = code.find(globals_tag); + if (cpos==-1) { + fragment_code0=code.ascii(); + } else { + fragment_code0=code.substr(0,cpos).ascii(); + code = code.substr(cpos+globals_tag.length(),code.length()); + + cpos = code.find(code_tag); + + if (cpos==-1) { + fragment_code1=code.ascii(); + } else { + + fragment_code1=code.substr(0,cpos).ascii(); + String code2 = code.substr(cpos+code_tag.length(),code.length()); + + cpos = code2.find(light_code_tag); + if (cpos==-1) { + fragment_code2=code2.ascii(); + } else { + + fragment_code2=code2.substr(0,cpos).ascii(); + fragment_code3 = code2.substr(cpos+light_code_tag.length(),code2.length()).ascii(); + } + } + } + } + +} + +void ShaderGLES3::finish() { + + const VersionKey *V=NULL; + while((V=version_map.next(V))) { + + Version &v=version_map[*V]; + glDeleteShader( v.vert_id ); + glDeleteShader( v.frag_id ); + glDeleteProgram( v.id ); + memdelete_arr( v.uniform_location ); + + } + +} + + +void ShaderGLES3::clear_caches() { + + const VersionKey *V=NULL; + while((V=version_map.next(V))) { + + Version &v=version_map[*V]; + glDeleteShader( v.vert_id ); + glDeleteShader( v.frag_id ); + glDeleteProgram( v.id ); + memdelete_arr( v.uniform_location ); + } + + version_map.clear(); + + custom_code_map.clear(); + version=NULL; + last_custom_code=1; + uniforms_dirty = true; + +} + +uint32_t ShaderGLES3::create_custom_shader() { + + custom_code_map[last_custom_code]=CustomCode(); + custom_code_map[last_custom_code].version=1; + return last_custom_code++; +} + +void ShaderGLES3::set_custom_shader_code(uint32_t p_code_id, const String& p_vertex, const String& p_vertex_globals,const String& p_fragment,const String& p_light, const String& p_fragment_globals,const Vector& p_uniforms,const Vector &p_custom_defines) { + + ERR_FAIL_COND(!custom_code_map.has(p_code_id)); + CustomCode *cc=&custom_code_map[p_code_id]; + + cc->vertex=p_vertex; + cc->vertex_globals=p_vertex_globals; + cc->fragment=p_fragment; + cc->fragment_globals=p_fragment_globals; + cc->light=p_light; + cc->custom_uniforms=p_uniforms; + cc->custom_defines=p_custom_defines; + cc->version++; +} + +void ShaderGLES3::set_custom_shader(uint32_t p_code_id) { + + new_conditional_version.code_version=p_code_id; +} + +void ShaderGLES3::free_custom_shader(uint32_t p_code_id) { + + /* if (! custom_code_map.has( p_code_id )) { + print_line("no code id "+itos(p_code_id)); + } else { + print_line("freed code id "+itos(p_code_id)); + + }*/ + + ERR_FAIL_COND(! custom_code_map.has( p_code_id )); + if (conditional_version.code_version==p_code_id) + conditional_version.code_version=0; //bye + + custom_code_map.erase(p_code_id); + +} + + + +ShaderGLES3::ShaderGLES3() { + version=NULL; + last_custom_code=1; + uniforms_dirty = true; + + glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS,&max_image_units); +} + + +ShaderGLES3::~ShaderGLES3() { + + finish(); +} + + + -- cgit v1.2.3 From 1527cf8c0d17891dd0ebf99d484f83daa46eba3c Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Mon, 10 Oct 2016 18:31:01 -0300 Subject: 2D Shaders are working again using the new syntax, though all is buggy in general --- drivers/gles3/shader_gles3.cpp | 83 +++++++++++++++++++++++++++++++++--------- 1 file changed, 65 insertions(+), 18 deletions(-) (limited to 'drivers/gles3/shader_gles3.cpp') diff --git a/drivers/gles3/shader_gles3.cpp b/drivers/gles3/shader_gles3.cpp index f8c0234943..35191fecf7 100644 --- a/drivers/gles3/shader_gles3.cpp +++ b/drivers/gles3/shader_gles3.cpp @@ -214,6 +214,8 @@ ShaderGLES3::Version* ShaderGLES3::get_current_version() { } + + v.ok=false; /* SETUP CONDITIONALS */ @@ -245,6 +247,7 @@ ShaderGLES3::Version* ShaderGLES3::get_current_version() { CharString code_string; CharString code_string2; CharString code_globals; + CharString material_string; //print_line("code version? "+itos(conditional_version.code_version)); @@ -258,6 +261,7 @@ ShaderGLES3::Version* ShaderGLES3::get_current_version() { cc=&custom_code_map[conditional_version.code_version]; v.code_version=cc->version; define_line_ofs+=2; + } @@ -273,7 +277,7 @@ ShaderGLES3::Version* ShaderGLES3::get_current_version() { if (cc) { for(int i=0;icustom_defines.size();i++) { - strings.push_back(cc->custom_defines[i]); + strings.push_back(cc->custom_defines[i].get_data()); DEBUG_PRINT("CD #"+itos(i)+": "+String(cc->custom_defines[i])); } } @@ -305,14 +309,22 @@ ShaderGLES3::Version* ShaderGLES3::get_current_version() { code_globals=cc->vertex_globals.ascii(); strings.push_back(code_globals.get_data()); } + strings.push_back(vertex_code1.get_data()); + if (cc) { + material_string=cc->uniforms.ascii(); + strings.push_back(material_string.get_data()); + } + + strings.push_back(vertex_code2.get_data()); + if (cc) { code_string=cc->vertex.ascii(); strings.push_back(code_string.get_data()); } - strings.push_back(vertex_code2.get_data()); + strings.push_back(vertex_code3.get_data()); #ifdef DEBUG_SHADER DEBUG_PRINT("\nVertex Code:\n\n"+String(code_string.get_data())); @@ -367,7 +379,8 @@ ShaderGLES3::Version* ShaderGLES3::get_current_version() { ERR_FAIL_V(NULL); } - + + /* FRAGMENT SHADER */ strings.resize(strings_base_size); @@ -396,21 +409,29 @@ ShaderGLES3::Version* ShaderGLES3::get_current_version() { code_globals=cc->fragment_globals.ascii(); strings.push_back(code_globals.get_data()); } + strings.push_back(fragment_code1.get_data()); + if (cc) { + material_string=cc->uniforms.ascii(); + strings.push_back(material_string.get_data()); + } + + strings.push_back(fragment_code2.get_data()); + if (cc) { code_string=cc->fragment.ascii(); strings.push_back(code_string.get_data()); } - strings.push_back(fragment_code2.get_data()); + strings.push_back(fragment_code3.get_data()); if (cc) { code_string2=cc->light.ascii(); strings.push_back(code_string2.get_data()); } - strings.push_back(fragment_code3.get_data()); + strings.push_back(fragment_code4.get_data()); #ifdef DEBUG_SHADER DEBUG_PRINT("\nFragment Code:\n\n"+String(code_string.get_data())); @@ -463,7 +484,7 @@ ShaderGLES3::Version* ShaderGLES3::get_current_version() { ERR_FAIL_V( NULL ); } - + glAttachShader(v.id,v.frag_id); glAttachShader(v.id,v.vert_id); @@ -552,10 +573,11 @@ ShaderGLES3::Version* ShaderGLES3::get_current_version() { if ( cc ) { - v.custom_uniform_locations.resize(cc->custom_uniforms.size()); - for(int i=0;icustom_uniforms.size();i++) { + v.texture_uniform_locations.resize(cc->texture_uniforms.size()); + for(int i=0;itexture_uniforms.size();i++) { - v.custom_uniform_locations[i]=glGetUniformLocation(v.id,String(cc->custom_uniforms[i]).ascii().get_data()); + v.texture_uniform_locations[i]=glGetUniformLocation(v.id,String(cc->texture_uniforms[i]).ascii().get_data()); + glUniform1i(v.texture_uniform_locations[i],i+base_material_tex_index); } } @@ -597,6 +619,7 @@ void ShaderGLES3::setup(const char** p_conditional_defines, int p_conditional_co //split vertex and shader code (thank you, retarded shader compiler programmers from you know what company). { String globals_tag="\nVERTEX_SHADER_GLOBALS"; + String material_tag="\nMATERIAL_UNIFORMS"; String code_tag="\nVERTEX_SHADER_CODE"; String code = vertex_code; int cpos = code.find(globals_tag); @@ -606,20 +629,31 @@ void ShaderGLES3::setup(const char** p_conditional_defines, int p_conditional_co vertex_code0=code.substr(0,cpos).ascii(); code = code.substr(cpos+globals_tag.length(),code.length()); - cpos = code.find(code_tag); + cpos = code.find(material_tag); if (cpos==-1) { vertex_code1=code.ascii(); } else { vertex_code1=code.substr(0,cpos).ascii(); - vertex_code2=code.substr(cpos+code_tag.length(),code.length()).ascii(); + String code2 = code.substr(cpos+material_tag.length(),code.length()); + + cpos = code2.find(code_tag); + if (cpos==-1) { + vertex_code2=code2.ascii(); + } else { + + vertex_code2=code2.substr(0,cpos).ascii(); + vertex_code3 = code2.substr(cpos+code_tag.length(),code2.length()).ascii(); + } + } } } { String globals_tag="\nFRAGMENT_SHADER_GLOBALS"; + String material_tag="\nMATERIAL_UNIFORMS"; String code_tag="\nFRAGMENT_SHADER_CODE"; String light_code_tag="\nLIGHT_SHADER_CODE"; String code = fragment_code; @@ -630,22 +664,31 @@ void ShaderGLES3::setup(const char** p_conditional_defines, int p_conditional_co fragment_code0=code.substr(0,cpos).ascii(); code = code.substr(cpos+globals_tag.length(),code.length()); - cpos = code.find(code_tag); + cpos = code.find(material_tag); if (cpos==-1) { fragment_code1=code.ascii(); } else { fragment_code1=code.substr(0,cpos).ascii(); - String code2 = code.substr(cpos+code_tag.length(),code.length()); + String code2 = code.substr(cpos+material_tag.length(),code.length()); - cpos = code2.find(light_code_tag); + cpos = code2.find(code_tag); if (cpos==-1) { fragment_code2=code2.ascii(); } else { fragment_code2=code2.substr(0,cpos).ascii(); - fragment_code3 = code2.substr(cpos+light_code_tag.length(),code2.length()).ascii(); + String code3 = code2.substr(cpos+code_tag.length(),code2.length()); + + cpos = code3.find(light_code_tag); + if (cpos==-1) { + fragment_code3=code3.ascii(); + } else { + + fragment_code3=code3.substr(0,cpos).ascii(); + fragment_code4 = code3.substr(cpos+light_code_tag.length(),code3.length()).ascii(); + } } } } @@ -697,7 +740,7 @@ uint32_t ShaderGLES3::create_custom_shader() { return last_custom_code++; } -void ShaderGLES3::set_custom_shader_code(uint32_t p_code_id, const String& p_vertex, const String& p_vertex_globals,const String& p_fragment,const String& p_light, const String& p_fragment_globals,const Vector& p_uniforms,const Vector &p_custom_defines) { +void ShaderGLES3::set_custom_shader_code(uint32_t p_code_id, const String& p_vertex, const String& p_vertex_globals, const String& p_fragment, const String& p_light, const String& p_fragment_globals, const String &p_uniforms, const Vector &p_texture_uniforms, const Vector &p_custom_defines) { ERR_FAIL_COND(!custom_code_map.has(p_code_id)); CustomCode *cc=&custom_code_map[p_code_id]; @@ -707,7 +750,8 @@ void ShaderGLES3::set_custom_shader_code(uint32_t p_code_id, const String& p_ver cc->fragment=p_fragment; cc->fragment_globals=p_fragment_globals; cc->light=p_light; - cc->custom_uniforms=p_uniforms; + cc->texture_uniforms=p_texture_uniforms; + cc->uniforms=p_uniforms; cc->custom_defines=p_custom_defines; cc->version++; } @@ -734,13 +778,16 @@ void ShaderGLES3::free_custom_shader(uint32_t p_code_id) { } +void ShaderGLES3::set_base_material_tex_index(int p_idx) { + base_material_tex_index=p_idx; +} ShaderGLES3::ShaderGLES3() { version=NULL; last_custom_code=1; uniforms_dirty = true; - + base_material_tex_index=0; glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS,&max_image_units); } -- cgit v1.2.3 From 4428115916144b45c4697cd65d9c8c093631bec6 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Wed, 19 Oct 2016 11:14:41 -0300 Subject: Everything returning to normal in 3D, still a long way to go -implemented the scene part of visual server and rasterizer, objects without lighting and material are rendererd only --- drivers/gles3/shader_gles3.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'drivers/gles3/shader_gles3.cpp') diff --git a/drivers/gles3/shader_gles3.cpp b/drivers/gles3/shader_gles3.cpp index 35191fecf7..ebdf60cf42 100644 --- a/drivers/gles3/shader_gles3.cpp +++ b/drivers/gles3/shader_gles3.cpp @@ -662,8 +662,8 @@ void ShaderGLES3::setup(const char** p_conditional_defines, int p_conditional_co fragment_code0=code.ascii(); } else { fragment_code0=code.substr(0,cpos).ascii(); - code = code.substr(cpos+globals_tag.length(),code.length()); - + //print_line("CODE0:\n"+String(fragment_code0.get_data())); + code = code.substr(cpos+globals_tag.length(),code.length()); cpos = code.find(material_tag); if (cpos==-1) { @@ -671,14 +671,18 @@ void ShaderGLES3::setup(const char** p_conditional_defines, int p_conditional_co } else { fragment_code1=code.substr(0,cpos).ascii(); - String code2 = code.substr(cpos+material_tag.length(),code.length()); + //print_line("CODE1:\n"+String(fragment_code1.get_data())); + String code2 = code.substr(cpos+material_tag.length(),code.length()); cpos = code2.find(code_tag); + if (cpos==-1) { fragment_code2=code2.ascii(); } else { fragment_code2=code2.substr(0,cpos).ascii(); + //print_line("CODE2:\n"+String(fragment_code2.get_data())); + String code3 = code2.substr(cpos+code_tag.length(),code2.length()); cpos = code3.find(light_code_tag); @@ -687,7 +691,9 @@ void ShaderGLES3::setup(const char** p_conditional_defines, int p_conditional_co } else { fragment_code3=code3.substr(0,cpos).ascii(); + // print_line("CODE3:\n"+String(fragment_code3.get_data())); fragment_code4 = code3.substr(cpos+light_code_tag.length(),code3.length()).ascii(); + //print_line("CODE4:\n"+String(fragment_code4.get_data())); } } } -- cgit v1.2.3 From 53d8f2b1ec1d86b189800b7fe156c464fdf9e380 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Thu, 27 Oct 2016 11:50:26 -0300 Subject: PBR more or less working, still working on bringing gizmos back --- drivers/gles3/shader_gles3.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/gles3/shader_gles3.cpp') diff --git a/drivers/gles3/shader_gles3.cpp b/drivers/gles3/shader_gles3.cpp index ebdf60cf42..052c915241 100644 --- a/drivers/gles3/shader_gles3.cpp +++ b/drivers/gles3/shader_gles3.cpp @@ -751,6 +751,7 @@ void ShaderGLES3::set_custom_shader_code(uint32_t p_code_id, const String& p_ver ERR_FAIL_COND(!custom_code_map.has(p_code_id)); CustomCode *cc=&custom_code_map[p_code_id]; + cc->vertex=p_vertex; cc->vertex_globals=p_vertex_globals; cc->fragment=p_fragment; -- cgit v1.2.3 From a7078a4be9f4c44a41e5c7e7a633169b53f78d48 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Fri, 11 Nov 2016 12:27:52 -0300 Subject: Done with lights and shadows (wonder if i'm missing something..) --- drivers/gles3/shader_gles3.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'drivers/gles3/shader_gles3.cpp') diff --git a/drivers/gles3/shader_gles3.cpp b/drivers/gles3/shader_gles3.cpp index 052c915241..6f0616035a 100644 --- a/drivers/gles3/shader_gles3.cpp +++ b/drivers/gles3/shader_gles3.cpp @@ -228,8 +228,15 @@ ShaderGLES3::Version* ShaderGLES3::get_current_version() { #endif + int define_line_ofs=1; + for(int i=0;i Date: Tue, 22 Nov 2016 20:51:56 -0300 Subject: Migrated from GLES to GLAD, fixes many issues. --- drivers/gles3/shader_gles3.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers/gles3/shader_gles3.cpp') diff --git a/drivers/gles3/shader_gles3.cpp b/drivers/gles3/shader_gles3.cpp index 6f0616035a..0a25f6c3b3 100644 --- a/drivers/gles3/shader_gles3.cpp +++ b/drivers/gles3/shader_gles3.cpp @@ -220,7 +220,7 @@ ShaderGLES3::Version* ShaderGLES3::get_current_version() { /* SETUP CONDITIONALS */ Vector strings; -#ifdef GLEW_ENABLED +#ifdef GLES_OVER_GL //strings.push_back("#version 330\n"); strings.push_back("#version 300 es\n"); #else @@ -709,6 +709,8 @@ void ShaderGLES3::setup(const char** p_conditional_defines, int p_conditional_co } } + glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS,&max_image_units); + } void ShaderGLES3::finish() { @@ -804,7 +806,7 @@ ShaderGLES3::ShaderGLES3() { last_custom_code=1; uniforms_dirty = true; base_material_tex_index=0; - glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS,&max_image_units); + } -- cgit v1.2.3 From b72ca046051018628a31bc458dd730384ebddbe8 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Tue, 22 Nov 2016 20:53:37 -0300 Subject: Changed to proper GLSL version --- drivers/gles3/shader_gles3.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/gles3/shader_gles3.cpp') diff --git a/drivers/gles3/shader_gles3.cpp b/drivers/gles3/shader_gles3.cpp index 0a25f6c3b3..e906f9a790 100644 --- a/drivers/gles3/shader_gles3.cpp +++ b/drivers/gles3/shader_gles3.cpp @@ -221,8 +221,8 @@ ShaderGLES3::Version* ShaderGLES3::get_current_version() { Vector strings; #ifdef GLES_OVER_GL - //strings.push_back("#version 330\n"); - strings.push_back("#version 300 es\n"); + strings.push_back("#version 330\n"); + //strings.push_back("#version 300 es\n"); #else strings.push_back("#version 300 es\n"); //ATI requieres this before anything #endif -- cgit v1.2.3 From 7cf8d75cf8c49d02a72eac1d5342808526fa54ef Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Wed, 23 Nov 2016 07:04:55 -0300 Subject: WIP immediates and proper buffers swapping --- drivers/gles3/shader_gles3.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/gles3/shader_gles3.cpp') diff --git a/drivers/gles3/shader_gles3.cpp b/drivers/gles3/shader_gles3.cpp index e906f9a790..78f35c493a 100644 --- a/drivers/gles3/shader_gles3.cpp +++ b/drivers/gles3/shader_gles3.cpp @@ -222,9 +222,8 @@ ShaderGLES3::Version* ShaderGLES3::get_current_version() { Vector strings; #ifdef GLES_OVER_GL strings.push_back("#version 330\n"); - //strings.push_back("#version 300 es\n"); #else - strings.push_back("#version 300 es\n"); //ATI requieres this before anything + strings.push_back("#version 300 es\n"); #endif -- cgit v1.2.3 From a732708b9dad4ebc118a0ce854f950c6becb984c Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Thu, 24 Nov 2016 20:46:55 -0300 Subject: Blend shapes using transform feedback (GPU) --- drivers/gles3/shader_gles3.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'drivers/gles3/shader_gles3.cpp') diff --git a/drivers/gles3/shader_gles3.cpp b/drivers/gles3/shader_gles3.cpp index 78f35c493a..d29927b137 100644 --- a/drivers/gles3/shader_gles3.cpp +++ b/drivers/gles3/shader_gles3.cpp @@ -502,6 +502,25 @@ ShaderGLES3::Version* ShaderGLES3::get_current_version() { glBindAttribLocation(v.id, attribute_pairs[i].index, attribute_pairs[i].name ); } + //if feedback exists, set it up + + if (feedback_count) { + Vector feedback; + for(int i=0;i Date: Tue, 29 Nov 2016 19:55:12 -0300 Subject: Screen space reflection effect --- drivers/gles3/shader_gles3.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/gles3/shader_gles3.cpp') diff --git a/drivers/gles3/shader_gles3.cpp b/drivers/gles3/shader_gles3.cpp index d29927b137..778d3b23ec 100644 --- a/drivers/gles3/shader_gles3.cpp +++ b/drivers/gles3/shader_gles3.cpp @@ -393,8 +393,8 @@ ShaderGLES3::Version* ShaderGLES3::get_current_version() { strings.resize(strings_base_size); //fragment precision is medium - strings.push_back("precision mediump float;\n"); - strings.push_back("precision mediump int;\n"); + strings.push_back("precision highp float;\n"); + strings.push_back("precision highp int;\n"); #if 0 if (cc) { -- cgit v1.2.3