mirror of
https://github.com/godotengine/godot.git
synced 2024-11-10 22:23:07 +00:00
Some changes to dual paraboloid envmap generation, fixes somme bleeding
This commit is contained in:
parent
58320b7f6c
commit
12a8fedfe6
@ -16,6 +16,7 @@ attribute vec2 uv_in; // attrib:4
|
||||
#endif
|
||||
attribute vec2 uv2_in; // attrib:5
|
||||
|
||||
|
||||
#ifdef USE_CUBEMAP
|
||||
varying vec3 cube_interp;
|
||||
#else
|
||||
@ -58,7 +59,9 @@ float sRGB_gamma_correct(float c){
|
||||
#define LUM_RANGE 4.0
|
||||
|
||||
|
||||
#ifdef USE_CUBEMAP
|
||||
#ifdef USE_ARRAY
|
||||
uniform sampler2DArray source;
|
||||
#elif defined(USE_CUBEMAP)
|
||||
varying vec3 cube_interp;
|
||||
uniform samplerCube source_cube;
|
||||
#else
|
||||
@ -145,23 +148,17 @@ uniform float custom_alpha;
|
||||
void main() {
|
||||
|
||||
//vec4 color = color_interp;
|
||||
#ifdef USE_HIGHP_SOURCE
|
||||
|
||||
#ifdef USE_CUBEMAP
|
||||
|
||||
#ifdef USE_ARRAY
|
||||
highp vec4 color = textureLod( source, vec3(uv_interp,0.0),0.0 );
|
||||
#elif defined(USE_CUBEMAP)
|
||||
highp vec4 color = textureCube( source_cube, normalize(cube_interp) );
|
||||
|
||||
#else
|
||||
highp vec4 color = texture2D( source, uv_interp );
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#ifdef USE_CUBEMAP
|
||||
vec4 color = textureCube( source_cube, normalize(cube_interp) );
|
||||
|
||||
#else
|
||||
vec4 color = texture2D( source, uv_interp );
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1889,6 +1889,7 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements, int p_
|
||||
} else {
|
||||
glBindTexture(GL_TEXTURE_2D, p_base_env);
|
||||
}
|
||||
|
||||
state.scene_shader.set_conditional(SceneShaderGLES3::USE_RADIANCE_MAP, true);
|
||||
state.scene_shader.set_conditional(SceneShaderGLES3::USE_RADIANCE_MAP_ARRAY, storage->config.use_texture_array_environment);
|
||||
} else {
|
||||
@ -4233,7 +4234,11 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
|
||||
storage->canvas->canvas_begin();
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, env_radiance_tex);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
storage->canvas->draw_generic_textured_rect(Rect2(0, 0, storage->frame.current_rt->width / 2, storage->frame.current_rt->height / 2), Rect2(0, 0, 1, 1));
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1260,6 +1260,10 @@ void RasterizerStorageGLES3::sky_set_texture(RID p_sky, RID p_panorama, int p_ra
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(texture->target, texture->tex_id);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); //need this for proper sampling
|
||||
|
||||
if (config.srgb_decode_supported && texture->srgb && !texture->using_srgb) {
|
||||
|
||||
@ -1377,8 +1381,8 @@ void RasterizerStorageGLES3::sky_set_texture(RID p_sky, RID p_panorama, int p_ra
|
||||
|
||||
glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, RasterizerStorageGLES3::system_fbo);
|
||||
glDeleteFramebuffers(1, &tmp_fb);
|
||||
|
@ -219,9 +219,8 @@ void main() {
|
||||
N.z = 0.5 - 0.5*((N.x * N.x) + (N.y * N.y));
|
||||
N = normalize(N);
|
||||
|
||||
if (!z_flip) {
|
||||
//N.y=-N.y; //y is flipped to improve blending between both sides
|
||||
} else {
|
||||
if (z_flip) {
|
||||
N.y=-N.y; //y is flipped to improve blending between both sides
|
||||
N.z=-N.z;
|
||||
}
|
||||
|
||||
|
@ -429,7 +429,9 @@ vec3 textureDualParaboloid(sampler2DArray p_tex, vec3 p_vec,float p_roughness) {
|
||||
// we need to lie the derivatives (normg) and assume that DP side is always the same
|
||||
// to get proper texure filtering
|
||||
vec2 normg=norm.xy;
|
||||
norm.y+=max(0.0,sign(norm.z))*0.5;
|
||||
if (norm.z>0) {
|
||||
norm.y=0.5-norm.y+0.5;
|
||||
}
|
||||
|
||||
// thanks to OpenGL spec using floor(layer + 0.5) for texture arrays,
|
||||
// it's easy to have precision errors using fract() to interpolate layers
|
||||
@ -451,7 +453,9 @@ vec3 textureDualParaboloid(sampler2D p_tex, vec3 p_vec,float p_roughness) {
|
||||
vec3 norm = normalize(p_vec);
|
||||
norm.xy/=1.0+abs(norm.z);
|
||||
norm.xy=norm.xy * vec2(0.5,0.25) + vec2(0.5,0.25);
|
||||
norm.y+=max(0.0,sign(norm.z))*0.5;
|
||||
if (norm.z>0) {
|
||||
norm.y=0.5-norm.y+0.5;
|
||||
}
|
||||
return textureLod(p_tex, norm.xy, p_roughness * RADIANCE_MAX_LOD).xyz;
|
||||
}
|
||||
|
||||
|
@ -554,10 +554,10 @@ static void _generate_tangents_and_binormals(const PoolVector<int> &p_indices, c
|
||||
tangent = Vector3();
|
||||
} else {
|
||||
tangent = Vector3((t2 * x1 - t1 * x2) * r, (t2 * y1 - t1 * y2) * r,
|
||||
(t2 * z1 - t1 * z2) * r)
|
||||
(t2 * z1 - t1 * z2) * r)
|
||||
.normalized();
|
||||
binormal = Vector3((s1 * x2 - s2 * x1) * r, (s1 * y2 - s2 * y1) * r,
|
||||
(s1 * z2 - s2 * z1) * r)
|
||||
(s1 * z2 - s2 * z1) * r)
|
||||
.normalized();
|
||||
}
|
||||
|
||||
@ -920,8 +920,6 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me
|
||||
bn.z = -bn.z;
|
||||
|
||||
vertex.tangent.d = vertex.normal.cross(vertex.tangent.normal).dot(bn) > 0 ? 1 : -1;
|
||||
|
||||
print_line("Tangent " + itos(p_i) + ": " + vertex.tangent);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -153,6 +153,9 @@ static void _compress_etc(Image *p_img, float p_lossy_quality, bool force_etc1_f
|
||||
Etc::Image::Format etc2comp_etc_format = _image_format_to_etc2comp_format(etc_format);
|
||||
|
||||
int wofs = 0;
|
||||
|
||||
print_line("begin encoding, format: " + Image::get_format_name(etc_format));
|
||||
uint64_t t = OS::get_singleton()->get_ticks_msec();
|
||||
for (int i = 0; i < mmc + 1; i++) {
|
||||
// convert source image to internal etc2comp format (which is equivalent to Image::FORMAT_RGBAF)
|
||||
// NOTE: We can alternatively add a case to Image::convert to handle Image::FORMAT_RGBAF conversion.
|
||||
@ -177,6 +180,7 @@ static void _compress_etc(Image *p_img, float p_lossy_quality, bool force_etc1_f
|
||||
delete[] etc_data;
|
||||
delete[] src_rgba_f;
|
||||
}
|
||||
print_line("time encoding: " + rtos(OS::get_singleton()->get_ticks_msec() - t));
|
||||
|
||||
p_img->create(imgw, imgh, mmc > 1 ? true : false, etc_format, dst_data);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user