diff options
author | Juan Linietsky <reduzio@gmail.com> | 2014-10-12 02:13:22 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2014-10-12 02:13:22 -0300 |
commit | 948fd83cdded7fed77ae5213101c1a2ece580434 (patch) | |
tree | a6953095dc4feaac1485c04b35039b85f1a95534 /drivers | |
parent | 37354da5b0dc1dc8dcfd9d844e593935311f4f8f (diff) |
Little Bits
-=-=-=-=-=-
-fix duplicate function bug when creating script callback in editor
-fix bug where hiding lights does not work
-fix 2D audio listener bug (romulox_x reported)
-fix exported properties with inheritance bug
-fix timer autostart (make it not work on editor)
-reactivate first camara found if viewport runs out of active camera
-option to hide gizmos in viewport
-changed skeleton gizmo because it sucks
-Make convex shapes using CollisionShape visible (use quickhull class)
-fix up menu when editing a mesh, to export collision, navmesh, convex, etc. from it.
-make a menu option to show SRGB in 3D editor views by default
-make option to edit default light direction in viewport settings
-make option to edit default ambient light in viewport settings
-make software conversion of linear->RGB if hardware support not found
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gles2/rasterizer_gles2.cpp | 177 | ||||
-rw-r--r-- | drivers/gles2/shaders/material.glsl | 10 |
2 files changed, 173 insertions, 14 deletions
diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp index 95ec1c5544..d9771dadf2 100644 --- a/drivers/gles2/rasterizer_gles2.cpp +++ b/drivers/gles2/rasterizer_gles2.cpp @@ -403,19 +403,55 @@ Image RasterizerGLES2::_get_gl_image_and_format(const Image& p_image, Image::For if (!image.empty()) image.convert(Image::FORMAT_RGBA); r_gl_components=4; - r_gl_format=(srgb_supported && p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?_GL_SRGB_ALPHA_EXT:GL_RGBA; + + if (p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { + + if (srgb_supported) { + r_gl_format=_GL_SRGB_ALPHA_EXT; + } else { + r_gl_format=GL_RGBA; + if (!image.empty()) + image.srgb_to_linear(); + } + } else { + r_gl_format=GL_RGBA; + } r_has_alpha_cache=true; } break; case Image::FORMAT_RGB: { r_gl_components=3; - r_gl_format=(srgb_supported && p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?_GL_SRGB_EXT:GL_RGB; + + if (p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { + + if (srgb_supported) { + r_gl_format=_GL_SRGB_EXT; + } else { + r_gl_format=GL_RGB; + if (!image.empty()) + image.srgb_to_linear(); + } + } else { + r_gl_format=GL_RGB; + } } break; case Image::FORMAT_RGBA: { r_gl_components=4; - r_gl_format=(srgb_supported && p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?_GL_SRGB_ALPHA_EXT:GL_RGBA; + if (p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { + + if (srgb_supported) { + r_gl_format=_GL_SRGB_ALPHA_EXT; + } else { + r_gl_format=GL_RGBA; + if (!image.empty()) + image.srgb_to_linear(); + } + } else { + r_gl_format=GL_RGBA; + } + r_has_alpha_cache=true; } break; case Image::FORMAT_BC1: { @@ -426,7 +462,18 @@ Image RasterizerGLES2::_get_gl_image_and_format(const Image& p_image, Image::For image.decompress(); } r_gl_components=4; - r_gl_format=(srgb_supported && p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?_GL_SRGB_ALPHA_EXT:GL_RGBA; + if (p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { + + if (srgb_supported) { + r_gl_format=_GL_SRGB_ALPHA_EXT; + } else { + r_gl_format=GL_RGBA; + if (!image.empty()) + image.srgb_to_linear(); + } + } else { + r_gl_format=GL_RGBA; + } r_has_alpha_cache=true; } else { @@ -445,7 +492,18 @@ Image RasterizerGLES2::_get_gl_image_and_format(const Image& p_image, Image::For image.decompress(); } r_gl_components=4; - r_gl_format=(srgb_supported && p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?_GL_SRGB_ALPHA_EXT:GL_RGBA; + if (p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { + + if (srgb_supported) { + r_gl_format=_GL_SRGB_ALPHA_EXT; + } else { + r_gl_format=GL_RGBA; + if (!image.empty()) + image.srgb_to_linear(); + } + } else { + r_gl_format=GL_RGBA; + } r_has_alpha_cache=true; } else { @@ -465,7 +523,18 @@ Image RasterizerGLES2::_get_gl_image_and_format(const Image& p_image, Image::For image.decompress(); } r_gl_components=4; - r_gl_format=(srgb_supported && p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?_GL_SRGB_ALPHA_EXT:GL_RGBA; + if (p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { + + if (srgb_supported) { + r_gl_format=_GL_SRGB_ALPHA_EXT; + } else { + r_gl_format=GL_RGBA; + if (!image.empty()) + image.srgb_to_linear(); + } + } else { + r_gl_format=GL_RGBA; + } r_has_alpha_cache=true; } else { @@ -484,7 +553,18 @@ Image RasterizerGLES2::_get_gl_image_and_format(const Image& p_image, Image::For image.decompress(); } r_gl_components=4; - r_gl_format=(srgb_supported && p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?_GL_SRGB_ALPHA_EXT:GL_RGBA; + if (p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { + + if (srgb_supported) { + r_gl_format=_GL_SRGB_ALPHA_EXT; + } else { + r_gl_format=GL_RGBA; + if (!image.empty()) + image.srgb_to_linear(); + } + } else { + r_gl_format=GL_RGBA; + } r_has_alpha_cache=true; } else { @@ -503,7 +583,18 @@ Image RasterizerGLES2::_get_gl_image_and_format(const Image& p_image, Image::For image.decompress(); } r_gl_components=4; - r_gl_format=(srgb_supported && p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?_GL_SRGB_ALPHA_EXT:GL_RGBA; + if (p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { + + if (srgb_supported) { + r_gl_format=_GL_SRGB_ALPHA_EXT; + } else { + r_gl_format=GL_RGBA; + if (!image.empty()) + image.srgb_to_linear(); + } + } else { + r_gl_format=GL_RGBA; + } r_has_alpha_cache=true; } else { @@ -520,7 +611,18 @@ Image RasterizerGLES2::_get_gl_image_and_format(const Image& p_image, Image::For image.decompress(); } r_gl_components=4; - r_gl_format=(srgb_supported && p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?_GL_SRGB_ALPHA_EXT:GL_RGBA; + if (p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { + + if (srgb_supported) { + r_gl_format=_GL_SRGB_ALPHA_EXT; + } else { + r_gl_format=GL_RGBA; + if (!image.empty()) + image.srgb_to_linear(); + } + } else { + r_gl_format=GL_RGBA; + } r_has_alpha_cache=true; @@ -540,7 +642,18 @@ Image RasterizerGLES2::_get_gl_image_and_format(const Image& p_image, Image::For if (!image.empty()) image.decompress(); r_gl_components=4; - r_gl_format=(srgb_supported && p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?_GL_SRGB_ALPHA_EXT:GL_RGBA; + if (p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { + + if (srgb_supported) { + r_gl_format=_GL_SRGB_ALPHA_EXT; + } else { + r_gl_format=GL_RGBA; + if (!image.empty()) + image.srgb_to_linear(); + } + } else { + r_gl_format=GL_RGBA; + } r_has_alpha_cache=true; @@ -561,7 +674,18 @@ Image RasterizerGLES2::_get_gl_image_and_format(const Image& p_image, Image::For if (!image.empty()) image.decompress(); r_gl_components=4; - r_gl_format=(srgb_supported && p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?_GL_SRGB_ALPHA_EXT:GL_RGBA; + if (p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { + + if (srgb_supported) { + r_gl_format=_GL_SRGB_ALPHA_EXT; + } else { + r_gl_format=GL_RGBA; + if (!image.empty()) + image.srgb_to_linear(); + } + } else { + r_gl_format=GL_RGBA; + } r_has_alpha_cache=true; } else { @@ -578,7 +702,18 @@ Image RasterizerGLES2::_get_gl_image_and_format(const Image& p_image, Image::For if (!image.empty()) image.decompress(); r_gl_components=4; - r_gl_format=GL_RGBA; + if (p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { + + if (srgb_supported) { + r_gl_format=_GL_SRGB_ALPHA_EXT; + } else { + r_gl_format=GL_RGBA; + if (!image.empty()) + image.srgb_to_linear(); + } + } else { + r_gl_format=GL_RGBA; + } r_has_alpha_cache=true; } else { @@ -590,12 +725,24 @@ Image RasterizerGLES2::_get_gl_image_and_format(const Image& p_image, Image::For } break; case Image::FORMAT_ETC: { - if (!etc_supported) { + if (!etc_supported || p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { if (!image.empty()) { image.decompress(); } r_gl_components=3; + if (p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { + + if (srgb_supported) { + r_gl_format=_GL_SRGB_EXT; + } else { + r_gl_format=GL_RGB; + if (!image.empty()) + image.srgb_to_linear(); + } + } else { + r_gl_format=GL_RGB; + } r_gl_format=GL_RGB; @@ -1458,6 +1605,7 @@ void RasterizerGLES2::material_set_flag(RID p_material, VS::MaterialFlag p_flag, Material *material = material_owner.get(p_material); ERR_FAIL_COND(!material); ERR_FAIL_INDEX(p_flag,VS::MATERIAL_FLAG_MAX); + material->flags[p_flag]=p_enabled; } @@ -4715,6 +4863,7 @@ bool RasterizerGLES2::_setup_material(const Geometry *p_geometry,const Material material_shader.set_conditional(MaterialShaderGLES2::USE_SHADOW_PCF_HQ,shadow_filter==SHADOW_FILTER_PCF13); material_shader.set_conditional(MaterialShaderGLES2::USE_SHADOW_ESM,shadow_filter==SHADOW_FILTER_ESM); material_shader.set_conditional(MaterialShaderGLES2::USE_LIGHTMAP_ON_UV2,p_material->flags[VS::MATERIAL_FLAG_LIGHTMAP_ON_UV2]); + material_shader.set_conditional(MaterialShaderGLES2::USE_COLOR_ATTRIB_SRGB_TO_LINEAR,p_material->flags[VS::MATERIAL_FLAG_COLOR_ARRAY_SRGB] && current_env && current_env->fx_enabled[VS::ENV_FX_SRGB]); if (p_opaque_pass && p_material->depth_draw_mode==VS::MATERIAL_DEPTH_DRAW_OPAQUE_PRE_PASS_ALPHA && p_material->shader_cache && p_material->shader_cache->has_alpha) { @@ -6218,7 +6367,7 @@ void RasterizerGLES2::_render_list_forward(RenderList *p_render_list,const Trans if (!shadow) { if (!additive && current_env && current_env->fx_enabled[VS::ENV_FX_AMBIENT_LIGHT]) { - Color ambcolor = current_env->fx_param[VS::ENV_FX_PARAM_AMBIENT_LIGHT_COLOR]; + Color ambcolor = _convert_color(current_env->fx_param[VS::ENV_FX_PARAM_AMBIENT_LIGHT_COLOR]); float ambnrg = current_env->fx_param[VS::ENV_FX_PARAM_AMBIENT_LIGHT_ENERGY]; material_shader.set_uniform(MaterialShaderGLES2::AMBIENT_LIGHT,Vector3(ambcolor.r*ambnrg,ambcolor.g*ambnrg,ambcolor.b*ambnrg)); } else { diff --git a/drivers/gles2/shaders/material.glsl b/drivers/gles2/shaders/material.glsl index ad8a364ac1..63ff4a5f47 100644 --- a/drivers/gles2/shaders/material.glsl +++ b/drivers/gles2/shaders/material.glsl @@ -292,8 +292,18 @@ void main() { normal_interp = normalize((modelview * vec4(normal_in,0.0)).xyz); #if defined(ENABLE_COLOR_INTERP) +#ifdef USE_COLOR_ATTRIB_SRGB_TO_LINEAR + + color_interp = vec4( + color_attrib.r<0.04045 ? color_attrib.r * (1.0 / 12.92) : pow((color_attrib.r + 0.055) * (1.0 / (1 + 0.055)), 2.4), + color_attrib.g<0.04045 ? color_attrib.g * (1.0 / 12.92) : pow((color_attrib.g + 0.055) * (1.0 / (1 + 0.055)), 2.4), + color_attrib.b<0.04045 ? color_attrib.b * (1.0 / 12.92) : pow((color_attrib.b + 0.055) * (1.0 / (1 + 0.055)), 2.4), + color_attrib.a + ); +#else color_interp = color_attrib; #endif +#endif #if defined(ENABLE_TANGENT_INTERP) tangent_interp=normalize(tangent_in); |