Skip to content

Commit

Permalink
Merge pull request #42 from nikp123/unstable
Browse files Browse the repository at this point in the history
Update to 0.7.1.0
  • Loading branch information
nikp123 authored Oct 26, 2021
2 parents dc62314 + 820c755 commit 898ebc8
Show file tree
Hide file tree
Showing 53 changed files with 1,373 additions and 755 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ jobs:
- sys: mingw32
arch: i686
icon: ''
cmake-args: -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/usr
cmake-args: -DBUILD_LEGACY_OUTPUTS:BOOL=ON -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/usr
build-args: '--parallel'
env:
CFLAGS: -Wdeclaration-after-statement -Werror
CXXFLAGS: -Werror
- sys: mingw64
arch: x86_64
icon: '🟦'
cmake-args: -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/usr
cmake-args: -DBUILD_LEGACY_OUTPUTS:BOOL=ON -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/usr
build-args: --parallel
env:
CFLAGS: -Wdeclaration-after-statement -Werror
Expand Down Expand Up @@ -55,6 +55,7 @@ jobs:
mingw-w64-${{matrix.arch}}-fftw
mingw-w64-${{matrix.arch}}-glew
mingw-w64-${{matrix.arch}}-nsis
mingw-w64-${{matrix.arch}}-SDL2
- name: Build in debug mode
env: ${{ matrix.env }}
Expand Down
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "lib/iniparser"]
path = lib/iniparser
url = https://github.com/ndevilla/iniparser
[submodule "lib/efsw"]
path = lib/efsw
url = https://github.com/SpartanJ/efsw
[submodule "lib/x-watcher"]
path = lib/x-watcher
url = https://github.com/nikp123/x-watcher
55 changes: 44 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ endif()
# Define XAVA version
set(xava_VERSION_MAJOR 0)
set(xava_VERSION_MINOR 7)
set(xava_VERSION_PATCH 0)
set(xava_VERSION_PATCH 1)
set(xava_VERSION_TWEAK 0)
set(xava_VERSION "${xava_VERSION_MAJOR}.${xava_VERSION_MINOR}.${xava_VERSION_PATCH}.${xava_VERSION_TWEAK}")

Expand Down Expand Up @@ -74,10 +74,12 @@ if(MINGW)
set(CMAKE_SHARED_LINKER_FLAGS "-static")
else()
# This hack is a of courtesy of: https://stackoverflow.com/a/40947954/3832385
string(LENGTH "${CMAKE_SOURCE_DIR}/" SOURCE_PATH_SIZE)
add_definitions("-DSOURCE_PATH_SIZE=${SOURCE_PATH_SIZE}")
set(BUILD_DEBUG_FLAGS "-rdynamic")
set(CMAKE_SHARED_LINKER_FLAGS "-rdynamic")
if(GNU)
string(LENGTH "${CMAKE_SOURCE_DIR}/" SOURCE_PATH_SIZE)
add_definitions("-DSOURCE_PATH_SIZE=${SOURCE_PATH_SIZE}")
set(BUILD_DEBUG_FLAGS "-rdynamic")
set(CMAKE_SHARED_LINKER_FLAGS "-rdynamic")
endif()
endif()


Expand Down Expand Up @@ -175,12 +177,43 @@ endforeach()
install (TARGETS xava DESTINATION bin)
install (FILES "${CMAKE_CURRENT_BINARY_DIR}/final-LICENSE.txt" DESTINATION share/licenses/xava)
install (FILES example_files/config RENAME config.example DESTINATION share/xava)
install (FILES example_files/gl/shaders/pre/default/vertex.glsl RENAME vertex.glsl.example DESTINATION share/xava/gl/shaders/pre/default)
install (FILES example_files/gl/shaders/pre/default/fragment.glsl RENAME fragment.glsl.example DESTINATION share/xava/gl/shaders/pre/default)
install (FILES example_files/gl/shaders/post/default/vertex.glsl RENAME vertex.glsl.example DESTINATION share/xava/gl/shaders/post/default)
install (FILES example_files/gl/shaders/post/default/fragment.glsl RENAME fragment.glsl.example DESTINATION share/xava/gl/shaders/post/default)
install (FILES example_files/gl/shaders/post/kinetic/vertex.glsl RENAME vertex.glsl.example DESTINATION share/xava/gl/shaders/post/kinetic)
install (FILES example_files/gl/shaders/post/kinetic/fragment.glsl RENAME fragment.glsl.example DESTINATION share/xava/gl/shaders/post/kinetic)

