RetroArch
fft_heightmap.glsl.vert.h
Go to the documentation of this file.
1 #include "shaders_common.h"
2 
4  layout(location = 0) in vec2 aVertex;
5  uniform sampler2D sHeight;
6  uniform mat4 uMVP;
7  uniform ivec2 uOffset;
8  uniform vec4 uHeightmapParams;
9  uniform float uAngleScale;
10  out vec3 vWorldPos;
11  out vec3 vHeight;
12 
13  void main() {
14  vec2 tex_coord = vec2(aVertex.x + float(uOffset.x) + 0.5, -aVertex.y + float(uOffset.y) + 0.5) / vec2(textureSize(sHeight, 0));
15 
16  vec3 world_pos = vec3(aVertex.x, 0.0, aVertex.y);
17  world_pos.xz += uHeightmapParams.xy;
18 
19  float angle = world_pos.x * uAngleScale;
20  world_pos.xz *= uHeightmapParams.zw;
21 
22  float lod = log2(world_pos.z + 1.0) - 6.0;
23  vec4 heights = textureLod(sHeight, tex_coord, lod);
24 
25  float cangle = cos(angle);
26  float sangle = sin(angle);
27 
28  int c = int(-sign(world_pos.x) + 1.0);
29  float height = mix(heights[c], heights[1], abs(angle) / 3.141592653);
30  height = height * 80.0 - 40.0;
31 
32  vec3 up = vec3(-sangle, cangle, 0.0);
33 
34  float base_y = 80.0 - 80.0 * cangle;
35  float base_x = 80.0 * sangle;
36  world_pos.xy = vec2(base_x, base_y);
37  world_pos += up * height;
38 
39  vWorldPos = world_pos;
40  vHeight = vec3(height, heights.yw * 80.0 - 40.0);
41  gl_Position = uMVP * vec4(world_pos, 1.0);
42  }
43 );
#define GLSL_300(src)
Definition: shaders_common.h:11
sampler2DBase< glm::vec4 > sampler2D
Definition: sampler.hpp:94
GLfloat angle
Definition: glext.h:11760
static const char * fft_vertex_program_heightmap
Definition: fft_heightmap.glsl.vert.h:3
struct passwd out
Definition: missing_libc_functions.c:51
const GLubyte * c
Definition: glext.h:9812
GLint lod
Definition: glext.h:8462
GLint location
Definition: glext.h:6690
GLuint in
Definition: glext.h:10523
#define sin(x)
Definition: math.h:23
int main(int argc, char *argv[])
Definition: send-presence.c:197
#define cos(x)
Definition: math.h:21
def sign()
Definition: build.py:201
#define gl_Position
Definition: internal_interface.hpp:385
bool up
Definition: connect_wiiupro.c:50
GLint GLint GLsizei GLsizei height
Definition: glext.h:6293