summaryrefslogtreecommitdiff
path: root/drivers/gles2
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gles2')
-rw-r--r--drivers/gles2/rasterizer_gles2.cpp116
-rw-r--r--drivers/gles2/rasterizer_gles2.h6
-rw-r--r--drivers/gles2/shader_compiler_gles2.cpp238
-rw-r--r--drivers/gles2/shader_compiler_gles2.h5
-rw-r--r--drivers/gles2/shaders/SCsub2
5 files changed, 196 insertions, 171 deletions
diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp
index d84ee5a758..b473e8493f 100644
--- a/drivers/gles2/rasterizer_gles2.cpp
+++ b/drivers/gles2/rasterizer_gles2.cpp
@@ -4075,6 +4075,8 @@ void RasterizerGLES2::render_target_set_size(RID p_render_target,int p_width,int
glDeleteTextures(1,&rt->color);
rt->fbo=0;
+ rt->depth=0;
+ rt->color=0;
rt->width=0;
rt->height=0;
rt->texture_ptr->tex_id=0;
@@ -4094,12 +4096,14 @@ void RasterizerGLES2::render_target_set_size(RID p_render_target,int p_width,int
glBindFramebuffer(GL_FRAMEBUFFER, rt->fbo);
//depth
- glGenRenderbuffers(1, &rt->depth);
- glBindRenderbuffer(GL_RENDERBUFFER, rt->depth );
+ if (!low_memory_2d) {
+ glGenRenderbuffers(1, &rt->depth);
+ glBindRenderbuffer(GL_RENDERBUFFER, rt->depth );
- glRenderbufferStorage(GL_RENDERBUFFER, use_depth24?_DEPTH_COMPONENT24_OES:GL_DEPTH_COMPONENT16, rt->width,rt->height);
+ glRenderbufferStorage(GL_RENDERBUFFER, use_depth24?_DEPTH_COMPONENT24_OES:GL_DEPTH_COMPONENT16, rt->width,rt->height);
- glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rt->depth);
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rt->depth);
+ }
//color
glGenTextures(1, &rt->color);
@@ -4641,6 +4645,9 @@ void RasterizerGLES2::_update_shader( Shader* p_shader) const {
enablers.push_back("#define USE_TIME\n");
uses_time=true;
}
+ if (vertex_flags.vertex_code_writes_position) {
+ enablers.push_back("#define VERTEX_SHADER_WRITE_POSITION\n");
+ }
material_shader.set_custom_shader_code(p_shader->custom_code_id,vertex_code, vertex_globals,fragment_code, light_code, fragment_globals,uniform_names,enablers);
} else if (p_shader->mode==VS::SHADER_CANVAS_ITEM) {
@@ -6526,80 +6533,84 @@ void RasterizerGLES2::_render_list_forward(RenderList *p_render_list,const Trans
material_shader.set_conditional(MaterialShaderGLES2::ENABLE_AMBIENT_LIGHTMAP,false);
material_shader.set_conditional(MaterialShaderGLES2::ENABLE_AMBIENT_DP_SAMPLER,false);
- if (e->instance->sampled_light.is_valid()) {
+ if (material->flags[VS::MATERIAL_FLAG_UNSHADED] == false && current_debug != VS::SCENARIO_DEBUG_SHADELESS) {
- SampledLight *sl = sampled_light_owner.get(e->instance->sampled_light);
- if (sl) {
+ if (e->instance->sampled_light.is_valid()) {
- baked_light=NULL; //can't mix
- material_shader.set_conditional(MaterialShaderGLES2::ENABLE_AMBIENT_DP_SAMPLER,true);
- glActiveTexture(GL_TEXTURE0+max_texture_units-3);
- glBindTexture(GL_TEXTURE_2D,sl->texture); //bind the texture
- sampled_light_dp_multiplier=sl->multiplier;
- bind_dp_sampler=true;
+ SampledLight *sl = sampled_light_owner.get(e->instance->sampled_light);
+ if (sl) {
+
+ baked_light = NULL; //can't mix
+ material_shader.set_conditional(MaterialShaderGLES2::ENABLE_AMBIENT_DP_SAMPLER, true);
+ glActiveTexture(GL_TEXTURE0 + max_texture_units - 3);
+ glBindTexture(GL_TEXTURE_2D, sl->texture); //bind the texture
+ sampled_light_dp_multiplier = sl->multiplier;
+ bind_dp_sampler = true;
+ }
}
- }
- if (!additive && baked_light) {
+ if (!additive && baked_light) {
- if (baked_light->mode==VS::BAKED_LIGHT_OCTREE && baked_light->octree_texture.is_valid() && e->instance->baked_light_octree_xform) {
- material_shader.set_conditional(MaterialShaderGLES2::ENABLE_AMBIENT_OCTREE,true);
- bind_baked_light_octree=true;
- if (prev_baked_light!=baked_light) {
- Texture *tex=texture_owner.get(baked_light->octree_texture);
- if (tex) {
+ if (baked_light->mode == VS::BAKED_LIGHT_OCTREE && baked_light->octree_texture.is_valid() && e->instance->baked_light_octree_xform) {
+ material_shader.set_conditional(MaterialShaderGLES2::ENABLE_AMBIENT_OCTREE, true);
+ bind_baked_light_octree = true;
+ if (prev_baked_light != baked_light) {
+ Texture *tex = texture_owner.get(baked_light->octree_texture);
+ if (tex) {
- glActiveTexture(GL_TEXTURE0+max_texture_units-3);
- glBindTexture(tex->target,tex->tex_id); //bind the texture
- }
- if (baked_light->light_texture.is_valid()) {
- Texture *texl=texture_owner.get(baked_light->light_texture);
- if (texl) {
- glActiveTexture(GL_TEXTURE0+max_texture_units-4);
- glBindTexture(texl->target,texl->tex_id); //bind the light texture
+ glActiveTexture(GL_TEXTURE0 + max_texture_units - 3);
+ glBindTexture(tex->target, tex->tex_id); //bind the texture
+ }
+ if (baked_light->light_texture.is_valid()) {
+ Texture *texl = texture_owner.get(baked_light->light_texture);
+ if (texl) {
+ glActiveTexture(GL_TEXTURE0 + max_texture_units - 4);
+ glBindTexture(texl->target, texl->tex_id); //bind the light texture
+ }
}
- }
+ }
}
- } else if (baked_light->mode==VS::BAKED_LIGHT_LIGHTMAPS) {
+ else if (baked_light->mode == VS::BAKED_LIGHT_LIGHTMAPS) {
- int lightmap_idx = e->instance->baked_lightmap_id;
+ int lightmap_idx = e->instance->baked_lightmap_id;
- material_shader.set_conditional(MaterialShaderGLES2::ENABLE_AMBIENT_LIGHTMAP,false);
- bind_baked_lightmap=false;
+ material_shader.set_conditional(MaterialShaderGLES2::ENABLE_AMBIENT_LIGHTMAP, false);
+ bind_baked_lightmap = false;
- if (baked_light->lightmaps.has(lightmap_idx)) {
+ if (baked_light->lightmaps.has(lightmap_idx)) {
- RID texid = baked_light->lightmaps[lightmap_idx];
+ RID texid = baked_light->lightmaps[lightmap_idx];
- if (prev_baked_light!=baked_light || texid!=prev_baked_light_texture) {
+ if (prev_baked_light != baked_light || texid != prev_baked_light_texture) {
- Texture *tex = texture_owner.get(texid);
- if (tex) {
+ Texture *tex = texture_owner.get(texid);
+ if (tex) {
+
+ glActiveTexture(GL_TEXTURE0 + max_texture_units - 3);
+ glBindTexture(tex->target, tex->tex_id); //bind the texture
+ }
- glActiveTexture(GL_TEXTURE0+max_texture_units-3);
- glBindTexture(tex->target,tex->tex_id); //bind the texture
+ prev_baked_light_texture = texid;
}
- prev_baked_light_texture=texid;
- }
+ if (texid.is_valid()) {
+ material_shader.set_conditional(MaterialShaderGLES2::ENABLE_AMBIENT_LIGHTMAP, true);
+ bind_baked_lightmap = true;
+ }
- if (texid.is_valid()) {
- material_shader.set_conditional(MaterialShaderGLES2::ENABLE_AMBIENT_LIGHTMAP,true);
- bind_baked_lightmap=true;
}
-
}
}
- }
- if (int(prev_baked_light!=NULL) ^ int(baked_light!=NULL)) {
- rebind=true;
+ if (int(prev_baked_light != NULL) ^ int(baked_light != NULL)) {
+ rebind = true;
+ }
}
}
@@ -10293,7 +10304,11 @@ void RasterizerGLES2::_update_framebuffer() {
framebuffer.fbo=0;
}
+#ifdef TOOLS_ENABLED
framebuffer.active=use_fbo;
+#else
+ framebuffer.active=use_fbo && !low_memory_2d;
+#endif
framebuffer.width=dwidth;
framebuffer.height=dheight;
framebuffer.scale=scale;
@@ -11203,6 +11218,7 @@ RasterizerGLES2::RasterizerGLES2(bool p_compress_arrays,bool p_keep_ram_copy,boo
use_fp16_fb=bool(GLOBAL_DEF("rasterizer/fp16_framebuffer",true));
use_shadow_mapping=true;
use_fast_texture_filter=!bool(GLOBAL_DEF("rasterizer/trilinear_mipmap_filter",true));
+ low_memory_2d=bool(GLOBAL_DEF("rasterizer/low_memory_2d_mode",false));
skel_default.resize(1024*4);
for(int i=0;i<1024/3;i++) {
diff --git a/drivers/gles2/rasterizer_gles2.h b/drivers/gles2/rasterizer_gles2.h
index 507e46ae75..d6d9593da8 100644
--- a/drivers/gles2/rasterizer_gles2.h
+++ b/drivers/gles2/rasterizer_gles2.h
@@ -105,13 +105,13 @@ class RasterizerGLES2 : public Rasterizer {
float anisotropic_level;
bool use_half_float;
-
+ bool low_memory_2d;
Vector<float> skel_default;
Image _get_gl_image_and_format(const Image& p_image, Image::Format p_format, uint32_t p_flags,GLenum& r_gl_format,GLenum& r_gl_internal_format,int &r_gl_components,bool &r_has_alpha_cache,bool &r_compressed);
- class RenderTarget;
+ struct RenderTarget;
struct Texture {
@@ -305,7 +305,7 @@ class RasterizerGLES2 : public Rasterizer {
virtual ~GeometryOwner() {}
};
- class Mesh;
+ struct Mesh;
struct Surface : public Geometry {
diff --git a/drivers/gles2/shader_compiler_gles2.cpp b/drivers/gles2/shader_compiler_gles2.cpp
index d57512c936..c8f59ce22b 100644
--- a/drivers/gles2/shader_compiler_gles2.cpp
+++ b/drivers/gles2/shader_compiler_gles2.cpp
@@ -154,6 +154,9 @@ String ShaderCompilerGLES2::dump_node_code(SL::Node *p_node,int p_level,bool p_a
if (vnode->name==vname_vertex && p_assign_left) {
vertex_code_writes_vertex=true;
}
+ if (vnode->name == vname_position && p_assign_left) {
+ vertex_code_writes_position = true;
+ }
if (vnode->name==vname_color_interp) {
flags->use_color_interp=true;
}
@@ -659,6 +662,7 @@ Error ShaderCompilerGLES2::compile(const String& p_code, ShaderLanguage::ShaderT
uses_texpixel_size=false;
uses_worldvec=false;
vertex_code_writes_vertex=false;
+ vertex_code_writes_position = false;
uses_shadow_color=false;
uniforms=r_uniforms;
flags=&r_flags;
@@ -690,6 +694,7 @@ Error ShaderCompilerGLES2::compile(const String& p_code, ShaderLanguage::ShaderT
r_flags.uses_texscreen=uses_texscreen;
r_flags.uses_texpos=uses_texpos;
r_flags.vertex_code_writes_vertex=vertex_code_writes_vertex;
+ r_flags.vertex_code_writes_position=vertex_code_writes_position;
r_flags.uses_discard=uses_discard;
r_flags.uses_screen_uv=uses_screen_uv;
r_flags.uses_light=uses_light;
@@ -778,125 +783,127 @@ ShaderCompilerGLES2::ShaderCompilerGLES2() {
replace_table["texscreen"]= "texscreen";
replace_table["texpos"]= "texpos";
- mode_replace_table[0]["SRC_VERTEX"]="vertex_in.xyz";
- mode_replace_table[0]["SRC_NORMAL"]="normal_in";
- mode_replace_table[0]["SRC_TANGENT"]="tangent_in";
- mode_replace_table[0]["SRC_BINORMALF"]="binormalf";
-
- mode_replace_table[0]["VERTEX"]="vertex_interp";
- mode_replace_table[0]["NORMAL"]="normal_interp";
- mode_replace_table[0]["TANGENT"]="tangent_interp";
- mode_replace_table[0]["BINORMAL"]="binormal_interp";
- mode_replace_table[0]["UV"]="uv_interp.xy";
- mode_replace_table[0]["UV2"]="uv_interp.zw";
- mode_replace_table[0]["COLOR"]="color_interp";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["POSITION"] = "gl_Position";
+
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["SRC_VERTEX"] = "vertex_in.xyz";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["SRC_NORMAL"] = "normal_in";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["SRC_TANGENT"]="tangent_in";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["SRC_BINORMALF"]="binormalf";
+
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["VERTEX"]="vertex_interp";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["NORMAL"]="normal_interp";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["TANGENT"]="tangent_interp";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["BINORMAL"]="binormal_interp";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["UV"]="uv_interp.xy";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["UV2"]="uv_interp.zw";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["COLOR"]="color_interp";
//@TODO convert to glsl stuff
- mode_replace_table[0]["SPEC_EXP"]="vertex_specular_exp";
- mode_replace_table[0]["WORLD_MATRIX"]="world_transform";
- mode_replace_table[0]["INV_CAMERA_MATRIX"]="camera_inverse_transform";
- mode_replace_table[0]["PROJECTION_MATRIX"]="projection_transform";
- mode_replace_table[0]["MODELVIEW_MATRIX"]="modelview";
- mode_replace_table[0]["POINT_SIZE"]="gl_PointSize";
- mode_replace_table[0]["VAR1"]="var1_interp";
- mode_replace_table[0]["VAR2"]="var2_interp";
-
-// mode_replace_table[0]["SCREEN_POS"]="SCREEN_POS";
-// mode_replace_table[0]["SCREEN_SIZE"]="SCREEN_SIZE";
- mode_replace_table[0]["INSTANCE_ID"]="instance_id";
- mode_replace_table[0]["TIME"]="time";
-
- mode_replace_table[1]["VERTEX"]="vertex";
- //mode_replace_table[1]["POSITION"]="IN_POSITION";
- mode_replace_table[1]["NORMAL"]="normal";
- mode_replace_table[1]["TANGENT"]="tangent";
- mode_replace_table[1]["POSITION"]="gl_Position";
- mode_replace_table[1]["BINORMAL"]="binormal";
- mode_replace_table[1]["NORMALMAP"]="normalmap";
- mode_replace_table[1]["NORMALMAP_DEPTH"]="normaldepth";
- mode_replace_table[1]["VAR1"]="var1_interp";
- mode_replace_table[1]["VAR2"]="var2_interp";
- mode_replace_table[1]["UV"]="uv";
- mode_replace_table[1]["UV2"]="uv2";
- mode_replace_table[1]["SCREEN_UV"]="screen_uv";
- mode_replace_table[1]["VAR1"]="var1_interp";
- mode_replace_table[1]["VAR2"]="var2_interp";
- mode_replace_table[1]["COLOR"]="color";
- mode_replace_table[1]["DIFFUSE"]="diffuse.rgb";
- mode_replace_table[1]["DIFFUSE_ALPHA"]="diffuse";
- mode_replace_table[1]["SPECULAR"]="specular";
- mode_replace_table[1]["EMISSION"]="emission";
- mode_replace_table[1]["SHADE_PARAM"]="shade_param";
- mode_replace_table[1]["SPEC_EXP"]="specular_exp";
- mode_replace_table[1]["GLOW"]="glow";
- mode_replace_table[1]["DISCARD"]="discard_";
- mode_replace_table[1]["POINT_COORD"]="gl_PointCoord";
- mode_replace_table[1]["INV_CAMERA_MATRIX"]="camera_inverse_transform";
-
- //mode_replace_table[1]["SCREEN_POS"]="SCREEN_POS";
- //mode_replace_table[1]["SCREEN_TEXEL_SIZE"]="SCREEN_TEXEL_SIZE";
- mode_replace_table[1]["TIME"]="time";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["SPEC_EXP"]="vertex_specular_exp";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["WORLD_MATRIX"]="world_transform";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["INV_CAMERA_MATRIX"]="camera_inverse_transform";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["PROJECTION_MATRIX"]="projection_transform";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["MODELVIEW_MATRIX"]="modelview";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["POINT_SIZE"]="gl_PointSize";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["VAR1"]="var1_interp";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["VAR2"]="var2_interp";
+
+// mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["SCREEN_POS"]="SCREEN_POS";
+// mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["SCREEN_SIZE"]="SCREEN_SIZE";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["INSTANCE_ID"]="instance_id";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["TIME"]="time";
+
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["VERTEX"]="vertex";
+ //mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["POSITION"]="IN_POSITION";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["NORMAL"]="normal";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["TANGENT"]="tangent";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["POSITION"]="gl_Position";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["BINORMAL"]="binormal";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["NORMALMAP"]="normalmap";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["NORMALMAP_DEPTH"]="normaldepth";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["VAR1"]="var1_interp";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["VAR2"]="var2_interp";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["UV"]="uv";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["UV2"]="uv2";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["SCREEN_UV"]="screen_uv";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["VAR1"]="var1_interp";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["VAR2"]="var2_interp";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["COLOR"]="color";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["DIFFUSE"]="diffuse.rgb";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["DIFFUSE_ALPHA"]="diffuse";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["SPECULAR"]="specular";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["EMISSION"]="emission";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["SHADE_PARAM"]="shade_param";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["SPEC_EXP"]="specular_exp";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["GLOW"]="glow";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["DISCARD"]="discard_";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["POINT_COORD"]="gl_PointCoord";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["INV_CAMERA_MATRIX"]="camera_inverse_transform";
+
+ //mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["SCREEN_POS"]="SCREEN_POS";
+ //mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["SCREEN_TEXEL_SIZE"]="SCREEN_TEXEL_SIZE";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["TIME"]="time";
//////////////
- mode_replace_table[2]["NORMAL"]="normal";
- //mode_replace_table[2]["POSITION"]="IN_POSITION";
- mode_replace_table[2]["LIGHT_DIR"]="light_dir";
- mode_replace_table[2]["LIGHT_DIFFUSE"]="light_diffuse";
- mode_replace_table[2]["LIGHT_SPECULAR"]="light_specular";
- mode_replace_table[2]["EYE_VEC"]="eye_vec";
- mode_replace_table[2]["DIFFUSE"]="mdiffuse";
- mode_replace_table[2]["SPECULAR"]="specular";
- mode_replace_table[2]["SPECULAR_EXP"]="specular_exp";
- mode_replace_table[2]["SHADE_PARAM"]="shade_param";
- mode_replace_table[2]["LIGHT"]="light";
- mode_replace_table[2]["POINT_COORD"]="gl_PointCoord";
- mode_replace_table[2]["TIME"]="time";
-
- mode_replace_table[3]["SRC_VERTEX"]="src_vtx";
- mode_replace_table[3]["VERTEX"]="outvec.xy";
- mode_replace_table[3]["WORLD_VERTEX"]="outvec.xy";
- mode_replace_table[3]["UV"]="uv_interp";
- mode_replace_table[3]["COLOR"]="color_interp";
- mode_replace_table[3]["VAR1"]="var1_interp";
- mode_replace_table[3]["VAR2"]="var2_interp";
- mode_replace_table[3]["POINT_SIZE"]="gl_PointSize";
- mode_replace_table[3]["WORLD_MATRIX"]="modelview_matrix";
- mode_replace_table[3]["PROJECTION_MATRIX"]="projection_matrix";
- mode_replace_table[3]["EXTRA_MATRIX"]="extra_matrix";
- mode_replace_table[3]["TIME"]="time";
-
- mode_replace_table[4]["POSITION"]="gl_Position";
- mode_replace_table[4]["NORMAL"]="normal";
- mode_replace_table[4]["NORMALMAP"]="normal_map";
- mode_replace_table[4]["NORMALMAP_DEPTH"]="normal_depth";
- mode_replace_table[4]["UV"]="uv_interp";
- mode_replace_table[4]["SRC_COLOR"]="color_interp";
- mode_replace_table[4]["COLOR"]="color";
- mode_replace_table[4]["TEXTURE"]="texture";
- mode_replace_table[4]["TEXTURE_PIXEL_SIZE"]="texpixel_size";
- mode_replace_table[4]["VAR1"]="var1_interp";
- mode_replace_table[4]["VAR2"]="var2_interp";
- mode_replace_table[4]["SCREEN_UV"]="screen_uv";
- mode_replace_table[4]["POINT_COORD"]="gl_PointCoord";
- mode_replace_table[4]["TIME"]="time";
-
- mode_replace_table[5]["POSITION"]="gl_Position";
- mode_replace_table[5]["NORMAL"]="normal";
- mode_replace_table[5]["UV"]="uv_interp";
- mode_replace_table[5]["COLOR"]="color";
- mode_replace_table[5]["TEXTURE"]="texture";
- mode_replace_table[5]["TEXTURE_PIXEL_SIZE"]="texpixel_size";
- mode_replace_table[5]["VAR1"]="var1_interp";
- mode_replace_table[5]["VAR2"]="var2_interp";
- mode_replace_table[5]["LIGHT_VEC"]="light_vec";
- mode_replace_table[5]["LIGHT_HEIGHT"]="light_height";
- mode_replace_table[5]["LIGHT_COLOR"]="light";
- mode_replace_table[5]["LIGHT_UV"]="light_uv";
- mode_replace_table[5]["LIGHT"]="light_out";
- mode_replace_table[5]["SHADOW"]="shadow_color";
- mode_replace_table[5]["SCREEN_UV"]="screen_uv";
- mode_replace_table[5]["POINT_COORD"]="gl_PointCoord";
- mode_replace_table[5]["TIME"]="time";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["NORMAL"]="normal";
+ //mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["POSITION"]="IN_POSITION";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["LIGHT_DIR"]="light_dir";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["LIGHT_DIFFUSE"]="light_diffuse";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["LIGHT_SPECULAR"]="light_specular";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["EYE_VEC"]="eye_vec";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["DIFFUSE"]="mdiffuse";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["SPECULAR"]="specular";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["SPECULAR_EXP"]="specular_exp";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["SHADE_PARAM"]="shade_param";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["LIGHT"]="light";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["POINT_COORD"]="gl_PointCoord";
+ mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["TIME"]="time";
+
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["SRC_VERTEX"]="src_vtx";
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["VERTEX"]="outvec.xy";
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["WORLD_VERTEX"]="outvec.xy";
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["UV"]="uv_interp";
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["COLOR"]="color_interp";
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["VAR1"]="var1_interp";
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["VAR2"]="var2_interp";
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["POINT_SIZE"]="gl_PointSize";
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["WORLD_MATRIX"]="modelview_matrix";
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["PROJECTION_MATRIX"]="projection_matrix";
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["EXTRA_MATRIX"]="extra_matrix";
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["TIME"]="time";
+
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["POSITION"]="gl_Position";
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["NORMAL"]="normal";
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["NORMALMAP"]="normal_map";
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["NORMALMAP_DEPTH"]="normal_depth";
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["UV"]="uv_interp";
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["SRC_COLOR"]="color_interp";
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["COLOR"]="color";
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["TEXTURE"]="texture";
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["TEXTURE_PIXEL_SIZE"]="texpixel_size";
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["VAR1"]="var1_interp";
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["VAR2"]="var2_interp";
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["SCREEN_UV"]="screen_uv";
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["POINT_COORD"]="gl_PointCoord";
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["TIME"]="time";
+
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["POSITION"]="gl_Position";
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["NORMAL"]="normal";
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["UV"]="uv_interp";
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["COLOR"]="color";
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["TEXTURE"]="texture";
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["TEXTURE_PIXEL_SIZE"]="texpixel_size";
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["VAR1"]="var1_interp";
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["VAR2"]="var2_interp";
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["LIGHT_VEC"]="light_vec";
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["LIGHT_HEIGHT"]="light_height";
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["LIGHT_COLOR"]="light";
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["LIGHT_UV"]="light_uv";
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["LIGHT"]="light_out";
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["SHADOW"]="shadow_color";
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["SCREEN_UV"]="screen_uv";
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["POINT_COORD"]="gl_PointCoord";
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["TIME"]="time";
@@ -917,6 +924,7 @@ ShaderCompilerGLES2::ShaderCompilerGLES2() {
vname_var1_interp="VAR1";
vname_var2_interp="VAR2";
vname_vertex="VERTEX";
+ vname_position = "POSITION";
vname_light="LIGHT";
vname_time="TIME";
vname_normalmap="NORMALMAP";
diff --git a/drivers/gles2/shader_compiler_gles2.h b/drivers/gles2/shader_compiler_gles2.h
index 43902a7536..46ef2e035f 100644
--- a/drivers/gles2/shader_compiler_gles2.h
+++ b/drivers/gles2/shader_compiler_gles2.h
@@ -34,7 +34,7 @@ class ShaderCompilerGLES2 {
class Uniform;
public:
- class Flags;
+ struct Flags;
private:
ShaderLanguage::ProgramNode *program_node;
@@ -55,6 +55,7 @@ private:
bool uses_texpixel_size;
bool uses_worldvec;
bool vertex_code_writes_vertex;
+ bool vertex_code_writes_position;
bool uses_shadow_color;
bool sinh_used;
@@ -76,6 +77,7 @@ private:
StringName vname_var1_interp;
StringName vname_var2_interp;
StringName vname_vertex;
+ StringName vname_position;
StringName vname_light;
StringName vname_time;
StringName vname_normalmap;
@@ -107,6 +109,7 @@ public:
bool uses_texpos;
bool uses_normalmap;
bool vertex_code_writes_vertex;
+ bool vertex_code_writes_position;
bool uses_discard;
bool uses_screen_uv;
bool use_color_interp;
diff --git a/drivers/gles2/shaders/SCsub b/drivers/gles2/shaders/SCsub
index 9679223b16..38177d725f 100644
--- a/drivers/gles2/shaders/SCsub
+++ b/drivers/gles2/shaders/SCsub
@@ -6,5 +6,3 @@ if env['BUILDERS'].has_key('GLSL120GLES'):
env.GLSL120GLES('canvas_shadow.glsl');
env.GLSL120GLES('blur.glsl');
env.GLSL120GLES('copy.glsl');
-
-