# Install vertex shaders
file(GLOB filters "example_files/gl/shaders/*/*/vertex.glsl" )
foreach(files ${filters})
get_filename_component(path ${files} REALPATH DIRECTORY)
string(REPLACE "${xava_SOURCE_DIR}/example_files/" "" target_path ${path})
string(REPLACE "vertex.glsl" "" target_path ${target_path})
install(FILES "example_files/${target_path}/vertex.glsl" RENAME vertex.glsl.example DESTINATION "share/xava/${target_path}")
endforeach()

# Install geometry shaders
file(GLOB filters "example_files/gl/shaders/*/*/geometry.glsl" )
foreach(files ${filters})
get_filename_component(path ${files} REALPATH DIRECTORY)
string(REPLACE "${xava_SOURCE_DIR}/example_files/" "" target_path ${path})
string(REPLACE "geometry.glsl" "" target_path ${target_path})
install(FILES "example_files/${target_path}/geometry.glsl" RENAME geometry.glsl.example DESTINATION "share/xava/${target_path}")
endforeach()

# Install fragment shaders
file(GLOB filters "example_files/gl/shaders/*/*/fragment.glsl" )
foreach(files ${filters})
get_filename_component(path ${files} REALPATH DIRECTORY)
string(REPLACE "${xava_SOURCE_DIR}/example_files/" "" target_path ${path})
string(REPLACE "fragment.glsl" "" target_path ${target_path})
install(FILES "example_files/${target_path}/fragment.glsl" RENAME fragment.glsl.example DESTINATION "share/xava/${target_path}")
endforeach()

# Install shader configs
file(GLOB filters "example_files/gl/shaders/*/*/config.ini" )
foreach(files ${filters})
get_filename_component(path ${files} REALPATH DIRECTORY)
string(REPLACE "${xava_SOURCE_DIR}/example_files/" "" target_path ${path})
string(REPLACE "config.ini" "" target_path ${target_path})
install(FILES "example_files/${target_path}/config.ini" RENAME config.ini.example DESTINATION "share/xava/${target_path}")
endforeach()

