This repository has been archived by the owner on Sep 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
expose user textures, add repeat to sampling for wgpu backend
- Loading branch information
1 parent
a4d4f8c
commit 4665b76
Showing
18 changed files
with
754 additions
and
671 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#version 300 es | ||
|
||
|
||
// vertex input | ||
layout(location = 0) in vec2 vin_pos; // vertex in position | ||
layout(location = 1) in vec2 vin_tc; // vertex in texture coordinates | ||
layout(location = 2) in vec4 vin_sc; // vertex in normalized srgba color | ||
|
||
// vertex output | ||
out vec2 vout_tc; // vertex out texture coordinates | ||
out vec4 vout_sc; // srgb color | ||
|
||
// vertex uniform | ||
uniform vec2 u_screen_size; // in physical pixels | ||
|
||
|
||
void main() { | ||
gl_Position = vec4( | ||
2.0 * vin_pos.x / u_screen_size.x - 1.0, | ||
1.0 - 2.0 * vin_pos.y / u_screen_size.y, | ||
0.0, | ||
1.0); | ||
vout_tc = vin_tc; | ||
// egui does everything in srgb space | ||
vout_sc = vin_sc; | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#version 300 es | ||
|
||
precision highp float; | ||
// fragment shader uniforms. texture and sampler | ||
uniform sampler2D u_sampler; | ||
|
||
// fragment inputs | ||
in vec2 vout_tc; | ||
in vec4 vout_sc; // srgb color | ||
|
||
out vec4 fout_color; | ||
|
||
// Converts a color from linear light gamma to sRGB gamma | ||
vec4 from_linear(vec4 linearRGB) | ||
{ | ||
bvec3 cutoff = lessThan(linearRGB.rgb, vec3(0.0031308)); | ||
vec3 higher = vec3(1.055)*pow(linearRGB.rgb, vec3(1.0/2.4)) - vec3(0.055); | ||
vec3 lower = linearRGB.rgb * vec3(12.92); | ||
|
||
return vec4(mix(higher, lower, cutoff), linearRGB.a); | ||
} | ||
|
||
// Converts a color from sRGB gamma to linear light gamma | ||
vec4 to_linear(vec4 sRGB) | ||
{ | ||
bvec3 cutoff = lessThan(sRGB.rgb, vec3(0.04045)); | ||
vec3 higher = pow((sRGB.rgb + vec3(0.055))/vec3(1.055), vec3(2.4)); | ||
vec3 lower = sRGB.rgb/vec3(12.92); | ||
|
||
return vec4(mix(higher, lower, cutoff), sRGB.a); | ||
} | ||
|
||
void main() { | ||
// we output in linear. so that gpu can convert it into srgb for srgb framebuffers | ||
fout_color = to_linear(vout_sc * from_linear(texture(u_sampler, vout_tc))); | ||
} | ||
|
||
|
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#version 300 es | ||
|
||
precision highp float; | ||
// fragment shader uniforms. texture and sampler | ||
uniform sampler2D u_sampler; | ||
|
||
// fragment inputs | ||
in vec2 vout_tc; | ||
in vec4 vout_sc; // srgb color | ||
|
||
out vec4 fout_color; | ||
|
||
|
||
// Converts a color from linear light gamma to sRGB gamma | ||
vec4 from_linear(vec4 linearRGB) | ||
{ | ||
bvec3 cutoff = lessThan(linearRGB.rgb, vec3(0.0031308)); | ||
vec3 higher = vec3(1.055)*pow(linearRGB.rgb, vec3(1.0/2.4)) - vec3(0.055); | ||
vec3 lower = linearRGB.rgb * vec3(12.92); | ||
|
||
return vec4(mix(higher, lower, cutoff), linearRGB.a); | ||
} | ||
|
||
void main() { | ||
// we output in srgb space to write to linear framebuffers without gpu doing any conversion | ||
fout_color = vout_sc * from_linear(texture(u_sampler, vout_tc)); | ||
} |
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.