16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-22 20:59:19 +02:00

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 "stdafx.h"
#include "query.h" #include "query.h"
#include "Globals.h"
gl::query::query(targets target) gl::query::query(targets target)
: target(target) : target(target)
@@ -35,9 +36,13 @@ std::optional<int64_t> gl::query::result()
{ {
GLuint ready; GLuint ready;
glGetQueryObjectuiv(*this, GL_QUERY_RESULT_AVAILABLE, &ready); glGetQueryObjectuiv(*this, GL_QUERY_RESULT_AVAILABLE, &ready);
int64_t value; int64_t value = 0;
if (ready) { 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::optional<int64_t>(value);
} }
return std::nullopt; return std::nullopt;

View File

@@ -220,11 +220,11 @@ gl::shader::shader(const std::string &filename)
} }
else else
{ {
if (type == GL_GEOMETRY_SHADER) { if (GLAD_GL_ES_VERSION_3_1) {
str += "#version 310 es\n"; str += "#version 310 es\n";
str += "#extension EXT_geometry_shader : require\n"; if (type == GL_GEOMETRY_SHADER)
} str += "#extension GL_EXT_geometry_shader : require\n";
else { } else {
str += "#version 300 es\n"; str += "#version 300 es\n";
} }
str += "precision highp float;\n"; str += "precision highp float;\n";

View File

@@ -3444,9 +3444,16 @@ void opengl_renderer::Render_Alpha(TSubModel *Submodel)
// main draw call // main draw call
if (Submodel->occlusion_query) { if (Submodel->occlusion_query) {
glBeginConditionalRender(*Submodel->occlusion_query, GL_QUERY_WAIT); if (!Global.gfx_usegles) {
draw(m_billboardgeometry); glBeginConditionalRender(*Submodel->occlusion_query, GL_QUERY_WAIT);
glEndConditionalRender(); draw(m_billboardgeometry);
glEndConditionalRender();
}
else {
auto result = Submodel->occlusion_query->result();
if (result && *result)
draw(m_billboardgeometry);
}
} }
else else
draw(m_billboardgeometry); draw(m_billboardgeometry);

View File

@@ -47,7 +47,7 @@ void main()
discard; discard;
normal.xy = (texture(normalmap, f_coord).rg * 2.0 - 1.0); 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)); normal = normalize(f_tbn * normalize(normal.xyz));
//vec3 normal = normalize(f_tbn * normalize(texture(normalmap, f_coord).rgb * 2.0 - 1.0)); //vec3 normal = normalize(f_tbn * normalize(texture(normalmap, f_coord).rgb * 2.0 - 1.0));
vec3 refvec = reflect(f_pos.xyz, normal); vec3 refvec = reflect(f_pos.xyz, normal);

View File

@@ -54,7 +54,7 @@ void main()
discard; discard;
vec3 normal; vec3 normal;
normal.xy = (texture(normalmap, f_coord_p).rg * 2.0 - 1.0); 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)); normal_p = normalize(f_tbn * normalize(normal.xyz));
vec3 refvec = reflect(f_pos.xyz, normal_p); vec3 refvec = reflect(f_pos.xyz, normal_p);
#if ENVMAP_ENABLED #if ENVMAP_ENABLED
@@ -107,11 +107,11 @@ vec2 ParallaxMapping(vec2 f_coord, vec3 viewDir)
#if ENVMAP_ENABLED #if ENVMAP_ENABLED
const float minLayers = 8.0; const float minLayers = 8.0;
const float maxLayers = 32.0; const float maxLayers = 32.0;
float LayersWeight = 1; float LayersWeight = 1.0;
if (length(f_pos.xyz) > 20) if (length(f_pos.xyz) > 20.0)
LayersWeight = 1; LayersWeight = 1.0;
else else
LayersWeight = (length(f_pos.xyz) / 20); LayersWeight = (length(f_pos.xyz) / 20.0);
vec2 currentTexCoords = f_coord; vec2 currentTexCoords = f_coord;
float currentDepthMapValue = texture(normalmap, currentTexCoords).b; float currentDepthMapValue = texture(normalmap, currentTexCoords).b;
LayersWeight = min(abs(dot(vec3(0.0, 0.0, 1.0), viewDir)),LayersWeight); 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); vec2 p = viewDir.xy / viewDir.z * (height * param[2].y - param[2].z);
return f_coord - p; return f_coord - p;
#endif #endif
} }

View File

@@ -38,7 +38,7 @@ uniform samplerCube envmap;
#endif #endif
//wave distortion variables //wave distortion variables
float move_factor = 0; float move_factor = 0.0;
vec3 normal_d; vec3 normal_d;
#define WATER #define WATER
@@ -49,7 +49,7 @@ void main()
{ {
//wave distortion //wave distortion
move_factor += (param[2].z * time); 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 texture_coords = f_coord;
vec2 distorted_tex_coord = texture(dudvmap, vec2(texture_coords.x + move_factor, texture_coords.y)).rg * 0.1; 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); distorted_tex_coord = texture_coords + vec2(distorted_tex_coord.x , distorted_tex_coord.y + move_factor);
@@ -58,7 +58,7 @@ void main()
vec3 normal; vec3 normal;
normal.xy = (texture(normalmap, texture_coords).rg * 2.0 - 1.0); 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)); normal_d = normalize(f_tbn * normalize(normal.xyz));
vec3 refvec = reflect(f_pos.xyz, normal_d); vec3 refvec = reflect(f_pos.xyz, normal_d);
#if ENVMAP_ENABLED #if ENVMAP_ENABLED