diff --git a/gl/query.cpp b/gl/query.cpp index f46d6a6a..d98451b8 100644 --- a/gl/query.cpp +++ b/gl/query.cpp @@ -1,5 +1,6 @@ #include "stdafx.h" #include "query.h" +#include "Globals.h" gl::query::query(targets target) : target(target) @@ -35,9 +36,13 @@ std::optional gl::query::result() { GLuint ready; glGetQueryObjectuiv(*this, GL_QUERY_RESULT_AVAILABLE, &ready); - int64_t value; + int64_t value = 0; if (ready) { - glGetQueryObjecti64v(*this, GL_QUERY_RESULT, &value); + if (!Global.gfx_usegles) + glGetQueryObjecti64v(*this, GL_QUERY_RESULT, &value); + else + glGetQueryObjectuiv(*this, GL_QUERY_RESULT, reinterpret_cast(&value)); + return std::optional(value); } return std::nullopt; diff --git a/gl/shader.cpp b/gl/shader.cpp index 4a524578..f4d7f3c7 100644 --- a/gl/shader.cpp +++ b/gl/shader.cpp @@ -220,11 +220,11 @@ gl::shader::shader(const std::string &filename) } else { - if (type == GL_GEOMETRY_SHADER) { + if (GLAD_GL_ES_VERSION_3_1) { str += "#version 310 es\n"; - str += "#extension EXT_geometry_shader : require\n"; - } - else { + if (type == GL_GEOMETRY_SHADER) + str += "#extension GL_EXT_geometry_shader : require\n"; + } else { str += "#version 300 es\n"; } str += "precision highp float;\n"; diff --git a/renderer.cpp b/renderer.cpp index 97873a9f..61977168 100644 --- a/renderer.cpp +++ b/renderer.cpp @@ -3444,9 +3444,16 @@ void opengl_renderer::Render_Alpha(TSubModel *Submodel) // main draw call if (Submodel->occlusion_query) { - glBeginConditionalRender(*Submodel->occlusion_query, GL_QUERY_WAIT); - draw(m_billboardgeometry); - glEndConditionalRender(); + if (!Global.gfx_usegles) { + glBeginConditionalRender(*Submodel->occlusion_query, GL_QUERY_WAIT); + draw(m_billboardgeometry); + glEndConditionalRender(); + } + else { + auto result = Submodel->occlusion_query->result(); + if (result && *result) + draw(m_billboardgeometry); + } } else draw(m_billboardgeometry); diff --git a/shaders/mat_normalmap.frag b/shaders/mat_normalmap.frag index cae429aa..ec3c9732 100644 --- a/shaders/mat_normalmap.frag +++ b/shaders/mat_normalmap.frag @@ -47,7 +47,7 @@ void main() discard; normal.xy = (texture(normalmap, f_coord).rg * 2.0 - 1.0); - normal.z = sqrt(1 - clamp((dot(normal.xy, normal.xy)), 0.0, 1.0)); + normal.z = sqrt(1.0 - clamp((dot(normal.xy, normal.xy)), 0.0, 1.0)); normal = normalize(f_tbn * normalize(normal.xyz)); //vec3 normal = normalize(f_tbn * normalize(texture(normalmap, f_coord).rgb * 2.0 - 1.0)); vec3 refvec = reflect(f_pos.xyz, normal); diff --git a/shaders/mat_parallax.frag b/shaders/mat_parallax.frag index 41b11a63..687d7207 100644 --- a/shaders/mat_parallax.frag +++ b/shaders/mat_parallax.frag @@ -54,7 +54,7 @@ void main() discard; vec3 normal; normal.xy = (texture(normalmap, f_coord_p).rg * 2.0 - 1.0); - normal.z = sqrt(1 - clamp((dot(normal.xy, normal.xy)), 0.0, 1.0)); + normal.z = sqrt(1.0 - clamp((dot(normal.xy, normal.xy)), 0.0, 1.0)); normal_p = normalize(f_tbn * normalize(normal.xyz)); vec3 refvec = reflect(f_pos.xyz, normal_p); #if ENVMAP_ENABLED @@ -107,11 +107,11 @@ vec2 ParallaxMapping(vec2 f_coord, vec3 viewDir) #if ENVMAP_ENABLED const float minLayers = 8.0; const float maxLayers = 32.0; - float LayersWeight = 1; - if (length(f_pos.xyz) > 20) - LayersWeight = 1; + float LayersWeight = 1.0; + if (length(f_pos.xyz) > 20.0) + LayersWeight = 1.0; else - LayersWeight = (length(f_pos.xyz) / 20); + LayersWeight = (length(f_pos.xyz) / 20.0); vec2 currentTexCoords = f_coord; float currentDepthMapValue = texture(normalmap, currentTexCoords).b; LayersWeight = min(abs(dot(vec3(0.0, 0.0, 1.0), viewDir)),LayersWeight); @@ -143,4 +143,4 @@ vec2 ParallaxMapping(vec2 f_coord, vec3 viewDir) vec2 p = viewDir.xy / viewDir.z * (height * param[2].y - param[2].z); return f_coord - p; #endif -} \ No newline at end of file +} diff --git a/shaders/mat_water.frag b/shaders/mat_water.frag index 3eba83ea..02bba734 100644 --- a/shaders/mat_water.frag +++ b/shaders/mat_water.frag @@ -38,7 +38,7 @@ uniform samplerCube envmap; #endif //wave distortion variables -float move_factor = 0; +float move_factor = 0.0; vec3 normal_d; #define WATER @@ -49,7 +49,7 @@ void main() { //wave distortion move_factor += (param[2].z * time); - move_factor = mod(move_factor, 1); + move_factor = mod(move_factor, 1.0); vec2 texture_coords = f_coord; vec2 distorted_tex_coord = texture(dudvmap, vec2(texture_coords.x + move_factor, texture_coords.y)).rg * 0.1; distorted_tex_coord = texture_coords + vec2(distorted_tex_coord.x , distorted_tex_coord.y + move_factor); @@ -58,7 +58,7 @@ void main() vec3 normal; normal.xy = (texture(normalmap, texture_coords).rg * 2.0 - 1.0); - normal.z = sqrt(1 - clamp((dot(normal.xy, normal.xy)), 0.0, 1.0)); + normal.z = sqrt(1.0 - clamp((dot(normal.xy, normal.xy)), 0.0, 1.0)); normal_d = normalize(f_tbn * normalize(normal.xyz)); vec3 refvec = reflect(f_pos.xyz, normal_d); #if ENVMAP_ENABLED