-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added extensions .gs, .comp and .glslf. See: https://stackoverflow.com/q/6432838 * add disambiguation rule for .gs files: if it starts with `#version <number>`, it's GLSL. This seems to work for most GLSL files with few exceptions that are catched by the classifier. * added sample extrude_normal.gs from kyle-piddington/ShaderTool (licensed under MIT): https://github.com/kyle-piddington/ShaderTool/blob/c753a53bde6eab942da617adab9483c945f27f51/assets/shaders/extrude_normals.gs * added sample blend_120.glslf from gfx-rs/gfx (licensed under Apache 2.0): https://github.com/gfx-rs/gfx/blob/7b084cfbb95e3e4d1ea51e91746fc75b2efb3be3/examples/blend/shader/blend_120.glslf * test_heuristics.rb now supports alt_name to ake a different file name for a fixture.
- Loading branch information
Showing
5 changed files
with
90 additions
and
1 deletion.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#version 120 | ||
|
||
#define SCREEN 0 | ||
#define DODGE 1 | ||
#define BURN 2 | ||
#define OVERLAY 3 | ||
#define MULTIPLY 4 | ||
#define ADD 5 | ||
#define DIVIDE 6 | ||
#define GRAIN_EXTRACT 7 | ||
#define GRAIN_MERGE 8 | ||
|
||
// grayscale | ||
uniform sampler2D t_Lena; | ||
// rgba | ||
uniform sampler2D t_Tint; | ||
|
||
uniform int i_Blend; | ||
|
||
varying vec2 v_Uv; | ||
|
||
void main() { | ||
// we sample from both textures using the same uv coordinates. since our | ||
// lena image is grayscale, we only get the first component. | ||
vec3 lena = vec3(texture2D(t_Lena, v_Uv).r); | ||
vec3 tint = texture2D(t_Tint, v_Uv).rgb; | ||
|
||
vec3 result = vec3(0.0); | ||
|
||
// normally you'd have a shader program per technique, but for the sake of | ||
// simplicity we'll just branch on it here. | ||
if (i_Blend == SCREEN) { | ||
result = vec3(1.0) - ((vec3(1.0) - lena) * (vec3(1.0) - tint)); | ||
} else if (i_Blend == DODGE) { | ||
result = lena / (vec3(1.0) - tint); | ||
} else if (i_Blend == BURN) { | ||
result = vec3(1.0) - ((vec3(1.0) - lena) / lena); | ||
} else if (i_Blend == OVERLAY) { | ||
result = lena * (lena + (tint * 2) * (vec3(1.0) - lena)); | ||
} else if (i_Blend == MULTIPLY) { | ||
result = lena * tint; | ||
} else if (i_Blend == ADD) { | ||
result = lena + tint; | ||
} else if (i_Blend == DIVIDE) { | ||
result = lena / tint; | ||
} else if (i_Blend == GRAIN_EXTRACT) { | ||
result = lena - tint + 0.5; | ||
} else if (i_Blend == GRAIN_MERGE) { | ||
result = lena + tint - 0.5; | ||
} | ||
|
||
gl_FragColor = vec4(result, 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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#version 330 core | ||
layout(triangles) in; | ||
layout (line_strip, max_vertices = 6) out; | ||
|
||
in VS_OUT | ||
{ | ||
vec3 normal; | ||
}gs_in[]; | ||
|
||
const float MAGNITUDE = 0.025f; | ||
|
||
void GenerateLine(int index) | ||
{ | ||
gl_Position = gl_in[index].gl_Position; | ||
EmitVertex(); | ||
gl_Position = gl_in[index].gl_Position + vec4(gs_in[index].normal, 0.0f) * MAGNITUDE; | ||
EmitVertex(); | ||
EndPrimitive(); | ||
} | ||
|
||
void main() | ||
{ | ||
GenerateLine(0); | ||
GenerateLine(1); | ||
GenerateLine(2); | ||
} | ||
|
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