-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5731308
commit 7b9a111
Showing
6 changed files
with
98 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,26 @@ | ||
#shader vertex | ||
#version 430 core | ||
|
||
layout(location = 0) in vec2 inPos; | ||
layout(location = 1) in vec2 inUV; | ||
layout(location = 0) in vec2 geo_Pos; | ||
layout(location = 1) in vec2 geo_TexCoords; | ||
|
||
out vec2 fragUV; | ||
out vec2 TexCoords; | ||
|
||
void main() { | ||
fragUV = inUV; | ||
gl_Position = vec4(inPos, 0.0, 1.0); | ||
void main() | ||
{ | ||
TexCoords = geo_TexCoords; | ||
gl_Position = vec4(geo_Pos, 0.0, 1.0); | ||
} | ||
|
||
#shader fragment | ||
#version 430 core | ||
|
||
in vec2 fragUV; | ||
out vec4 fragColor; // Output color | ||
in vec2 TexCoords; | ||
out vec4 FRAGMENT_COLOR; | ||
|
||
uniform sampler2D _InputTexture; | ||
|
||
void main() { | ||
fragColor = texture(_InputTexture, fragUV); | ||
void main() | ||
{ | ||
FRAGMENT_COLOR = texture(_InputTexture, TexCoords); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,30 @@ | ||
#shader vertex | ||
#version 430 core | ||
|
||
layout(location = 0) in vec2 inPos; | ||
layout(location = 1) in vec2 inUV; | ||
layout(location = 0) in vec2 geo_Pos; | ||
layout(location = 1) in vec2 geo_TexCoords; | ||
|
||
out vec2 fragUV; | ||
out vec2 TexCoords; | ||
|
||
void main() { | ||
fragUV = inUV; | ||
gl_Position = vec4(inPos, 0.0, 1.0); | ||
void main() | ||
{ | ||
TexCoords = geo_TexCoords; | ||
gl_Position = vec4(geo_Pos, 0.0, 1.0); | ||
} | ||
|
||
#shader fragment | ||
#version 430 core | ||
|
||
in vec2 fragUV; | ||
out vec4 fragColor; // Output color | ||
in vec2 TexCoords; | ||
out vec4 FRAGMENT_COLOR; | ||
|
||
uniform sampler2D _InputTexture; // Original scene texture | ||
uniform sampler2D _BloomTexture; // Blurred bloom texture | ||
uniform float _BloomIntensity; // Strength of bloom effect | ||
uniform sampler2D _InputTexture; | ||
uniform sampler2D _BloomTexture; | ||
uniform float _BloomIntensity; | ||
|
||
void main() { | ||
vec3 sceneColor = texture(_InputTexture, fragUV).rgb; | ||
vec3 bloomColor = texture(_BloomTexture, fragUV).rgb; | ||
fragColor = vec4(sceneColor + _BloomIntensity * bloomColor, 1.0); | ||
void main() | ||
{ | ||
const vec3 sceneColor = texture(_InputTexture, TexCoords).rgb; | ||
const vec3 bloomColor = texture(_BloomTexture, TexCoords).rgb; | ||
FRAGMENT_COLOR = vec4(sceneColor + _BloomIntensity * bloomColor, 1.0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,43 @@ | ||
#shader vertex | ||
#version 430 core | ||
|
||
layout(location = 0) in vec2 inPos; | ||
layout(location = 1) in vec2 inUV; | ||
layout(location = 0) in vec2 geo_Pos; | ||
layout(location = 1) in vec2 geo_TexCoords; | ||
|
||
out vec2 fragUV; | ||
out vec2 TexCoords; | ||
|
||
void main() { | ||
fragUV = inUV; | ||
gl_Position = vec4(inPos, 0.0, 1.0); | ||
void main() | ||
{ | ||
TexCoords = geo_TexCoords; | ||
gl_Position = vec4(geo_Pos, 0.0, 1.0); | ||
} | ||
|
||
#shader fragment | ||
#version 430 core | ||
|
||
in vec2 fragUV; | ||
out vec4 fragColor; // Output color | ||
in vec2 TexCoords; | ||
out vec4 FRAGMENT_COLOR; | ||
|
||
uniform sampler2D _InputTexture; // Input texture | ||
uniform bool _Horizontal; // Blur direction: horizontal or vertical | ||
uniform sampler2D _InputTexture; | ||
uniform bool _Horizontal; | ||
uniform float _BlurSize; | ||
uniform int _KernelSize; | ||
|
||
uniform float _BlurSize; // Controls the spread of the blur | ||
uniform int _KernelSize; // Number of samples in the blur kernel | ||
|
||
void main() { | ||
vec2 texelSize = 1.0 / textureSize(_InputTexture, 0); // Size of one texel in UV coordinates | ||
vec2 direction = _Horizontal ? vec2(texelSize.x, 0.0) : vec2(0.0, texelSize.y); | ||
void main() | ||
{ | ||
const vec2 texelSize = 1.0 / textureSize(_InputTexture, 0); | ||
const vec2 direction = _Horizontal ? vec2(texelSize.x, 0.0) : vec2(0.0, texelSize.y); | ||
|
||
vec4 color = vec4(0.0); | ||
float totalWeight = 0.0; | ||
|
||
// Loop through the kernel | ||
for (int i = -_KernelSize; i <= _KernelSize; i++) { | ||
for (int i = -_KernelSize; i <= _KernelSize; i++) | ||
{ | ||
float weight = exp(-0.5 * (i * i) / (_BlurSize * _BlurSize)); | ||
vec2 offset = float(i) * direction; | ||
color += texture(_InputTexture, fragUV + offset) * weight; | ||
color += texture(_InputTexture, TexCoords + offset) * weight; | ||
totalWeight += weight; | ||
} | ||
|
||
// Normalize the result | ||
fragColor = color / totalWeight; | ||
FRAGMENT_COLOR = color / totalWeight; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,35 @@ | ||
#shader vertex | ||
#version 430 core | ||
|
||
layout(location = 0) in vec2 inPos; | ||
layout(location = 1) in vec2 inUV; | ||
layout(location = 0) in vec2 geo_Pos; | ||
layout(location = 1) in vec2 geo_TexCoords; | ||
|
||
out vec2 fragUV; | ||
out vec2 TexCoords; | ||
|
||
void main() { | ||
fragUV = inUV; | ||
gl_Position = vec4(inPos, 0.0, 1.0); | ||
void main() | ||
{ | ||
TexCoords = geo_TexCoords; | ||
gl_Position = vec4(geo_Pos, 0.0, 1.0); | ||
} | ||
|
||
#shader fragment | ||
#version 430 core | ||
|
||
in vec2 fragUV; | ||
out vec4 fragColor; // Output color | ||
in vec2 TexCoords; | ||
out vec4 FRAGMENT_COLOR; | ||
|
||
uniform sampler2D _InputTexture; // Input scene texture | ||
uniform float _Threshold; // Brightness threshold | ||
uniform sampler2D _InputTexture; | ||
uniform float _Threshold; | ||
|
||
float luminance(vec3 color) | ||
{ | ||
return dot(color, vec3(0.2126, 0.7152, 0.0722)); | ||
} | ||
|
||
void main() { | ||
vec3 color = texture(_InputTexture, fragUV).rgb; | ||
void main() | ||
{ | ||
const vec3 color = texture(_InputTexture, TexCoords).rgb; | ||
float brightness = luminance(color); | ||
brightness = max(0.0, brightness - _Threshold); | ||
fragColor = vec4(color * sign(brightness), 1.0); | ||
FRAGMENT_COLOR = vec4(color * sign(brightness), 1.0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters