fixes for gles mode

This commit is contained in:
milek7
2019-09-27 13:26:00 +02:00
parent cebf5de86a
commit a3abdeac63
6 changed files with 31 additions and 19 deletions

View File

@@ -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<int64_t> 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<GLuint*>(&value));
return std::optional<int64_t>(value);
}
return std::nullopt;

View File

@@ -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";

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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