Some more GLES2 tuning..
This commit is contained in:
parent
3333166b07
commit
ce8294986d
|
@ -2227,6 +2227,7 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements,
|
|||
if (p_env) {
|
||||
state.scene_shader.set_uniform(SceneShaderGLES2::BG_ENERGY, p_env->bg_energy);
|
||||
state.scene_shader.set_uniform(SceneShaderGLES2::AMBIENT_SKY_CONTRIBUTION, p_env->ambient_sky_contribution);
|
||||
|
||||
state.scene_shader.set_uniform(SceneShaderGLES2::AMBIENT_COLOR, p_env->ambient_color);
|
||||
state.scene_shader.set_uniform(SceneShaderGLES2::AMBIENT_ENERGY, p_env->ambient_energy);
|
||||
|
||||
|
|
|
@ -948,6 +948,7 @@ void RasterizerStorageGLES2::sky_set_texture(RID p_sky, RID p_panorama, int p_ra
|
|||
shaders.cubemap_filter.set_uniform(CubemapFilterShaderGLES2::FACE_ID, i);
|
||||
|
||||
float roughness = mm_level ? lod / (float)(mipmaps - 1) : 1;
|
||||
roughness = MIN(1.0, roughness); //keep max at 1
|
||||
shaders.cubemap_filter.set_uniform(CubemapFilterShaderGLES2::ROUGHNESS, roughness);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
@ -4492,13 +4493,13 @@ void RasterizerStorageGLES2::initialize() {
|
|||
|
||||
// radical inverse vdc cache texture
|
||||
// used for cubemap filtering
|
||||
if (config.float_texture_supported) {
|
||||
if (true /*||config.float_texture_supported*/) { //uint8 is similar and works everywhere
|
||||
glGenTextures(1, &resources.radical_inverse_vdc_cache_tex);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, resources.radical_inverse_vdc_cache_tex);
|
||||
|
||||
float radical_inverse[512];
|
||||
uint8_t radical_inverse[512];
|
||||
|
||||
for (uint32_t i = 0; i < 512; i++) {
|
||||
uint32_t bits = i;
|
||||
|
@ -4510,11 +4511,10 @@ void RasterizerStorageGLES2::initialize() {
|
|||
bits = ((bits & 0x00FF00FF) << 8) | ((bits & 0xFF00FF00) >> 8);
|
||||
|
||||
float value = float(bits) * 2.3283064365386963e-10;
|
||||
|
||||
radical_inverse[i] = value;
|
||||
radical_inverse[i] = uint8_t(CLAMP(value * 255.0, 0, 255));
|
||||
}
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 512, 1, 0, GL_LUMINANCE, GL_FLOAT, radical_inverse);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 512, 1, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, radical_inverse);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
}
|
||||
|
|
|
@ -167,17 +167,21 @@ void main() {
|
|||
|
||||
vec3 H = ImportanceSampleGGX(xi, roughness, N);
|
||||
vec3 V = N;
|
||||
vec3 L = normalize(2.0 * dot(V, H) * H - V);
|
||||
vec3 L = (2.0 * dot(V, H) * H - V);
|
||||
|
||||
float NdotL = clamp(dot(N, L), 0.0, 1.0);
|
||||
|
||||
if (NdotL > 0.0) {
|
||||
|
||||
#ifdef USE_SOURCE_PANORAMA
|
||||
sum.rgb += texturePanorama(source_panorama, L).rgb * NdotL;
|
||||
vec3 val = texturePanorama(source_panorama, L).rgb;
|
||||
#else
|
||||
sum.rgb += textureCubeLod(source_cube, L, 0.0).rgb * NdotL;
|
||||
vec3 val = textureCubeLod(source_cube, L,0.0).rgb;
|
||||
#endif
|
||||
//mix using Linear, to approximate high end back-end
|
||||
val = mix(pow((val + vec3(0.055)) * (1.0 / (1.0 + 0.055)), vec3(2.4)), val * (1.0 / 12.92), vec3(lessThan(val, vec3(0.04045))));
|
||||
|
||||
sum.rgb += val * NdotL;
|
||||
|
||||
sum.a += NdotL;
|
||||
}
|
||||
|
@ -185,5 +189,8 @@ void main() {
|
|||
|
||||
sum /= sum.a;
|
||||
|
||||
vec3 a = vec3(0.055);
|
||||
sum.rgb = mix((vec3(1.0) + a) * pow(sum.rgb, vec3(1.0 / 2.4)) - a, 12.92 * sum.rgb, vec3(lessThan(sum.rgb, vec3(0.0031308))));
|
||||
|
||||
gl_FragColor = vec4(sum.rgb, 1.0);
|
||||
}
|
||||
|
|
|
@ -1757,8 +1757,14 @@ FRAGMENT_SHADER_CODE
|
|||
|
||||
// environment BRDF approximation
|
||||
|
||||
// TODO shadeless
|
||||
|
||||
{
|
||||
|
||||
#if defined(DIFFUSE_TOON)
|
||||
//simplify for toon, as
|
||||
specular_light *= specular * metallic * albedo * 2.0;
|
||||
#else
|
||||
//TODO: this curve is not really designed for gammaspace, should be adjusted
|
||||
const vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022);
|
||||
const vec4 c1 = vec4(1.0, 0.0425, 1.04, -0.04);
|
||||
vec4 r = roughness * c0 + c1;
|
||||
|
@ -1768,9 +1774,15 @@ FRAGMENT_SHADER_CODE
|
|||
|
||||
vec3 specular_color = metallic_to_specular_color(metallic, specular, albedo);
|
||||
specular_light *= AB.x * specular_color + AB.y;
|
||||
#endif
|
||||
}
|
||||
|
||||
gl_FragColor = vec4(ambient_light + diffuse_light + specular_light, alpha);
|
||||
|
||||
//add emission if in base pass
|
||||
#ifdef BASE_PASS
|
||||
gl_FragColor.rgb += emission;
|
||||
#endif
|
||||
// gl_FragColor = vec4(normal, 1.0);
|
||||
|
||||
#endif //unshaded
|
||||
|
|
Loading…
Reference in New Issue