Skip to content

Commit

Permalink
[resources/shaders/screen] Migrated.
Browse files Browse the repository at this point in the history
  • Loading branch information
Unarelith committed Oct 29, 2023
1 parent 4bbbbbd commit 12474af
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 29 deletions.
1 change: 1 addition & 0 deletions resources/shaders/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ endfunction()
compile_shaders(
basic
game
screen
skybox
)
5 changes: 5 additions & 0 deletions resources/shaders/screen.def.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
vec2 a_position : POSITION;
vec2 a_texcoord0 : TEXCOORD0;

vec2 v_position : POSITION;
vec2 v_texcoord0 : TEXCOORD0;
28 changes: 14 additions & 14 deletions resources/shaders/screen.f.glsl → resources/shaders/screen.fs.sc
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
#version 120
$input v_position, v_texcoord0

varying vec2 v_texCoord;
varying vec2 v_coord2d;
#include <bgfx_shader.sh>

uniform sampler2D screenTexture;
uniform sampler2D depthTexture;
SAMPLER2D(s_colorTexture, 0);
SAMPLER2D(s_depthTexture, 1);

uniform int u_effectType;
uniform float u_fogDepth;
uniform vec4 u_fogColor;
uniform vec4 u_effectType;
uniform vec4 u_depthFogColor;

#define u_fogDepth u_effectType.y

void main() {
vec4 color = texture2D(screenTexture, v_texCoord);
float depth = texture2D(depthTexture, v_texCoord).r;
vec4 color = texture2D(s_colorTexture, v_texcoord0).rgba;
float depth = texture2D(s_depthTexture, v_texcoord0).r;

// Underwater effect
if (u_effectType == 1) {
if (u_effectType.x == 1) {
/* color.rgb = mix(color.rgb, vec3(0, 0.5, 1), clamp(pow(depth, 20.0), 0.0, 1.0)); */
color.rgb = mix(color.rgb, u_fogColor.rgb, clamp(pow(depth, u_fogDepth), 0.0, 1.0));
color.rgb = mix(color.rgb, u_depthFogColor.rgb, clamp(pow(depth, u_fogDepth), 0.0, 1.0));
}

// Grayscale
Expand All @@ -26,7 +26,7 @@ void main() {
/* color = vec4(average, average, average, 1.0); */

// Inverted colors
/* color = vec4(vec3(1.0 - texture2D(screenTexture, v_texCoord)), 1.0); */
/* color = vec4(vec3(1.0 - texture2D(s_colorTexture, v_texcoord0)), 1.0); */

gl_FragColor = color;
}
Expand Down Expand Up @@ -69,7 +69,7 @@ void main() {
//
// vec3 sampleTex[9];
// for(int i = 0; i < 9; i++) {
// sampleTex[i] = vec3(texture2D(screenTexture, v_texCoord.st + offsets[i]));
// sampleTex[i] = vec3(texture2D(s_colorTexture, v_texcoord0.st + offsets[i]));
// }
//
// vec3 col = vec3(0.0);
Expand Down
15 changes: 0 additions & 15 deletions resources/shaders/screen.v.glsl

This file was deleted.

10 changes: 10 additions & 0 deletions resources/shaders/screen.vs.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
$input a_position, a_texcoord0
$output v_position, v_texcoord0

void main() {
v_texcoord0 = a_texcoord0;
v_position = a_position;

gl_Position = vec4(a_position.x, a_position.y, 0.0, 1.0);
}

0 comments on commit 12474af

Please sign in to comment.