-
Notifications
You must be signed in to change notification settings - Fork 463
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Drop compatibility mode, which is not supported by Mesa - Don't use gl_ prefixes for user-declared variables - Don't redeclare gl_PerVertex
- Loading branch information
Showing
10 changed files
with
139 additions
and
30 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
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,15 @@ | ||
#version 150 | ||
|
||
// Passes the fragment color, multiplying a with the alpha param | ||
|
||
uniform vec4 highlight; | ||
uniform float alpha; | ||
|
||
in vec4 color; | ||
out vec4 FragColor; | ||
|
||
void main() | ||
{ | ||
vec3 col = color.xyz + color.xyz * highlight.xyz; | ||
FragColor = vec4(col, color.a * alpha); | ||
} |
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 |
---|---|---|
@@ -1,14 +1,17 @@ | ||
#version 150 compatibility | ||
#version 150 | ||
|
||
// this merely passes over position and color, | ||
// as needed by box.geom | ||
// need to use exactly these names to have OGRE bind the unpacked values: | ||
// https://ogrecave.github.io/ogre/api/latest/_high-level-_programs.html#Binding-vertex-attributes | ||
in vec4 vertex; | ||
in vec4 colour; | ||
|
||
out gl_PerVertex { | ||
vec4 gl_Position; | ||
vec4 gl_FrontColor; | ||
}; | ||
// this merely passes over position and color as needed by box.geom | ||
|
||
out VertexData { | ||
vec4 color; | ||
} vdata; | ||
|
||
void main() { | ||
gl_Position = gl_Vertex; | ||
gl_FrontColor = gl_Color; | ||
gl_Position = vertex; | ||
vdata.color = colour; | ||
} |
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,26 @@ | ||
#version 150 | ||
|
||
// rasterizes a circle that is darker at the borders than in the center | ||
|
||
uniform vec4 highlight; | ||
uniform float alpha; | ||
|
||
in vec4 color; | ||
in vec2 TexCoord; | ||
|
||
out vec4 FragColor; | ||
|
||
void main() | ||
{ | ||
float ax = TexCoord.x-0.5; | ||
float ay = TexCoord.y-0.5; | ||
|
||
float rsquared = ax*ax+ay*ay; | ||
float a = (0.25 - rsquared) * 4.0; | ||
|
||
vec3 col = mix(vec3(0.8, 0.8, 0.8) * color.xyz, color.xyz, a); | ||
|
||
col = col + col * highlight.xyz; | ||
|
||
FragColor = vec4(col, alpha * ceil(a) * color.a); | ||
} |
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,34 @@ | ||
#version 150 | ||
|
||
// rasterizes a smooth square with ax,ay in [-0.5..0.5] | ||
|
||
uniform vec4 highlight; | ||
uniform float alpha; | ||
|
||
in vec4 color; | ||
in vec2 TexCoord; | ||
|
||
out vec4 FragColor; | ||
|
||
void main() | ||
{ | ||
const float outer = 0.48; | ||
const float inner = 0.45; | ||
float ax = TexCoord.x-0.5; | ||
float ay = TexCoord.y-0.5; | ||
|
||
// blending factor, varying between 0.0 (at the border) and 1.0 (at the center of the square) | ||
float blend = smoothstep(-outer, -inner, ay) * (1.0 - smoothstep(inner, outer, ay)) * | ||
smoothstep(-outer, -inner, ax) * (1.0 - smoothstep(inner, outer, ax)); | ||
|
||
#if 1 // high contrast edge (dark edge on light surface / light edge on dark surface) | ||
float inv_blend = 1.0 - blend; | ||
vec3 col = blend * color.rgb + (sign(0.5 - length(vec3(color.rgb))) * vec3(0.2, 0.2, 0.2) + color.rgb) * inv_blend; | ||
#else // alternatively: make color at edge darker | ||
vec3 col = (0.5 + 0.5*blend) * color.rgb; | ||
#endif | ||
|
||
col = col + col * highlight.rgb; | ||
|
||
FragColor = vec4(col.rgb, alpha * color.a); | ||
} |
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