if(UNIX AND NOT APPLE)
install (FILES ${CMAKE_BINARY_DIR}/xava.desktop DESTINATION share/applications)
install (FILES assets/linux/xava.svg DESTINATION share/icons/hicolor/scalable/apps)
Expand Down
14 changes: 0 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ a fork of [Karl Stavestrand's](mailto:[email protected]) [C.A.V.A.](https://gi
- [Vsync](#vsync)
- [Bars](#bars)
- [Colors and gradients](#colors-and-gradients)
- [Shadow](#shadow)
- [Accent colors](#accent-colors)
- [Additional options](#additional-options)
- [Contribution](#contribution)
Expand Down Expand Up @@ -684,19 +683,6 @@ enable them by changing:
...


### Shadow

XAVA can render shadows around the bars so to make the
visualizer look like it's floating on your desktop.
In the ``shadow`` section you'll find these two options:

size = *in pixels*
color = *hex color string in the following format '#aarrggbb'*

You need to be running the "supported" mode and a shader that supports shadows
for this to work (by default, the shaders do support shadows).


### Additional options

XAVA still has plenty to offer, just look up all of the options in the config
Expand Down
17 changes: 7 additions & 10 deletions example_files/config
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,13 @@
# Adjusts the input buffer size (in samples, calculated by 2^input_size)
; size = 12

# Adjust the sample rate of the input audio (if possible)
; rate = 44100

# Adjust the capture packets of an input (if possible, in samples)
# A lower value means less latency, although it comes with a high CPU cost
; latency = 128


[output]

Expand Down Expand Up @@ -260,16 +267,6 @@
; gradient_color_2 = '#ff3399'


[shadow]

# Fake shadow effect (woks with supported modes only)
# To disable shadows, set size to 0
; size = 7

# Color format is #aarrggbb
; color = "#ff000000"


[stars]

# For stars to work, you need a speical output mode that supports it
Expand Down
45 changes: 21 additions & 24 deletions example_files/gl/shaders/post/default/fragment.glsl
Original file line number Diff line number Diff line change
@@ -1,37 +1,34 @@
#ifdef GL_ES
precision mediump float;
#endif
#version 420 core

varying vec2 v_texCoord;
in vec2 texCoord;

uniform sampler2D s_texture;
uniform sampler2D s_depth;
uniform sampler2D color_texture;
uniform sampler2D depth_texture;

uniform vec4 shadow_color;
uniform vec2 shadow_offset;
uniform vec4 background_color;

uniform vec4 bgcolor;
layout(location=0) out vec4 FragColor;

// Credit: https://github.com/Jam3/glsl-fast-gaussian-blur/blob/master/5.glsl
vec4 blur5(sampler2D image, vec2 uv, vec2 resolution, vec2 direction) {
vec4 color = vec4(0.0);
vec2 off1 = vec2(1.3333333333333333) * direction;
color += texture2D(image, uv) * 0.29411764705882354;
color += texture2D(image, uv + (off1 / resolution)) * 0.35294117647058826;
color += texture2D(image, uv - (off1 / resolution)) * 0.35294117647058826;
return color;
vec4 correctForAlphaBlend(vec4 color) {
return vec4(color.rgb*color.a, color.a);
}

vec4 append_color_properly(vec4 source, vec4 target) {
target.rgb += source.rgb*source.a;
target.a = max(source.a, target.a);
return target;
}

void main() {
vec4 depth = texture2D(s_depth, v_texCoord);
vec4 depth = texture(depth_texture, texCoord);

// test if infinite
if(depth.r == 1.0) {
float color = 1.0 - blur5(s_depth, shadow_offset+v_texCoord, vec2(2.0, 2.0), shadow_offset).r;
color *= 1.6; // strenghten shadows
gl_FragColor = mix(bgcolor, shadow_color, color);
} else {
gl_FragColor = texture2D(s_texture, v_texCoord);
FragColor = background_color;
if(depth.r != 1.0) {
FragColor = append_color_properly(texture(color_texture, texCoord),
FragColor);
}

FragColor = correctForAlphaBlend(FragColor);
}

14 changes: 6 additions & 8 deletions example_files/gl/shaders/post/default/vertex.glsl
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
#ifdef GL_ES
precision mediump float;
#endif
#version 420 core

// input vertex and texture coordinate
attribute vec4 a_position;
attribute vec2 a_texCoord;
in vec4 v_texCoord; // vertex
in vec2 m_texCoord; // mapping

// output texture map coordinate
varying vec2 v_texCoord;
out vec2 texCoord;

void main() {
gl_Position = a_position;
v_texCoord = a_texCoord;
gl_Position = v_texCoord;
texCoord = m_texCoord;
}
48 changes: 20 additions & 28 deletions example_files/gl/shaders/post/kinetic/fragment.glsl
Original file line number Diff line number Diff line change
@@ -1,42 +1,34 @@
#ifdef GL_ES
precision mediump float;
#endif
#version 420 core

varying vec2 v_texCoord;
in vec2 texCoord;

uniform sampler2D s_texture;
uniform sampler2D s_depth;
uniform sampler2D color_texture;
uniform sampler2D depth_texture;

uniform vec4 shadow_color;
uniform vec2 shadow_offset;

uniform vec4 bgcolor;
uniform vec4 background_color;

uniform float intensity;

// Credit: https://github.com/Jam3/glsl-fast-gaussian-blur/blob/master/5.glsl
vec4 blur5(sampler2D image, vec2 uv, vec2 resolution, vec2 direction) {
vec4 color = vec4(0.0);
vec2 off1 = vec2(1.3333333333333333) * direction;
color += texture2D(image, uv) * 0.29411764705882354;
color += texture2D(image, uv + (off1 / resolution)) * 0.35294117647058826;
color += texture2D(image, uv - (off1 / resolution)) * 0.35294117647058826;
return color;
layout(location=0) out vec4 FragColor;

vec4 correctForAlphaBlend(vec4 color) {
return vec4(color.rgb*color.a, color.a);
}

vec4 append_color_properly(vec4 source, vec4 target) {
target.a = target.a > source.a ? target.a : source.a;
target.rgb += source.rgb*target.a;
return target;
}

void main() {
vec4 depth = texture2D(s_depth, v_texCoord);
vec4 depth = texture(depth_texture, texCoord);

// test if infinite
if(depth.r == 1.0) {
vec4 bg = mix(vec4(0.0, 0.0, 0.0, 0.0), bgcolor, 1.0-intensity);

float depth = 1.0 - blur5(s_depth, shadow_offset+v_texCoord, vec2(2.0, 2.0), shadow_offset).r;
depth *= 1.6; // strenghten shadows
FragColor = append_color_properly(
texture(color_texture, texCoord),
vec4(background_color.rgb, background_color.a*(1.0-intensity)));

gl_FragColor = mix(bg, shadow_color, depth);
} else {
gl_FragColor = texture2D(s_texture, v_texCoord);
}
//FragColor = correctForAlphaBlend(FragColor);
}

12 changes: 7 additions & 5 deletions example_files/gl/shaders/post/kinetic/vertex.glsl
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#version 420 core

// input vertex and texture coordinate
attribute vec4 a_position;
attribute vec2 a_texCoord;
in vec4 v_texCoord; // vertex
in vec2 m_texCoord; // mapping

// output texture map coordinate
varying vec2 v_texCoord;
out vec2 texCoord;

void main() {
gl_Position = a_position;
v_texCoord = a_texCoord;
gl_Position = v_texCoord;
texCoord = m_texCoord;
}
54 changes: 54 additions & 0 deletions example_files/gl/shaders/post/shadow/fragment.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#version 420 core

in vec2 texCoord;

uniform sampler2D color_texture;
uniform sampler2D depth_texture;

uniform vec2 resolution;

vec4 shadow_color = vec4(0.0, 0.0, 0.0, 1.0);
vec2 shadow_offset;

uniform vec4 background_color;

layout(location=0) out vec4 FragColor;

// Credit: https://github.com/Jam3/glsl-fast-gaussian-blur/blob/master/5.glsl
vec4 blur5(sampler2D image, vec2 uv, vec2 resolution, vec2 direction) {
vec4 color = vec4(0.0);
vec2 off1 = vec2(1.3333333333333333) * direction;
color += texture(image, uv) * 0.29411764705882354;
color += texture(image, uv + (off1 / resolution)) * 0.35294117647058826;
color += texture(image, uv - (off1 / resolution)) * 0.35294117647058826;
return color;
}

vec4 correctForAlphaBlend(vec4 color) {
return vec4(color.rgb*color.a, color.a);
}

vec4 append_color_properly(vec4 source, vec4 target) {
target.rgb += source.rgb*source.a;
target.a = max(source.a, target.a);
return target;
}

void main() {
vec4 depth = texture(depth_texture, texCoord);

shadow_offset = vec2(-5.0, 5.0) / resolution;

// test if infinite
FragColor = background_color;
if(depth.r == 1.0) {
float color = 1.0 - blur5(depth_texture, shadow_offset+texCoord, vec2(2.0, 2.0), shadow_offset).r;
FragColor = mix(FragColor, shadow_color, color);
}

FragColor = append_color_properly(texture(color_texture, texCoord),
FragColor);

FragColor = correctForAlphaBlend(FragColor);
}

Loading

0 comments on commit 898ebc8

Please sign in to comment.