[Impeller] Format shader sources. (flutter/engine#37770)
* Update format.dart to include glsl, format repo * format more
This commit is contained in:
@@ -71,7 +71,7 @@ FormatCheck nameToFormatCheck(String name) {
|
||||
String formatCheckToName(FormatCheck check) {
|
||||
switch (check) {
|
||||
case FormatCheck.clang:
|
||||
return 'C++/ObjC';
|
||||
return 'C++/ObjC/Shader';
|
||||
case FormatCheck.gn:
|
||||
return 'GN';
|
||||
case FormatCheck.java:
|
||||
@@ -301,7 +301,7 @@ abstract class FormatChecker {
|
||||
}
|
||||
}
|
||||
|
||||
/// Checks and formats C++/ObjC files using clang-format.
|
||||
/// Checks and formats C++/ObjC/Shader files using clang-format.
|
||||
class ClangFormatChecker extends FormatChecker {
|
||||
ClangFormatChecker({
|
||||
ProcessManager processManager = const LocalProcessManager(),
|
||||
@@ -350,7 +350,7 @@ class ClangFormatChecker extends FormatChecker {
|
||||
|
||||
@override
|
||||
Future<bool> fixFormatting() async {
|
||||
message('Fixing C++/ObjC formatting...');
|
||||
message('Fixing C++/ObjC/Shader formatting...');
|
||||
final List<String> failures = await _getCFormatFailures(fixing: true);
|
||||
if (failures.isEmpty) {
|
||||
return true;
|
||||
@@ -365,7 +365,7 @@ class ClangFormatChecker extends FormatChecker {
|
||||
}
|
||||
|
||||
Future<List<String>> _getCFormatFailures({bool fixing = false}) async {
|
||||
message('Checking C++/ObjC formatting...');
|
||||
message('Checking C++/ObjC/Shader formatting...');
|
||||
const List<String> clangFiletypes = <String>[
|
||||
'*.c',
|
||||
'*.cc',
|
||||
@@ -374,10 +374,17 @@ class ClangFormatChecker extends FormatChecker {
|
||||
'*.h',
|
||||
'*.m',
|
||||
'*.mm',
|
||||
'*.glsl',
|
||||
'*.hlsl',
|
||||
'*.comp',
|
||||
'*.tese',
|
||||
'*.tesc',
|
||||
'*.vert',
|
||||
'*.frag',
|
||||
];
|
||||
final List<String> files = await getFileList(clangFiletypes);
|
||||
if (files.isEmpty) {
|
||||
message('No C++/ObjC files with changes, skipping C++/ObjC format check.');
|
||||
message('No C++/ObjC/Shader files with changes, skipping C++/ObjC/Shader format check.');
|
||||
return <String>[];
|
||||
}
|
||||
if (verbose) {
|
||||
@@ -416,10 +423,10 @@ class ClangFormatChecker extends FormatChecker {
|
||||
if (failed.isNotEmpty) {
|
||||
final bool plural = failed.length > 1;
|
||||
if (fixing) {
|
||||
message('Fixing ${failed.length} C++/ObjC file${plural ? 's' : ''}'
|
||||
message('Fixing ${failed.length} C++/ObjC/Shader file${plural ? 's' : ''}'
|
||||
' which ${plural ? 'were' : 'was'} formatted incorrectly.');
|
||||
} else {
|
||||
error('Found ${failed.length} C++/ObjC file${plural ? 's' : ''}'
|
||||
error('Found ${failed.length} C++/ObjC/Shader file${plural ? 's' : ''}'
|
||||
' which ${plural ? 'were' : 'was'} formatted incorrectly.');
|
||||
stdout.writeln('To fix, run:');
|
||||
stdout.writeln();
|
||||
@@ -431,7 +438,7 @@ class ClangFormatChecker extends FormatChecker {
|
||||
stdout.writeln();
|
||||
}
|
||||
} else {
|
||||
message('Completed checking ${diffJobs.length} C++/ObjC files with no formatting problems.');
|
||||
message('Completed checking ${diffJobs.length} C++/ObjC/Shader files with no formatting problems.');
|
||||
}
|
||||
return failed.map<String>((WorkerJob job) {
|
||||
return job.result.stdout;
|
||||
|
||||
@@ -24,8 +24,12 @@ vec4 IPSample(sampler2D texture_sampler, vec2 coords, float y_coord_scale) {
|
||||
/// If `y_coord_scale` < 0.0, the Y coordinate is flipped. This is useful
|
||||
/// for Impeller graphics backends that use a flipped framebuffer coordinate
|
||||
/// space.
|
||||
/// The range of `coods` will be mapped from [0, 1] to [half_texel, 1 - half_texel]
|
||||
vec4 IPSampleLinear(sampler2D texture_sampler, vec2 coords, float y_coord_scale, vec2 half_texel) {
|
||||
/// The range of `coods` will be mapped from [0, 1] to [half_texel, 1 -
|
||||
/// half_texel]
|
||||
vec4 IPSampleLinear(sampler2D texture_sampler,
|
||||
vec2 coords,
|
||||
float y_coord_scale,
|
||||
vec2 half_texel) {
|
||||
coords.x = mix(half_texel.x, 1 - half_texel.x, coords.x);
|
||||
coords.y = mix(half_texel.y, 1 - half_texel.y, coords.y);
|
||||
return IPSample(texture_sampler, coords, y_coord_scale);
|
||||
@@ -79,7 +83,8 @@ vec4 IPSampleWithTileMode(sampler2D tex,
|
||||
return vec4(0);
|
||||
}
|
||||
|
||||
return IPSample(tex, IPVec2Tile(coords, x_tile_mode, y_tile_mode), y_coord_scale);
|
||||
return IPSample(tex, IPVec2Tile(coords, x_tile_mode, y_tile_mode),
|
||||
y_coord_scale);
|
||||
}
|
||||
|
||||
/// Sample a texture, emulating a specific tile mode.
|
||||
@@ -97,7 +102,8 @@ vec4 IPSampleWithTileMode(sampler2D tex,
|
||||
///
|
||||
/// This is useful for Impeller graphics backend that don't have native support
|
||||
/// for Decal.
|
||||
/// The range of `coods` will be mapped from [0, 1] to [half_texel, 1 - half_texel]
|
||||
/// The range of `coods` will be mapped from [0, 1] to [half_texel, 1 -
|
||||
/// half_texel]
|
||||
vec4 IPSampleLinearWithTileMode(sampler2D tex,
|
||||
vec2 coords,
|
||||
float y_coord_scale,
|
||||
@@ -109,20 +115,23 @@ vec4 IPSampleLinearWithTileMode(sampler2D tex,
|
||||
return vec4(0);
|
||||
}
|
||||
|
||||
return IPSampleLinear(tex, IPVec2Tile(coords, x_tile_mode, y_tile_mode), y_coord_scale, half_texel);
|
||||
return IPSampleLinear(tex, IPVec2Tile(coords, x_tile_mode, y_tile_mode),
|
||||
y_coord_scale, half_texel);
|
||||
}
|
||||
|
||||
/// Sample a texture, emulating a specific tile mode.
|
||||
///
|
||||
/// This is useful for Impeller graphics backend that don't have native support
|
||||
/// for Decal.
|
||||
/// The range of `coods` will be mapped from [0, 1] to [half_texel, 1 - half_texel]
|
||||
/// The range of `coods` will be mapped from [0, 1] to [half_texel, 1 -
|
||||
/// half_texel]
|
||||
vec4 IPSampleLinearWithTileMode(sampler2D tex,
|
||||
vec2 coords,
|
||||
float y_coord_scale,
|
||||
vec2 half_texel,
|
||||
float tile_mode) {
|
||||
return IPSampleLinearWithTileMode(tex, coords, y_coord_scale, half_texel, tile_mode, tile_mode);
|
||||
return IPSampleLinearWithTileMode(tex, coords, y_coord_scale, half_texel,
|
||||
tile_mode, tile_mode);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -12,7 +12,8 @@ uniform BlendInfo {
|
||||
float src_y_coord_scale;
|
||||
float color_factor;
|
||||
vec4 color; // This color input is expected to be unpremultiplied.
|
||||
} blend_info;
|
||||
}
|
||||
blend_info;
|
||||
|
||||
uniform sampler2D texture_sampler_dst;
|
||||
uniform sampler2D texture_sampler_src;
|
||||
@@ -28,7 +29,8 @@ void main() {
|
||||
v_dst_texture_coords, // texture coordinates
|
||||
blend_info.dst_y_coord_scale, // y coordinate scale
|
||||
kTileModeDecal // tile mode
|
||||
) * blend_info.dst_input_alpha;
|
||||
) *
|
||||
blend_info.dst_input_alpha;
|
||||
|
||||
vec4 dst = IPUnpremultiply(dst_sample);
|
||||
vec4 src = blend_info.color_factor > 0
|
||||
@@ -43,5 +45,5 @@ void main() {
|
||||
vec4 blended = vec4(Blend(dst.rgb, src.rgb), 1) * dst.a;
|
||||
|
||||
frag_color = mix(dst_sample, blended, src.a);
|
||||
//frag_color = dst_sample;
|
||||
// frag_color = dst_sample;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,8 @@ uniform sampler2D texture_sampler_src;
|
||||
uniform FragInfo {
|
||||
float texture_sampler_y_coord_scale;
|
||||
float input_alpha;
|
||||
} frag_info;
|
||||
}
|
||||
frag_info;
|
||||
|
||||
in vec2 v_texture_coords;
|
||||
|
||||
@@ -18,5 +19,5 @@ out vec4 frag_color;
|
||||
void main() {
|
||||
frag_color = IPSample(texture_sampler_src, v_texture_coords,
|
||||
frag_info.texture_sampler_y_coord_scale) *
|
||||
frag_info.input_alpha;
|
||||
frag_info.input_alpha;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
uniform FrameInfo {
|
||||
mat4 mvp;
|
||||
} frame_info;
|
||||
}
|
||||
frame_info;
|
||||
|
||||
in vec2 vertices;
|
||||
in vec2 texture_coords;
|
||||
|
||||
@@ -18,7 +18,8 @@ uniform sampler2D texture_sampler;
|
||||
|
||||
uniform FragInfo {
|
||||
float texture_sampler_y_coord_scale;
|
||||
} frag_info;
|
||||
}
|
||||
frag_info;
|
||||
|
||||
in vec2 v_texture_coords;
|
||||
in vec2 v_sigma_uv;
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
|
||||
// A color filter that transforms colors through a 4x5 color matrix.
|
||||
//
|
||||
// This filter can be used to change the saturation of pixels, convert from YUV to RGB, etc.
|
||||
// This filter can be used to change the saturation of pixels, convert from YUV
|
||||
// to RGB, etc.
|
||||
//
|
||||
// 4x5 matrix for transforming the color and alpha components of a Bitmap.
|
||||
// The matrix can be passed as single array, and is treated as follows:
|
||||
@@ -24,14 +25,16 @@
|
||||
// B’ = k*R + l*G + m*B + n*A + o;
|
||||
// A’ = p*R + q*G + r*B + s*A + t;
|
||||
//
|
||||
// That resulting color [R’, G’, B’, A’] then has each channel clamped to the 0 to 255 range.
|
||||
// That resulting color [R’, G’, B’, A’] then has each channel clamped to the 0
|
||||
// to 255 range.
|
||||
|
||||
uniform FragInfo {
|
||||
mat4 color_m;
|
||||
vec4 color_v;
|
||||
float texture_sampler_y_coord_scale;
|
||||
float input_alpha;
|
||||
} frag_info;
|
||||
}
|
||||
frag_info;
|
||||
|
||||
uniform sampler2D input_texture;
|
||||
|
||||
@@ -41,14 +44,13 @@ out vec4 frag_color;
|
||||
void main() {
|
||||
vec4 input_color = IPSample(input_texture, v_position,
|
||||
frag_info.texture_sampler_y_coord_scale) *
|
||||
frag_info.input_alpha;
|
||||
|
||||
frag_info.input_alpha;
|
||||
|
||||
// unpremultiply first, as filter inputs are premultiplied.
|
||||
vec4 color = IPUnpremultiply(input_color);
|
||||
|
||||
color = clamp(frag_info.color_m * color + frag_info.color_v, 0.0, 1.0);
|
||||
|
||||
|
||||
// premultiply the outputs
|
||||
frag_color = vec4(color.rgb * color.a, color.a);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
uniform FrameInfo {
|
||||
mat4 mvp;
|
||||
} frame_info;
|
||||
}
|
||||
frame_info;
|
||||
|
||||
in vec2 position;
|
||||
out vec2 v_position;
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
uniform FrameInfo {
|
||||
mat4 mvp;
|
||||
mat4 matrix;
|
||||
} frame_info;
|
||||
}
|
||||
frame_info;
|
||||
|
||||
in vec2 position;
|
||||
|
||||
|
||||
@@ -13,7 +13,8 @@ uniform GradientInfo {
|
||||
float texture_sampler_y_coord_scale;
|
||||
float alpha;
|
||||
vec2 half_texel;
|
||||
} gradient_info;
|
||||
}
|
||||
gradient_info;
|
||||
|
||||
in vec2 v_position;
|
||||
|
||||
@@ -21,16 +22,13 @@ out vec4 frag_color;
|
||||
|
||||
void main() {
|
||||
float len = length(gradient_info.end_point - gradient_info.start_point);
|
||||
float dot = dot(
|
||||
v_position - gradient_info.start_point,
|
||||
gradient_info.end_point - gradient_info.start_point
|
||||
);
|
||||
float dot = dot(v_position - gradient_info.start_point,
|
||||
gradient_info.end_point - gradient_info.start_point);
|
||||
float t = dot / (len * len);
|
||||
frag_color = IPSampleLinearWithTileMode(
|
||||
texture_sampler,
|
||||
vec2(t, 0.5),
|
||||
gradient_info.texture_sampler_y_coord_scale,
|
||||
gradient_info.half_texel,
|
||||
gradient_info.tile_mode);
|
||||
frag_color = vec4(frag_color.xyz * frag_color.a, frag_color.a) * gradient_info.alpha;
|
||||
texture_sampler, vec2(t, 0.5),
|
||||
gradient_info.texture_sampler_y_coord_scale, gradient_info.half_texel,
|
||||
gradient_info.tile_mode);
|
||||
frag_color =
|
||||
vec4(frag_color.xyz * frag_color.a, frag_color.a) * gradient_info.alpha;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
|
||||
readonly buffer ColorData {
|
||||
vec4 colors[];
|
||||
} color_data;
|
||||
}
|
||||
color_data;
|
||||
|
||||
uniform GradientInfo {
|
||||
vec2 start_point;
|
||||
@@ -15,7 +16,8 @@ uniform GradientInfo {
|
||||
float alpha;
|
||||
float tile_mode;
|
||||
float colors_length;
|
||||
} gradient_info;
|
||||
}
|
||||
gradient_info;
|
||||
|
||||
in vec2 v_position;
|
||||
|
||||
@@ -23,10 +25,8 @@ out vec4 frag_color;
|
||||
|
||||
void main() {
|
||||
float len = length(gradient_info.end_point - gradient_info.start_point);
|
||||
float dot = dot(
|
||||
v_position - gradient_info.start_point,
|
||||
gradient_info.end_point - gradient_info.start_point
|
||||
);
|
||||
float dot = dot(v_position - gradient_info.start_point,
|
||||
gradient_info.end_point - gradient_info.start_point);
|
||||
float t = dot / (len * len);
|
||||
|
||||
if ((t < 0.0 || t > 1.0) && gradient_info.tile_mode == kTileModeDecal) {
|
||||
@@ -36,6 +36,8 @@ void main() {
|
||||
t = IPFloatTile(t, gradient_info.tile_mode);
|
||||
vec3 values = IPComputeFixedGradientValues(t, gradient_info.colors_length);
|
||||
|
||||
frag_color = mix(color_data.colors[int(values.x)], color_data.colors[int(values.y)], values.z);
|
||||
frag_color = vec4(frag_color.xyz * frag_color.a, frag_color.a) * gradient_info.alpha;
|
||||
frag_color = mix(color_data.colors[int(values.x)],
|
||||
color_data.colors[int(values.y)], values.z);
|
||||
frag_color =
|
||||
vec4(frag_color.xyz * frag_color.a, frag_color.a) * gradient_info.alpha;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,8 @@ uniform sampler2D input_texture;
|
||||
uniform FragInfo {
|
||||
float texture_sampler_y_coord_scale;
|
||||
float input_alpha;
|
||||
} frag_info;
|
||||
}
|
||||
frag_info;
|
||||
|
||||
in vec2 v_position;
|
||||
out vec4 frag_color;
|
||||
@@ -22,7 +23,7 @@ out vec4 frag_color;
|
||||
void main() {
|
||||
vec4 input_color = IPSample(input_texture, v_position,
|
||||
frag_info.texture_sampler_y_coord_scale) *
|
||||
frag_info.input_alpha;
|
||||
frag_info.input_alpha;
|
||||
|
||||
vec4 color = IPUnpremultiply(input_color);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
uniform FrameInfo {
|
||||
mat4 mvp;
|
||||
} frame_info;
|
||||
}
|
||||
frame_info;
|
||||
|
||||
in vec2 position;
|
||||
out vec2 v_position;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
// 'FilterContents::MorphType' enum class.
|
||||
const float kMorphTypeDilate = 0;
|
||||
const float kMorphTypeErode = 1;
|
||||
|
||||
|
||||
uniform sampler2D texture_sampler;
|
||||
|
||||
uniform FragInfo {
|
||||
@@ -30,13 +30,12 @@ void main() {
|
||||
for (float i = -frag_info.radius; i <= frag_info.radius; i++) {
|
||||
vec2 texture_coords = v_texture_coords + uv_offset * i;
|
||||
vec4 color;
|
||||
color =
|
||||
IPSampleWithTileMode(
|
||||
texture_sampler, // sampler
|
||||
texture_coords, // texture coordinates
|
||||
frag_info.texture_sampler_y_coord_scale, // y coordinate scale
|
||||
kTileModeDecal // tile mode
|
||||
);
|
||||
color = IPSampleWithTileMode(
|
||||
texture_sampler, // sampler
|
||||
texture_coords, // texture coordinates
|
||||
frag_info.texture_sampler_y_coord_scale, // y coordinate scale
|
||||
kTileModeDecal // tile mode
|
||||
);
|
||||
if (frag_info.morph_type == kMorphTypeDilate) {
|
||||
result = max(color, result);
|
||||
} else {
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
uniform VertInfo {
|
||||
mat4 mvp;
|
||||
vec4 color;
|
||||
} vert_info;
|
||||
}
|
||||
vert_info;
|
||||
|
||||
in vec2 position;
|
||||
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
|
||||
uniform VertInfo {
|
||||
mat4 mvp;
|
||||
} vert_info;
|
||||
}
|
||||
vert_info;
|
||||
|
||||
in vec2 position;
|
||||
in vec4 color;
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
|
||||
uniform VertInfo {
|
||||
mat4 mvp;
|
||||
} vert_info;
|
||||
}
|
||||
vert_info;
|
||||
|
||||
in vec2 position;
|
||||
in vec2 uv;
|
||||
|
||||
@@ -13,7 +13,8 @@ uniform GradientInfo {
|
||||
float texture_sampler_y_coord_scale;
|
||||
float alpha;
|
||||
vec2 half_texel;
|
||||
} gradient_info;
|
||||
}
|
||||
gradient_info;
|
||||
|
||||
in vec2 v_position;
|
||||
|
||||
@@ -23,10 +24,9 @@ void main() {
|
||||
float len = length(v_position - gradient_info.center);
|
||||
float t = len / gradient_info.radius;
|
||||
frag_color = IPSampleLinearWithTileMode(
|
||||
texture_sampler,
|
||||
vec2(t, 0.5),
|
||||
gradient_info.texture_sampler_y_coord_scale,
|
||||
gradient_info.half_texel,
|
||||
gradient_info.tile_mode);
|
||||
frag_color = vec4(frag_color.xyz * frag_color.a, frag_color.a) * gradient_info.alpha;
|
||||
texture_sampler, vec2(t, 0.5),
|
||||
gradient_info.texture_sampler_y_coord_scale, gradient_info.half_texel,
|
||||
gradient_info.tile_mode);
|
||||
frag_color =
|
||||
vec4(frag_color.xyz * frag_color.a, frag_color.a) * gradient_info.alpha;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
|
||||
readonly buffer ColorData {
|
||||
vec4 colors[];
|
||||
} color_data;
|
||||
}
|
||||
color_data;
|
||||
|
||||
uniform GradientInfo {
|
||||
vec2 center;
|
||||
@@ -15,7 +16,8 @@ uniform GradientInfo {
|
||||
float tile_mode;
|
||||
float alpha;
|
||||
float colors_length;
|
||||
} gradient_info;
|
||||
}
|
||||
gradient_info;
|
||||
|
||||
in vec2 v_position;
|
||||
|
||||
@@ -32,6 +34,8 @@ void main() {
|
||||
t = IPFloatTile(t, gradient_info.tile_mode);
|
||||
vec3 values = IPComputeFixedGradientValues(t, gradient_info.colors_length);
|
||||
|
||||
frag_color = mix(color_data.colors[int(values.x)], color_data.colors[int(values.y)], values.z);
|
||||
frag_color = vec4(frag_color.xyz * frag_color.a, frag_color.a) * gradient_info.alpha;
|
||||
frag_color = mix(color_data.colors[int(values.x)],
|
||||
color_data.colors[int(values.y)], values.z);
|
||||
frag_color =
|
||||
vec4(frag_color.xyz * frag_color.a, frag_color.a) * gradient_info.alpha;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
uniform VertInfo {
|
||||
mat4 mvp;
|
||||
} vert_info;
|
||||
}
|
||||
vert_info;
|
||||
|
||||
in vec2 position;
|
||||
out vec2 v_position;
|
||||
|
||||
@@ -13,7 +13,8 @@ uniform sampler2D input_texture;
|
||||
uniform FragInfo {
|
||||
float texture_sampler_y_coord_scale;
|
||||
float input_alpha;
|
||||
} frag_info;
|
||||
}
|
||||
frag_info;
|
||||
|
||||
in vec2 v_position;
|
||||
out vec4 frag_color;
|
||||
@@ -21,7 +22,7 @@ out vec4 frag_color;
|
||||
void main() {
|
||||
vec4 input_color = IPSample(input_texture, v_position,
|
||||
frag_info.texture_sampler_y_coord_scale) *
|
||||
frag_info.input_alpha;
|
||||
frag_info.input_alpha;
|
||||
|
||||
vec4 color = IPUnpremultiply(input_color);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
uniform FrameInfo {
|
||||
mat4 mvp;
|
||||
} frame_info;
|
||||
}
|
||||
frame_info;
|
||||
|
||||
in vec2 position;
|
||||
out vec2 v_position;
|
||||
|
||||
@@ -15,7 +15,8 @@ uniform GradientInfo {
|
||||
float texture_sampler_y_coord_scale;
|
||||
float alpha;
|
||||
vec2 half_texel;
|
||||
} gradient_info;
|
||||
}
|
||||
gradient_info;
|
||||
|
||||
in vec2 v_position;
|
||||
|
||||
@@ -25,12 +26,12 @@ void main() {
|
||||
vec2 coord = v_position - gradient_info.center;
|
||||
float angle = atan(-coord.y, -coord.x);
|
||||
|
||||
float t = (angle * k1Over2Pi + 0.5 + gradient_info.bias) * gradient_info.scale;
|
||||
float t =
|
||||
(angle * k1Over2Pi + 0.5 + gradient_info.bias) * gradient_info.scale;
|
||||
frag_color = IPSampleLinearWithTileMode(
|
||||
texture_sampler,
|
||||
vec2(t, 0.5),
|
||||
gradient_info.texture_sampler_y_coord_scale,
|
||||
gradient_info.half_texel,
|
||||
gradient_info.tile_mode);
|
||||
frag_color = vec4(frag_color.xyz * frag_color.a, frag_color.a) * gradient_info.alpha;
|
||||
texture_sampler, vec2(t, 0.5),
|
||||
gradient_info.texture_sampler_y_coord_scale, gradient_info.half_texel,
|
||||
gradient_info.tile_mode);
|
||||
frag_color =
|
||||
vec4(frag_color.xyz * frag_color.a, frag_color.a) * gradient_info.alpha;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
|
||||
readonly buffer ColorData {
|
||||
vec4 colors[];
|
||||
} color_data;
|
||||
}
|
||||
color_data;
|
||||
|
||||
uniform GradientInfo {
|
||||
vec2 center;
|
||||
@@ -17,7 +18,8 @@ uniform GradientInfo {
|
||||
float tile_mode;
|
||||
float alpha;
|
||||
float colors_length;
|
||||
} gradient_info;
|
||||
}
|
||||
gradient_info;
|
||||
|
||||
in vec2 v_position;
|
||||
|
||||
@@ -26,7 +28,8 @@ out vec4 frag_color;
|
||||
void main() {
|
||||
vec2 coord = v_position - gradient_info.center;
|
||||
float angle = atan(-coord.y, -coord.x);
|
||||
float t = (angle * k1Over2Pi + 0.5 + gradient_info.bias) * gradient_info.scale;
|
||||
float t =
|
||||
(angle * k1Over2Pi + 0.5 + gradient_info.bias) * gradient_info.scale;
|
||||
|
||||
if ((t < 0.0 || t > 1.0) && gradient_info.tile_mode == kTileModeDecal) {
|
||||
frag_color = vec4(0);
|
||||
@@ -35,6 +38,8 @@ void main() {
|
||||
t = IPFloatTile(t, gradient_info.tile_mode);
|
||||
vec3 values = IPComputeFixedGradientValues(t, gradient_info.colors_length);
|
||||
|
||||
frag_color = mix(color_data.colors[int(values.x)], color_data.colors[int(values.y)], values.z);
|
||||
frag_color = vec4(frag_color.xyz * frag_color.a, frag_color.a) * gradient_info.alpha;
|
||||
frag_color = mix(color_data.colors[int(values.x)],
|
||||
color_data.colors[int(values.y)], values.z);
|
||||
frag_color =
|
||||
vec4(frag_color.xyz * frag_color.a, frag_color.a) * gradient_info.alpha;
|
||||
}
|
||||
|
||||
@@ -26,5 +26,6 @@ void main() {
|
||||
frag_info.texture_sampler_y_coord_scale, // y coordinate scale
|
||||
frag_info.x_tile_mode, // x tile mode
|
||||
frag_info.y_tile_mode // y tile mode
|
||||
) * frag_info.alpha;
|
||||
) *
|
||||
frag_info.alpha;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,8 @@ uniform FragInfo {
|
||||
float texture_sampler_y_coord_scale;
|
||||
mat4 matrix;
|
||||
float yuv_color_space;
|
||||
} frag_info;
|
||||
}
|
||||
frag_info;
|
||||
|
||||
in vec2 v_position;
|
||||
out vec4 frag_color;
|
||||
@@ -29,7 +30,11 @@ void main() {
|
||||
yuv_offset.x = 16.0 / 255.0;
|
||||
}
|
||||
|
||||
yuv.x = IPSample(y_texture, v_position, frag_info.texture_sampler_y_coord_scale).r;
|
||||
yuv.yz = IPSample(uv_texture, v_position, frag_info.texture_sampler_y_coord_scale).rg;
|
||||
yuv.x =
|
||||
IPSample(y_texture, v_position, frag_info.texture_sampler_y_coord_scale)
|
||||
.r;
|
||||
yuv.yz =
|
||||
IPSample(uv_texture, v_position, frag_info.texture_sampler_y_coord_scale)
|
||||
.rg;
|
||||
frag_color = frag_info.matrix * vec4(yuv - yuv_offset, 1);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
uniform FrameInfo {
|
||||
mat4 mvp;
|
||||
} frame_info;
|
||||
}
|
||||
frame_info;
|
||||
|
||||
in vec2 position;
|
||||
out vec2 v_position;
|
||||
|
||||
@@ -6,7 +6,8 @@ uniform FrameInfo {
|
||||
float current_time;
|
||||
vec2 cursor_position;
|
||||
vec2 window_size;
|
||||
} frame_info;
|
||||
}
|
||||
frame_info;
|
||||
|
||||
in vec2 interporlated_texture_coordinates;
|
||||
|
||||
@@ -18,5 +19,7 @@ uniform sampler2D contents2;
|
||||
void main() {
|
||||
vec4 tex1 = texture(contents1, interporlated_texture_coordinates);
|
||||
vec4 tex2 = texture(contents2, interporlated_texture_coordinates);
|
||||
frag_color = mix(tex1, tex2, clamp(frame_info.cursor_position.x / frame_info.window_size.x, 0.0, 1.0));
|
||||
frag_color = mix(
|
||||
tex1, tex2,
|
||||
clamp(frame_info.cursor_position.x / frame_info.window_size.x, 0.0, 1.0));
|
||||
}
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
uniform UniformBuffer {
|
||||
mat4 mvp;
|
||||
} uniform_buffer;
|
||||
}
|
||||
uniform_buffer;
|
||||
|
||||
in vec3 vertex_position;
|
||||
in vec2 texture_coordinates;
|
||||
|
||||
@@ -31,7 +31,7 @@ layout(location = 0) out vec4 fragColor;
|
||||
const float PI = 3.1415926535897932384626;
|
||||
const float PI_ROTATE_RIGHT = PI * 0.0078125;
|
||||
const float PI_ROTATE_LEFT = PI * -0.0078125;
|
||||
const float ONE_THIRD = 1./3.;
|
||||
const float ONE_THIRD = 1. / 3.;
|
||||
const vec2 TURBULENCE_SCALE = vec2(0.8);
|
||||
|
||||
float triangle_noise(highp vec2 n) {
|
||||
@@ -45,7 +45,7 @@ float threshold(float v, float l, float h) {
|
||||
return step(l, v) * (1.0 - step(h, v));
|
||||
}
|
||||
|
||||
mat2 rotate2d(vec2 rad){
|
||||
mat2 rotate2d(vec2 rad) {
|
||||
return mat2(rad.x, -rad.y, rad.y, rad.x);
|
||||
}
|
||||
|
||||
@@ -61,7 +61,11 @@ float soft_ring(vec2 uv, vec2 xy, float radius, float thickness, float blur) {
|
||||
return clamp(circle_outer - circle_inner, 0.0, 1.0);
|
||||
}
|
||||
|
||||
float circle_grid(vec2 resolution, vec2 p, vec2 xy, vec2 rotation, float cell_diameter) {
|
||||
float circle_grid(vec2 resolution,
|
||||
vec2 p,
|
||||
vec2 xy,
|
||||
vec2 rotation,
|
||||
float cell_diameter) {
|
||||
p = rotate2d(rotation) * (xy - p) + xy;
|
||||
p = mod(p, cell_diameter) / resolution;
|
||||
float cell_uv = cell_diameter / resolution.y * 0.5;
|
||||
@@ -80,9 +84,12 @@ float sparkle(vec2 uv, float t) {
|
||||
|
||||
float turbulence(vec2 uv) {
|
||||
vec2 uv_scale = uv * TURBULENCE_SCALE;
|
||||
float g1 = circle_grid(TURBULENCE_SCALE, uv_scale, u_circle1, u_rotation1, 0.17);
|
||||
float g2 = circle_grid(TURBULENCE_SCALE, uv_scale, u_circle2, u_rotation2, 0.2);
|
||||
float g3 = circle_grid(TURBULENCE_SCALE, uv_scale, u_circle3, u_rotation3, 0.275);
|
||||
float g1 =
|
||||
circle_grid(TURBULENCE_SCALE, uv_scale, u_circle1, u_rotation1, 0.17);
|
||||
float g2 =
|
||||
circle_grid(TURBULENCE_SCALE, uv_scale, u_circle2, u_rotation2, 0.2);
|
||||
float g3 =
|
||||
circle_grid(TURBULENCE_SCALE, uv_scale, u_circle3, u_rotation3, 0.275);
|
||||
float v = (g1 * g1 + g2 - g3) * 0.5;
|
||||
return clamp(0.45 + 0.8 * v, 0.0, 1.0);
|
||||
}
|
||||
@@ -94,9 +101,12 @@ void main() {
|
||||
float radius = u_max_radius * u_radius_scale;
|
||||
float turbulence = turbulence(uv);
|
||||
float ring = soft_ring(p, u_center, radius, 0.05 * u_max_radius, u_blur);
|
||||
float sparkle = sparkle(density_uv, u_noise_phase) * ring * turbulence * u_sparkle_alpha;
|
||||
float wave_alpha = soft_circle(p, u_center, radius, u_blur) * u_alpha * u_color.a;
|
||||
float sparkle =
|
||||
sparkle(density_uv, u_noise_phase) * ring * turbulence * u_sparkle_alpha;
|
||||
float wave_alpha =
|
||||
soft_circle(p, u_center, radius, u_blur) * u_alpha * u_color.a;
|
||||
vec4 wave_color = vec4(u_color.rgb * wave_alpha, wave_alpha);
|
||||
vec4 sparkle_color = vec4(u_sparkle_color.rgb * u_sparkle_color.a, u_sparkle_color.a);
|
||||
vec4 sparkle_color =
|
||||
vec4(u_sparkle_color.rgb * u_sparkle_color.a, u_sparkle_color.a);
|
||||
fragColor = mix(wave_color, sparkle_color, sparkle);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
|
||||
#ifdef IMPELLER_TARGET_OPENGLES
|
||||
|
||||
void main() {
|
||||
@@ -13,22 +12,22 @@ void main() {
|
||||
|
||||
uniform FrameInfo {
|
||||
mat4 mvp;
|
||||
} frame_info;
|
||||
}
|
||||
frame_info;
|
||||
|
||||
readonly buffer InstanceInfo {
|
||||
vec4 colors[];
|
||||
} instance_info;
|
||||
}
|
||||
instance_info;
|
||||
|
||||
in vec2 vtx;
|
||||
|
||||
out vec4 v_color;
|
||||
|
||||
void main () {
|
||||
gl_Position = frame_info.mvp *
|
||||
vec4(vtx.x + 105.0 * gl_InstanceIndex,
|
||||
vtx.y + 105.0 * gl_InstanceIndex,
|
||||
0.0,
|
||||
1.0);
|
||||
void main() {
|
||||
gl_Position =
|
||||
frame_info.mvp * vec4(vtx.x + 105.0 * gl_InstanceIndex,
|
||||
vtx.y + 105.0 * gl_InstanceIndex, 0.0, 1.0);
|
||||
v_color = instance_info.colors[gl_InstanceIndex];
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
uniform sampler1D tex;
|
||||
void main()
|
||||
{
|
||||
vec4 x = textureOffset(tex, 1.0, -10);
|
||||
void main() {
|
||||
vec4 x = textureOffset(tex, 1.0, -10);
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ layout(location = 1) uniform vec2 iResolution;
|
||||
layout(location = 0) out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
vec2 uv = gl_FragCoord.xy/iResolution;
|
||||
vec2 uv = gl_FragCoord.xy / iResolution;
|
||||
float t = 4 * iTime;
|
||||
vec3 col = 0.5 + 0.5*cos(t + uv.xyx + vec3(0,1,4));
|
||||
fragColor = vec4(col,1.0);
|
||||
vec3 col = 0.5 + 0.5 * cos(t + uv.xyx + vec3(0, 1, 4));
|
||||
fragColor = vec4(col, 1.0);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
|
||||
uniform UniformBufferObject {
|
||||
Uniforms uniforms;
|
||||
} ubo;
|
||||
}
|
||||
ubo;
|
||||
|
||||
uniform sampler2D world;
|
||||
|
||||
@@ -18,6 +19,8 @@ in float stuff;
|
||||
out vec4 outStuff;
|
||||
|
||||
void main() {
|
||||
gl_Position = ubo.uniforms.projection * ubo.uniforms.view * ubo.uniforms.model * vec4(inPosition22, 1.0) * inAnotherPosition;
|
||||
gl_Position = ubo.uniforms.projection * ubo.uniforms.view *
|
||||
ubo.uniforms.model * vec4(inPosition22, 1.0) *
|
||||
inAnotherPosition;
|
||||
outStuff = texture(world, inPosition);
|
||||
}
|
||||
|
||||
@@ -8,26 +8,29 @@ struct SomeStruct {
|
||||
|
||||
layout(binding = 0) writeonly buffer Output {
|
||||
vec4 elements[];
|
||||
} output_data;
|
||||
}
|
||||
output_data;
|
||||
|
||||
layout(binding = 1) readonly buffer Input0 {
|
||||
int some_int;
|
||||
ivec2 fixed_array[3];
|
||||
vec4 elements[];
|
||||
} input_data0;
|
||||
}
|
||||
input_data0;
|
||||
|
||||
layout(binding = 2) readonly buffer Input1 {
|
||||
SomeStruct some_struct;
|
||||
uvec2 fixed_array[4];
|
||||
vec4 elements[];
|
||||
} input_data1;
|
||||
}
|
||||
input_data1;
|
||||
|
||||
uniform Info {
|
||||
uint count;
|
||||
} info;
|
||||
}
|
||||
info;
|
||||
|
||||
void main()
|
||||
{
|
||||
void main() {
|
||||
uint ident = gl_GlobalInvocationID.x;
|
||||
// TODO(dnfield): https://github.com/flutter/flutter/issues/112683
|
||||
// We should be able to use length here instead of an extra arrgument.
|
||||
@@ -35,8 +38,12 @@ void main()
|
||||
return;
|
||||
}
|
||||
|
||||
output_data.elements[ident] = input_data0.elements[ident] * input_data1.elements[ident];
|
||||
output_data.elements[ident].x += input_data0.fixed_array[1].x + input_data1.some_struct.i;
|
||||
output_data.elements[ident].y += input_data1.fixed_array[0].y + input_data1.some_struct.vf.x;
|
||||
output_data.elements[ident].z += input_data0.some_int + input_data1.some_struct.vf.y;
|
||||
output_data.elements[ident] =
|
||||
input_data0.elements[ident] * input_data1.elements[ident];
|
||||
output_data.elements[ident].x +=
|
||||
input_data0.fixed_array[1].x + input_data1.some_struct.i;
|
||||
output_data.elements[ident].y +=
|
||||
input_data1.fixed_array[0].y + input_data1.some_struct.vf.x;
|
||||
output_data.elements[ident].z +=
|
||||
input_data0.some_int + input_data1.some_struct.vf.y;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
layout(vertices = 4) out;
|
||||
|
||||
void main() {
|
||||
gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
|
||||
gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
layout (quads, equal_spacing, ccw) in;
|
||||
layout(quads, equal_spacing, ccw) in;
|
||||
|
||||
void main() {
|
||||
float u = gl_TessCoord.x;
|
||||
@@ -6,9 +6,7 @@ void main() {
|
||||
float v = gl_TessCoord.y;
|
||||
float omv = 1 - v;
|
||||
|
||||
gl_Position =
|
||||
omu * omv * gl_in[0].gl_Position +
|
||||
u * omv * gl_in[1].gl_Position +
|
||||
u * v * gl_in[2].gl_Position +
|
||||
omu * v * gl_in[3].gl_Position;
|
||||
gl_Position = omu * omv * gl_in[0].gl_Position +
|
||||
u * omv * gl_in[1].gl_Position + u * v * gl_in[2].gl_Position +
|
||||
omu * v * gl_in[3].gl_Position;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
|
||||
uniform UniformBufferObject {
|
||||
Uniforms uniforms;
|
||||
} ubo;
|
||||
}
|
||||
ubo;
|
||||
|
||||
uniform sampler2D world;
|
||||
|
||||
@@ -18,6 +19,8 @@ in float stuff;
|
||||
out vec4 outStuff;
|
||||
|
||||
void main() {
|
||||
gl_Position = ubo.uniforms.projection * ubo.uniforms.view * ubo.uniforms.model * vec4(inPosition22, 1.0) * inAnotherPosition;
|
||||
gl_Position = ubo.uniforms.projection * ubo.uniforms.view *
|
||||
ubo.uniforms.model * vec4(inPosition22, 1.0) *
|
||||
inAnotherPosition;
|
||||
outStuff = texture(world, inPosition);
|
||||
}
|
||||
|
||||
@@ -4,9 +4,10 @@
|
||||
|
||||
#include "types.h"
|
||||
|
||||
layout (set = 3, binding = 17) uniform UniformBufferObject {
|
||||
layout(set = 3, binding = 17) uniform UniformBufferObject {
|
||||
Uniforms uniforms;
|
||||
} ubo;
|
||||
}
|
||||
ubo;
|
||||
|
||||
uniform sampler2D world;
|
||||
|
||||
@@ -18,6 +19,8 @@ in float stuff;
|
||||
out vec4 outStuff;
|
||||
|
||||
void main() {
|
||||
gl_Position = ubo.uniforms.projection * ubo.uniforms.view * ubo.uniforms.model * vec4(inPosition22, 1.0) * inAnotherPosition;
|
||||
gl_Position = ubo.uniforms.projection * ubo.uniforms.view *
|
||||
ubo.uniforms.model * vec4(inPosition22, 1.0) *
|
||||
inAnotherPosition;
|
||||
outStuff = texture(world, inPosition);
|
||||
}
|
||||
|
||||
@@ -6,10 +6,12 @@ uniform FrameInfo {
|
||||
mat4 mvp;
|
||||
vec2 atlas_size;
|
||||
vec4 text_color;
|
||||
} frame_info;
|
||||
}
|
||||
frame_info;
|
||||
|
||||
in vec2 unit_vertex;
|
||||
in mat4 glyph_position; // <--- Causes multiple slots to be used and is a failure.
|
||||
in mat4
|
||||
glyph_position; // <--- Causes multiple slots to be used and is a failure.
|
||||
in vec2 destination_size;
|
||||
in vec2 source_position;
|
||||
in vec2 source_glyph_size;
|
||||
@@ -21,9 +23,8 @@ out vec2 v_atlas_size;
|
||||
out vec4 v_text_color;
|
||||
|
||||
void main() {
|
||||
gl_Position = frame_info.mvp
|
||||
* glyph_position
|
||||
* vec4(unit_vertex.x * destination_size.x,
|
||||
gl_Position = frame_info.mvp * glyph_position *
|
||||
vec4(unit_vertex.x * destination_size.x,
|
||||
unit_vertex.y * destination_size.y, 0.0, 1.0);
|
||||
|
||||
v_unit_vertex = unit_vertex;
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
|
||||
uniform FrameInfo {
|
||||
mat4 mvp;
|
||||
} frame_info;
|
||||
}
|
||||
frame_info;
|
||||
|
||||
in vec2 vtx;
|
||||
|
||||
void main() {
|
||||
gl_Position = frame_info.mvp * vec4(vtx, 0.0, 1.0);
|
||||
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
|
||||
precision highp float;
|
||||
|
||||
layout ( location = 0 ) out vec4 oColor;
|
||||
layout(location = 0) out vec4 oColor;
|
||||
|
||||
layout ( location = 0 ) uniform sampler2D iChild;
|
||||
layout(location = 0) uniform sampler2D iChild;
|
||||
|
||||
void main() {
|
||||
// iChild1 is an image that is half blue, half green,
|
||||
@@ -16,4 +16,3 @@ void main() {
|
||||
oColor = texture(iChild, vec2(1, 0));
|
||||
oColor.a = 1.0;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
|
||||
precision highp float;
|
||||
|
||||
layout ( location = 0 ) out vec4 color;
|
||||
layout(location = 0) out vec4 color;
|
||||
|
||||
layout ( location = 0 ) uniform sampler2D child1;
|
||||
layout ( location = 1 ) uniform float a;
|
||||
layout ( location = 2 ) uniform sampler2D child2;
|
||||
layout ( location = 3 ) uniform float b;
|
||||
layout(location = 0) uniform sampler2D child1;
|
||||
layout(location = 1) uniform float a;
|
||||
layout(location = 2) uniform sampler2D child2;
|
||||
layout(location = 3) uniform float b;
|
||||
|
||||
void main() {
|
||||
// child1 is a 10x10 image where the left half is blue and the right
|
||||
@@ -23,4 +23,3 @@ void main() {
|
||||
|
||||
color = c1 * c2;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
|
||||
precision highp float;
|
||||
|
||||
layout ( location = 0 ) out vec4 oColor;
|
||||
layout(location = 0) out vec4 oColor;
|
||||
|
||||
layout ( location = 0 ) uniform float a; // should be 1.0
|
||||
layout(location = 0) uniform float a; // should be 1.0
|
||||
|
||||
float addA(float x) {
|
||||
return x + a;
|
||||
@@ -27,8 +27,8 @@ float multiParam(float x, float y, float z) {
|
||||
}
|
||||
|
||||
void main() {
|
||||
float x = addA(0.0); // x = 0 + 1;
|
||||
vec3 v3 = composedFunction(x); // v3 = vec3(2, 1, 1);
|
||||
x = multiParam(v3.x, v3.y, v3.z); // x = 2 * 1 * 1 * 1;
|
||||
oColor = vec4(0.0, x / 2.0, 0.0, 1.0); // vec4(0, 1, 0, 1);
|
||||
float x = addA(0.0); // x = 0 + 1;
|
||||
vec3 v3 = composedFunction(x); // v3 = vec3(2, 1, 1);
|
||||
x = multiParam(v3.x, v3.y, v3.z); // x = 2 * 1 * 1 * 1;
|
||||
oColor = vec4(0.0, x / 2.0, 0.0, 1.0); // vec4(0, 1, 0, 1);
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
|
||||
precision highp float;
|
||||
|
||||
layout ( location = 0 ) out vec4 oColor;
|
||||
layout(location = 0) out vec4 oColor;
|
||||
|
||||
layout ( location = 0 ) uniform float a; // should be 1.0
|
||||
layout(location = 0) uniform float a; // should be 1.0
|
||||
|
||||
float saturate(float x) {
|
||||
return clamp(x, 0.0, 1.0);
|
||||
@@ -31,8 +31,8 @@ float multiParam(float x, float y, float z) {
|
||||
}
|
||||
|
||||
void main() {
|
||||
float x = saturate(addA(0.0)); // x = 0 + 1;
|
||||
vec3 v3 = composedFunction(x); // v3 = vec3(2, 1, 1);
|
||||
x = multiParam(v3.x, v3.y, v3.z); // x = 2 * 1 * 1 * 1;
|
||||
oColor = vec4(0.0, x / 2.0, 0.0, 1.0); // vec4(0, 1, 0, 1);
|
||||
float x = saturate(addA(0.0)); // x = 0 + 1;
|
||||
vec3 v3 = composedFunction(x); // v3 = vec3(2, 1, 1);
|
||||
x = multiParam(v3.x, v3.y, v3.z); // x = 2 * 1 * 1 * 1;
|
||||
oColor = vec4(0.0, x / 2.0, 0.0, 1.0); // vec4(0, 1, 0, 1);
|
||||
}
|
||||
|
||||
@@ -9,5 +9,5 @@ precision highp float;
|
||||
layout(location = 0) out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
fragColor = vec4(0.0, 1.0, 0.0, 1.0);
|
||||
fragColor = vec4(0.0, 1.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
@@ -11,5 +11,5 @@ layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 0) uniform float a;
|
||||
|
||||
void main() {
|
||||
fragColor = vec4(0.0, a, 0.0, 1.0);
|
||||
fragColor = vec4(0.0, a, 0.0, 1.0);
|
||||
}
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
|
||||
precision highp float;
|
||||
|
||||
layout ( location = 0 ) out vec4 oColor;
|
||||
layout(location = 0) out vec4 oColor;
|
||||
|
||||
layout ( location = 1 ) uniform float floatArray[2];
|
||||
layout ( location = 3 ) uniform vec2 vec2Array[2];
|
||||
layout ( location = 7 ) uniform vec3 vec3Array[2];
|
||||
layout ( location = 13 ) uniform mat2 mat2Array[2];
|
||||
layout(location = 1) uniform float floatArray[2];
|
||||
layout(location = 3) uniform vec2 vec2Array[2];
|
||||
layout(location = 7) uniform vec3 vec3Array[2];
|
||||
layout(location = 13) uniform mat2 mat2Array[2];
|
||||
|
||||
void main() {
|
||||
vec4 badColor = vec4(1.0, 0, 0, 1.0);
|
||||
@@ -20,16 +20,11 @@ void main() {
|
||||
// The test populates the uniforms with strictly increasing values, so if
|
||||
// out-of-order values are read out of the uniforms, then the bad color that
|
||||
// causes the test to fail is returned.
|
||||
if (floatArray[0] >= floatArray[1] ||
|
||||
floatArray[1] >= vec2Array[0].x ||
|
||||
vec2Array[0].x >= vec2Array[0].y ||
|
||||
vec2Array[0].y >= vec2Array[1].x ||
|
||||
vec2Array[1].x >= vec2Array[1].y ||
|
||||
vec2Array[1].y >= vec3Array[0].x ||
|
||||
vec3Array[0].x >= vec3Array[0].y ||
|
||||
vec3Array[0].y >= vec3Array[0].z ||
|
||||
vec3Array[0].z >= vec3Array[1].x ||
|
||||
vec3Array[1].x >= vec3Array[1].y ||
|
||||
if (floatArray[0] >= floatArray[1] || floatArray[1] >= vec2Array[0].x ||
|
||||
vec2Array[0].x >= vec2Array[0].y || vec2Array[0].y >= vec2Array[1].x ||
|
||||
vec2Array[1].x >= vec2Array[1].y || vec2Array[1].y >= vec3Array[0].x ||
|
||||
vec3Array[0].x >= vec3Array[0].y || vec3Array[0].y >= vec3Array[0].z ||
|
||||
vec3Array[0].z >= vec3Array[1].x || vec3Array[1].x >= vec3Array[1].y ||
|
||||
vec3Array[1].y >= vec3Array[1].z ||
|
||||
vec3Array[1].z >= mat2Array[0][0][0] ||
|
||||
mat2Array[0][0][0] >= mat2Array[0][0][1] ||
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
|
||||
precision highp float;
|
||||
|
||||
layout ( location = 0 ) out vec4 oColor;
|
||||
layout(location = 0) out vec4 oColor;
|
||||
|
||||
layout ( location = 0 ) uniform float iFloatUniform;
|
||||
layout ( location = 1 ) uniform vec2 iVec2Uniform;
|
||||
layout ( location = 2 ) uniform mat2 iMat2Uniform;
|
||||
layout(location = 0) uniform float iFloatUniform;
|
||||
layout(location = 1) uniform vec2 iVec2Uniform;
|
||||
layout(location = 2) uniform mat2 iMat2Uniform;
|
||||
|
||||
void main() {
|
||||
oColor = vec4(iFloatUniform, iVec2Uniform, iMat2Uniform[1][1]);
|
||||
|
||||
@@ -36,7 +36,7 @@ layout(location = 0) out vec4 fragColor;
|
||||
const float PI = 3.1415926535897932384626;
|
||||
const float PI_ROTATE_RIGHT = PI * 0.0078125;
|
||||
const float PI_ROTATE_LEFT = PI * -0.0078125;
|
||||
const float ONE_THIRD = 1./3.;
|
||||
const float ONE_THIRD = 1. / 3.;
|
||||
const vec2 TURBULENCE_SCALE = vec2(0.8);
|
||||
|
||||
float triangle_noise(highp vec2 n) {
|
||||
@@ -50,7 +50,7 @@ float threshold(float v, float l, float h) {
|
||||
return step(l, v) * (1.0 - step(h, v));
|
||||
}
|
||||
|
||||
mat2 rotate2d(vec2 rad){
|
||||
mat2 rotate2d(vec2 rad) {
|
||||
return mat2(rad.x, -rad.y, rad.y, rad.x);
|
||||
}
|
||||
|
||||
@@ -66,7 +66,11 @@ float soft_ring(vec2 uv, vec2 xy, float radius, float thickness, float blur) {
|
||||
return clamp(circle_outer - circle_inner, 0.0, 1.0);
|
||||
}
|
||||
|
||||
float circle_grid(vec2 resolution, vec2 p, vec2 xy, vec2 rotation, float cell_diameter) {
|
||||
float circle_grid(vec2 resolution,
|
||||
vec2 p,
|
||||
vec2 xy,
|
||||
vec2 rotation,
|
||||
float cell_diameter) {
|
||||
p = rotate2d(rotation) * (xy - p) + xy;
|
||||
p = mod(p, cell_diameter) / resolution;
|
||||
float cell_uv = cell_diameter / resolution.y * 0.5;
|
||||
@@ -85,9 +89,12 @@ float sparkle(vec2 uv, float t) {
|
||||
|
||||
float turbulence(vec2 uv) {
|
||||
vec2 uv_scale = uv * TURBULENCE_SCALE;
|
||||
float g1 = circle_grid(TURBULENCE_SCALE, uv_scale, u_circle1, u_rotation1, 0.17);
|
||||
float g2 = circle_grid(TURBULENCE_SCALE, uv_scale, u_circle2, u_rotation2, 0.2);
|
||||
float g3 = circle_grid(TURBULENCE_SCALE, uv_scale, u_circle3, u_rotation3, 0.275);
|
||||
float g1 =
|
||||
circle_grid(TURBULENCE_SCALE, uv_scale, u_circle1, u_rotation1, 0.17);
|
||||
float g2 =
|
||||
circle_grid(TURBULENCE_SCALE, uv_scale, u_circle2, u_rotation2, 0.2);
|
||||
float g3 =
|
||||
circle_grid(TURBULENCE_SCALE, uv_scale, u_circle3, u_rotation3, 0.275);
|
||||
float v = (g1 * g1 + g2 - g3) * 0.5;
|
||||
return clamp(0.45 + 0.8 * v, 0.0, 1.0);
|
||||
}
|
||||
@@ -101,33 +108,28 @@ void main() {
|
||||
float radius = u_max_radius * u_radius_scale;
|
||||
float turbulence = turbulence(uv);
|
||||
float ring = soft_ring(p, u_center, radius, 0.05 * u_max_radius, u_blur);
|
||||
float sparkle = sparkle(density_uv, u_noise_phase) * ring * turbulence * u_sparkle_alpha;
|
||||
float wave_alpha = soft_circle(p, u_center, radius, u_blur) * u_alpha * u_color.a;
|
||||
float sparkle =
|
||||
sparkle(density_uv, u_noise_phase) * ring * turbulence * u_sparkle_alpha;
|
||||
float wave_alpha =
|
||||
soft_circle(p, u_center, radius, u_blur) * u_alpha * u_color.a;
|
||||
vec4 wave_color = vec4(u_color.rgb * wave_alpha, wave_alpha);
|
||||
vec4 sparkle_color = vec4(u_sparkle_color.rgb * u_sparkle_color.a, u_sparkle_color.a);
|
||||
vec4 sparkle_color =
|
||||
vec4(u_sparkle_color.rgb * u_sparkle_color.a, u_sparkle_color.a);
|
||||
fragColor = mix(wave_color, sparkle_color, sparkle);
|
||||
|
||||
vec4 badColor = vec4(1.0, 0, 0, 1.0);
|
||||
vec4 goodColor = vec4(0, 1.0, 0, 1.0);
|
||||
if (u_color.x > u_alpha ||
|
||||
u_alpha > u_sparkle_color.x ||
|
||||
u_sparkle_color.x > u_sparkle_alpha ||
|
||||
u_sparkle_alpha > u_blur ||
|
||||
u_blur > u_center.x ||
|
||||
u_center.x > u_radius_scale ||
|
||||
u_radius_scale > u_max_radius ||
|
||||
u_max_radius > u_resolution_scale.x ||
|
||||
if (u_color.x > u_alpha || u_alpha > u_sparkle_color.x ||
|
||||
u_sparkle_color.x > u_sparkle_alpha || u_sparkle_alpha > u_blur ||
|
||||
u_blur > u_center.x || u_center.x > u_radius_scale ||
|
||||
u_radius_scale > u_max_radius || u_max_radius > u_resolution_scale.x ||
|
||||
u_resolution_scale.x > u_noise_scale.x ||
|
||||
u_noise_scale.x > u_noise_phase ||
|
||||
u_noise_phase > u_circle1.x ||
|
||||
u_circle1.x > u_circle2.x ||
|
||||
u_circle2.x > u_circle3.x ||
|
||||
u_circle3.x > u_rotation1.x ||
|
||||
u_rotation1.x > u_rotation2.x ||
|
||||
u_noise_scale.x > u_noise_phase || u_noise_phase > u_circle1.x ||
|
||||
u_circle1.x > u_circle2.x || u_circle2.x > u_circle3.x ||
|
||||
u_circle3.x > u_rotation1.x || u_rotation1.x > u_rotation2.x ||
|
||||
u_rotation2.x > u_rotation3.x) {
|
||||
fragColor = badColor;
|
||||
} else {
|
||||
fragColor = goodColor;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,11 +11,7 @@ layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 0) uniform float a;
|
||||
|
||||
void main() {
|
||||
fragColor = vec4(
|
||||
fract(a),
|
||||
// 0.25 + 0.75 = 1.0
|
||||
fract(a + 1.25) + fract(3.75),
|
||||
0.0,
|
||||
1.0
|
||||
);
|
||||
fragColor = vec4(fract(a),
|
||||
// 0.25 + 0.75 = 1.0
|
||||
fract(a + 1.25) + fract(3.75), 0.0, 1.0);
|
||||
}
|
||||
|
||||
@@ -11,11 +11,7 @@ layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 0) uniform float a;
|
||||
|
||||
void main() {
|
||||
fragColor = vec4(
|
||||
0.0,
|
||||
// 57.2957795131 * pi / 180.0 = 1.0
|
||||
float(radians(a * 57.2957795131)),
|
||||
0.0,
|
||||
1.0
|
||||
);
|
||||
fragColor = vec4(0.0,
|
||||
// 57.2957795131 * pi / 180.0 = 1.0
|
||||
float(radians(a * 57.2957795131)), 0.0, 1.0);
|
||||
}
|
||||
|
||||
@@ -11,11 +11,7 @@ layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 0) uniform float a;
|
||||
|
||||
void main() {
|
||||
fragColor = vec4(
|
||||
0.0,
|
||||
// 0.01745329251 * 180.0 / pi = 1.0
|
||||
degrees(a * 0.01745329251),
|
||||
0.0,
|
||||
1.0
|
||||
);
|
||||
fragColor = vec4(0.0,
|
||||
// 0.01745329251 * 180.0 / pi = 1.0
|
||||
degrees(a * 0.01745329251), 0.0, 1.0);
|
||||
}
|
||||
|
||||
@@ -11,11 +11,9 @@ layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 0) uniform float a;
|
||||
|
||||
void main() {
|
||||
fragColor = vec4(
|
||||
/* sin(0.0) = 0.0 */
|
||||
sin(0.0),
|
||||
// sin(1.57079632679) = sin(pi / 2.0) = 1.0
|
||||
sin(a * 1.57079632679),
|
||||
0.0,
|
||||
1.0);
|
||||
fragColor = vec4(
|
||||
/* sin(0.0) = 0.0 */
|
||||
sin(0.0),
|
||||
// sin(1.57079632679) = sin(pi / 2.0) = 1.0
|
||||
sin(a * 1.57079632679), 0.0, 1.0);
|
||||
}
|
||||
|
||||
@@ -11,11 +11,9 @@ layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 0) uniform float a;
|
||||
|
||||
void main() {
|
||||
fragColor = vec4(
|
||||
/* cos(1.57079632679) = cos(pi / 2.0) = 0.0 */
|
||||
cos(a * 1.57079632679),
|
||||
// cos(0.0) = 0.0
|
||||
cos(0.0),
|
||||
0.0,
|
||||
1.0);
|
||||
fragColor = vec4(
|
||||
/* cos(1.57079632679) = cos(pi / 2.0) = 0.0 */
|
||||
cos(a * 1.57079632679),
|
||||
// cos(0.0) = 0.0
|
||||
cos(0.0), 0.0, 1.0);
|
||||
}
|
||||
|
||||
@@ -11,12 +11,9 @@ layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 0) uniform float a;
|
||||
|
||||
void main() {
|
||||
fragColor = vec4(
|
||||
// tan(0.0) = 0.0
|
||||
tan(0.0),
|
||||
// tan(1.57079632679) = tan(pi / 4.0) = 1.0
|
||||
tan(a * 0.785398163),
|
||||
0.0,
|
||||
1.0
|
||||
);
|
||||
fragColor = vec4(
|
||||
// tan(0.0) = 0.0
|
||||
tan(0.0),
|
||||
// tan(1.57079632679) = tan(pi / 4.0) = 1.0
|
||||
tan(a * 0.785398163), 0.0, 1.0);
|
||||
}
|
||||
|
||||
@@ -11,11 +11,9 @@ layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 0) uniform float a;
|
||||
|
||||
void main() {
|
||||
fragColor = vec4(
|
||||
/* sin(0.0) = 0.0 */
|
||||
asin(0.0),
|
||||
// sin(1.0) = 0.8414709848
|
||||
asin(a * 0.8414709848),
|
||||
0.0,
|
||||
1.0);
|
||||
fragColor = vec4(
|
||||
/* sin(0.0) = 0.0 */
|
||||
asin(0.0),
|
||||
// sin(1.0) = 0.8414709848
|
||||
asin(a * 0.8414709848), 0.0, 1.0);
|
||||
}
|
||||
|
||||
@@ -11,12 +11,9 @@ layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 0) uniform float a;
|
||||
|
||||
void main() {
|
||||
fragColor = vec4(
|
||||
// cos(0.0) = 1.0
|
||||
acos(1.0),
|
||||
// cos(1.0) = 0.54030230586
|
||||
acos(a * 0.54030230586),
|
||||
0.0,
|
||||
1.0
|
||||
);
|
||||
fragColor = vec4(
|
||||
// cos(0.0) = 1.0
|
||||
acos(1.0),
|
||||
// cos(1.0) = 0.54030230586
|
||||
acos(a * 0.54030230586), 0.0, 1.0);
|
||||
}
|
||||
|
||||
@@ -11,12 +11,9 @@ layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 0) uniform float a;
|
||||
|
||||
void main() {
|
||||
fragColor = vec4(
|
||||
// tan(0.0) = 0.0
|
||||
atan(0.0),
|
||||
// tan(1.0) = 1.55740772465
|
||||
atan(a * 1.55740772465),
|
||||
0.0,
|
||||
1.0
|
||||
);
|
||||
fragColor = vec4(
|
||||
// tan(0.0) = 0.0
|
||||
atan(0.0),
|
||||
// tan(1.0) = 1.55740772465
|
||||
atan(a * 1.55740772465), 0.0, 1.0);
|
||||
}
|
||||
|
||||
@@ -11,12 +11,9 @@ layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 0) uniform float a;
|
||||
|
||||
void main() {
|
||||
fragColor = vec4(
|
||||
// tan(0.0 / 1.0) = tan(0.0) = 0.0
|
||||
atan(0.0, 1.0),
|
||||
// tan(3.1148154493 / 2.0) = tan(1.55740772465) = 1.0
|
||||
atan(a * 3.1148154493, 2.0),
|
||||
0.0,
|
||||
1.0
|
||||
);
|
||||
fragColor = vec4(
|
||||
// tan(0.0 / 1.0) = tan(0.0) = 0.0
|
||||
atan(0.0, 1.0),
|
||||
// tan(3.1148154493 / 2.0) = tan(1.55740772465) = 1.0
|
||||
atan(a * 3.1148154493, 2.0), 0.0, 1.0);
|
||||
}
|
||||
|
||||
@@ -11,11 +11,5 @@ layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 0) uniform float a;
|
||||
|
||||
void main() {
|
||||
fragColor = vec4(
|
||||
pow(2.0, a-1.0) - 1.0,
|
||||
pow(a * 3.14, 0.0),
|
||||
0.0,
|
||||
1.0
|
||||
);
|
||||
fragColor = vec4(pow(2.0, a - 1.0) - 1.0, pow(a * 3.14, 0.0), 0.0, 1.0);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,12 +11,10 @@ layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 0) uniform float a;
|
||||
|
||||
void main() {
|
||||
fragColor = vec4(
|
||||
0.0,
|
||||
// e^0.0 = 1.0
|
||||
exp(a * 0.0),
|
||||
0.0,
|
||||
// e^2.0 - 6.38905609893 = 7.38905609893 - 6.38905609893 = 1.0
|
||||
exp(a * 2.0) - 6.38905609893
|
||||
);
|
||||
fragColor =
|
||||
vec4(0.0,
|
||||
// e^0.0 = 1.0
|
||||
exp(a * 0.0), 0.0,
|
||||
// e^2.0 - 6.38905609893 = 7.38905609893 - 6.38905609893 = 1.0
|
||||
exp(a * 2.0) - 6.38905609893);
|
||||
}
|
||||
|
||||
@@ -11,12 +11,9 @@ layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 0) uniform float a;
|
||||
|
||||
void main() {
|
||||
fragColor = vec4(
|
||||
// e^0.0 = 1.0
|
||||
log(a),
|
||||
// e^1.0 = e
|
||||
log(a * 2.718281828459),
|
||||
0.0,
|
||||
1.0
|
||||
);
|
||||
fragColor = vec4(
|
||||
// e^0.0 = 1.0
|
||||
log(a),
|
||||
// e^1.0 = e
|
||||
log(a * 2.718281828459), 0.0, 1.0);
|
||||
}
|
||||
|
||||
@@ -11,13 +11,9 @@ layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 0) uniform float a;
|
||||
|
||||
void main() {
|
||||
fragColor = vec4(
|
||||
0.0,
|
||||
// 2.0^0.0 = 1.0
|
||||
exp2(a - 1.0),
|
||||
0.0,
|
||||
// 2.0^3.0 - 7.0 = 8.0 - 7.0 = 1.0
|
||||
exp2(a * 3.0) - 7.0
|
||||
);
|
||||
fragColor = vec4(0.0,
|
||||
// 2.0^0.0 = 1.0
|
||||
exp2(a - 1.0), 0.0,
|
||||
// 2.0^3.0 - 7.0 = 8.0 - 7.0 = 1.0
|
||||
exp2(a * 3.0) - 7.0);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,12 +11,9 @@ layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 0) uniform float a;
|
||||
|
||||
void main() {
|
||||
fragColor = vec4(
|
||||
// 2.0^0.0 = 1.0
|
||||
log2(a),
|
||||
// 2.0^1.0 = 2.0
|
||||
log2(a * 2.0),
|
||||
0.0,
|
||||
1.0
|
||||
);
|
||||
fragColor = vec4(
|
||||
// 2.0^0.0 = 1.0
|
||||
log2(a),
|
||||
// 2.0^1.0 = 2.0
|
||||
log2(a * 2.0), 0.0, 1.0);
|
||||
}
|
||||
|
||||
@@ -11,11 +11,5 @@ layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 0) uniform float a;
|
||||
|
||||
void main() {
|
||||
fragColor = vec4(
|
||||
sqrt(a - 1.0),
|
||||
sqrt(a),
|
||||
sqrt(a * 9.0) - 3.0,
|
||||
1.0
|
||||
);
|
||||
fragColor = vec4(sqrt(a - 1.0), sqrt(a), sqrt(a * 9.0) - 3.0, 1.0);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,12 +11,9 @@ layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 0) uniform float a;
|
||||
|
||||
void main() {
|
||||
fragColor = vec4(
|
||||
0.0,
|
||||
// 1.0 / sqrt(1.0) = 1.0
|
||||
inversesqrt(a),
|
||||
0.0,
|
||||
// 1.0 / sqrt(4.0) + 0.5 = 1.0 / 2.0 + 0.5 = 1.0
|
||||
inversesqrt(a * 4.0) + 0.5
|
||||
);
|
||||
fragColor = vec4(0.0,
|
||||
// 1.0 / sqrt(1.0) = 1.0
|
||||
inversesqrt(a), 0.0,
|
||||
// 1.0 / sqrt(4.0) + 0.5 = 1.0 / 2.0 + 0.5 = 1.0
|
||||
inversesqrt(a * 4.0) + 0.5);
|
||||
}
|
||||
|
||||
@@ -11,10 +11,5 @@ layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 0) uniform float a;
|
||||
|
||||
void main() {
|
||||
fragColor = vec4(
|
||||
0.0,
|
||||
1.0 - min(1.0, 1.0-a),
|
||||
0.0,
|
||||
1.0
|
||||
);
|
||||
fragColor = vec4(0.0, 1.0 - min(1.0, 1.0 - a), 0.0, 1.0);
|
||||
}
|
||||
|
||||
@@ -11,10 +11,5 @@ layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 0) uniform float a;
|
||||
|
||||
void main() {
|
||||
fragColor = vec4(
|
||||
0.0,
|
||||
max(a, 0.5),
|
||||
0.0,
|
||||
1.0);
|
||||
fragColor = vec4(0.0, max(a, 0.5), 0.0, 1.0);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,11 +12,5 @@ layout(location = 0) uniform float a;
|
||||
|
||||
// clamp(x, a, b) is equivalent to min(max(x, a), b)
|
||||
void main() {
|
||||
fragColor = vec4(
|
||||
0.0,
|
||||
clamp(10.0, 0.0, a),
|
||||
0.0,
|
||||
clamp(-1.0, a, 10.0)
|
||||
);
|
||||
fragColor = vec4(0.0, clamp(10.0, 0.0, a), 0.0, clamp(-1.0, a, 10.0));
|
||||
}
|
||||
|
||||
|
||||
@@ -11,10 +11,5 @@ layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 0) uniform float a;
|
||||
|
||||
void main() {
|
||||
fragColor = vec4(
|
||||
0.0,
|
||||
mix(0.0, 1.0, a),
|
||||
0.0,
|
||||
mix(1.0, 0.0, 1.0 - a));
|
||||
fragColor = vec4(0.0, mix(0.0, 1.0, a), 0.0, mix(1.0, 0.0, 1.0 - a));
|
||||
}
|
||||
|
||||
|
||||
@@ -10,12 +10,8 @@ layout(location = 0) out vec4 fragColor;
|
||||
|
||||
layout(location = 0) uniform float a;
|
||||
|
||||
// 0.0 is returned if x (second param) < edge (first param), and 1.0 is returned otherwise.
|
||||
// 0.0 is returned if x (second param) < edge (first param), and 1.0 is returned
|
||||
// otherwise.
|
||||
void main() {
|
||||
fragColor = vec4(
|
||||
0.0,
|
||||
step(0.5, a),
|
||||
0.0,
|
||||
1.0
|
||||
);
|
||||
fragColor = vec4(0.0, step(0.5, a), 0.0, 1.0);
|
||||
}
|
||||
|
||||
@@ -17,12 +17,9 @@ layout(location = 0) uniform float a;
|
||||
// return t * t * (3.0 - 2.0 * t);
|
||||
// }
|
||||
void main() {
|
||||
fragColor = vec4(
|
||||
// smoothstep(1.0, 5.0, 3.0) is 0.5, subtract to get 0.0
|
||||
smoothstep(a, 5.0, 3.0) - 0.5,
|
||||
// smoothstep(0.0, 2.0, 1.0) is 0.5, add 0.5 to get 1.0
|
||||
smoothstep(0.0, 2.0, a) + 0.5,
|
||||
0.0,
|
||||
1.0
|
||||
);
|
||||
fragColor = vec4(
|
||||
// smoothstep(1.0, 5.0, 3.0) is 0.5, subtract to get 0.0
|
||||
smoothstep(a, 5.0, 3.0) - 0.5,
|
||||
// smoothstep(0.0, 2.0, 1.0) is 0.5, add 0.5 to get 1.0
|
||||
smoothstep(0.0, 2.0, a) + 0.5, 0.0, 1.0);
|
||||
}
|
||||
|
||||
@@ -11,10 +11,5 @@ layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 0) uniform float a;
|
||||
|
||||
void main() {
|
||||
fragColor = vec4(
|
||||
0.0,
|
||||
abs(-a),
|
||||
0.0,
|
||||
1.0
|
||||
);
|
||||
fragColor = vec4(0.0, abs(-a), 0.0, 1.0);
|
||||
}
|
||||
|
||||
@@ -11,13 +11,12 @@ layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 0) uniform float a;
|
||||
|
||||
void main() {
|
||||
fragColor = vec4(
|
||||
// length of a zero vector is 0.0
|
||||
length(vec3(a - 1.0, 0.0, 0.0)),
|
||||
// sqrt(3.0^2.0 + 4.0^2.0) - 4.0 = 5.0 - 4.0 = 1.0
|
||||
length(vec2(a * 3.0, 4.0)) - 4.0,
|
||||
0.0,
|
||||
// sqrt(4.0^2.0 + (-4.0)^2.0 + (-4.0)^2.0) + 4.0^2.0) - 7.0 = sqrt(16.0 + 16.0 + 16.0 + 16.0) - 7.0 = sqrt(64.0) - 7.0 = 8.0 - 7.0 = 1.0
|
||||
length(vec4(a * 4.0, -4.0, -4.0, 4.0)) - 7.0
|
||||
);
|
||||
fragColor = vec4(
|
||||
// length of a zero vector is 0.0
|
||||
length(vec3(a - 1.0, 0.0, 0.0)),
|
||||
// sqrt(3.0^2.0 + 4.0^2.0) - 4.0 = 5.0 - 4.0 = 1.0
|
||||
length(vec2(a * 3.0, 4.0)) - 4.0, 0.0,
|
||||
// sqrt(4.0^2.0 + (-4.0)^2.0 + (-4.0)^2.0) + 4.0^2.0) - 7.0 = sqrt(16.0
|
||||
// + 16.0 + 16.0 + 16.0) - 7.0 = sqrt(64.0) - 7.0 = 8.0 - 7.0 = 1.0
|
||||
length(vec4(a * 4.0, -4.0, -4.0, 4.0)) - 7.0);
|
||||
}
|
||||
|
||||
@@ -11,13 +11,11 @@ layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 0) uniform float a;
|
||||
|
||||
void main() {
|
||||
fragColor = vec4(
|
||||
// distance between same value is 0.0
|
||||
distance(a * 7.0, 7.0),
|
||||
// 7.0 - 6.0 = 1.0
|
||||
distance(a * 7.0, 6.0),
|
||||
0.0,
|
||||
// sqrt(7.0 * 7.0 - 6.0 * 8.0) = sqrt(49.0 - 48.0) = sqrt(1.0) = 1.0
|
||||
distance(vec2(a * 7.0, 6.0), vec2(7.0, 8.0))
|
||||
);
|
||||
fragColor = vec4(
|
||||
// distance between same value is 0.0
|
||||
distance(a * 7.0, 7.0),
|
||||
// 7.0 - 6.0 = 1.0
|
||||
distance(a * 7.0, 6.0), 0.0,
|
||||
// sqrt(7.0 * 7.0 - 6.0 * 8.0) = sqrt(49.0 - 48.0) = sqrt(1.0) = 1.0
|
||||
distance(vec2(a * 7.0, 6.0), vec2(7.0, 8.0)));
|
||||
}
|
||||
|
||||
@@ -11,12 +11,9 @@ layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 0) uniform float a;
|
||||
|
||||
void main() {
|
||||
fragColor = vec4(
|
||||
/* cross product of parallel vectors is a zero vector */
|
||||
cross(vec3(a, 2.0, 3.0), vec3(2.0, 4.0, 6.0))[0],
|
||||
1.0,
|
||||
// cross product of parallel vectors is a zero vector
|
||||
cross(vec3(a, 2.0, 3.0), vec3(2.0, 4.0, 6.0))[2],
|
||||
1.0);
|
||||
fragColor = vec4(
|
||||
/* cross product of parallel vectors is a zero vector */
|
||||
cross(vec3(a, 2.0, 3.0), vec3(2.0, 4.0, 6.0))[0], 1.0,
|
||||
// cross product of parallel vectors is a zero vector
|
||||
cross(vec3(a, 2.0, 3.0), vec3(2.0, 4.0, 6.0))[2], 1.0);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,12 +11,10 @@ layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 0) uniform float a;
|
||||
|
||||
void main() {
|
||||
fragColor = vec4(
|
||||
0.0,
|
||||
// normalized result is x = [3/5, 4/5], so add 2/5 to x1 to make 1.0
|
||||
normalize(vec2(a * 3.0, 4.0))[0] + 0.4,
|
||||
0.0,
|
||||
// normalized result is x = [3/5, 4/5], so add 1/5 to x2 to make 1.0
|
||||
normalize(vec2(a * 3.0, 4.0))[1] + 0.2
|
||||
);
|
||||
fragColor =
|
||||
vec4(0.0,
|
||||
// normalized result is x = [3/5, 4/5], so add 2/5 to x1 to make 1.0
|
||||
normalize(vec2(a * 3.0, 4.0))[0] + 0.4, 0.0,
|
||||
// normalized result is x = [3/5, 4/5], so add 1/5 to x2 to make 1.0
|
||||
normalize(vec2(a * 3.0, 4.0))[1] + 0.2);
|
||||
}
|
||||
|
||||
@@ -11,13 +11,11 @@ layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 0) uniform float a;
|
||||
|
||||
void main() {
|
||||
fragColor = vec4(
|
||||
// sign is negative which results to -1.0, and -1.0 + 1.0 is 0.0
|
||||
sign(-72.45) + a,
|
||||
// sign is negative which results to -1.0, and -1.0 + 2.0 is 1.0
|
||||
sign(-12.34) + 2.0 * a,
|
||||
0.0,
|
||||
// sign is positive which results to 1.0
|
||||
sign(a * 0.1234));
|
||||
fragColor = vec4(
|
||||
// sign is negative which results to -1.0, and -1.0 + 1.0 is 0.0
|
||||
sign(-72.45) + a,
|
||||
// sign is negative which results to -1.0, and -1.0 + 2.0 is 1.0
|
||||
sign(-12.34) + 2.0 * a, 0.0,
|
||||
// sign is positive which results to 1.0
|
||||
sign(a * 0.1234));
|
||||
}
|
||||
|
||||
|
||||
@@ -11,14 +11,14 @@ layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 0) uniform float a;
|
||||
|
||||
void main() {
|
||||
fragColor = vec4(
|
||||
0.0,
|
||||
// dot product of incident vector (2nd param) and reference vector (3rd param) is non-negative,
|
||||
// so the negated first param is returned, and its first value is 1.0.
|
||||
faceforward(vec2(-a, 5.0), vec2(1.0, 2.0), vec2(3.0, 4.0))[0],
|
||||
0.0,
|
||||
// dot product of incident vector (2nd param) and reference vector (3rd param) is negative,
|
||||
// so the original first param is returned, and its second value is 5.0, so subtract 4.0 to get 1.0.
|
||||
faceforward(vec2(a, 5.0), vec2(1.0, -2.0), vec2(3.0, 4.0))[1] - 4.0
|
||||
);
|
||||
fragColor =
|
||||
vec4(0.0,
|
||||
// dot product of incident vector (2nd param) and reference vector
|
||||
// (3rd param) is non-negative, so the negated first param is
|
||||
// returned, and its first value is 1.0.
|
||||
faceforward(vec2(-a, 5.0), vec2(1.0, 2.0), vec2(3.0, 4.0))[0], 0.0,
|
||||
// dot product of incident vector (2nd param) and reference vector
|
||||
// (3rd param) is negative, so the original first param is returned,
|
||||
// and its second value is 5.0, so subtract 4.0 to get 1.0.
|
||||
faceforward(vec2(a, 5.0), vec2(1.0, -2.0), vec2(3.0, 4.0))[1] - 4.0);
|
||||
}
|
||||
|
||||
@@ -11,10 +11,6 @@ layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 0) uniform float a;
|
||||
|
||||
void main() {
|
||||
fragColor = vec4(
|
||||
floor(a * 0.25),
|
||||
floor(a * 1.25),
|
||||
floor(a * 0.75),
|
||||
floor(a * 1.75)
|
||||
);
|
||||
fragColor =
|
||||
vec4(floor(a * 0.25), floor(a * 1.25), floor(a * 0.75), floor(a * 1.75));
|
||||
}
|
||||
|
||||
@@ -11,11 +11,6 @@ layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 0) uniform float a;
|
||||
|
||||
void main() {
|
||||
fragColor = vec4(
|
||||
ceil(a * -0.25),
|
||||
ceil(a * 0.25),
|
||||
ceil(a * -0.75),
|
||||
ceil(a * 0.75)
|
||||
);
|
||||
fragColor =
|
||||
vec4(ceil(a * -0.25), ceil(a * 0.25), ceil(a * -0.75), ceil(a * 0.75));
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,5 @@ layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 0) uniform float a;
|
||||
|
||||
void main() {
|
||||
fragColor = vec4(0.0, -(0.0-a), 0.0, 1.0);
|
||||
fragColor = vec4(0.0, -(0.0 - a), 0.0, 1.0);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,5 @@ layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 0) uniform float a;
|
||||
|
||||
void main() {
|
||||
fragColor = vec4(0.0, 0.5 * a + 0.5, 0.0, 1.0);
|
||||
fragColor = vec4(0.0, 0.5 * a + 0.5, 0.0, 1.0);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,5 @@ layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 0) uniform float a;
|
||||
|
||||
void main() {
|
||||
fragColor = vec4(0.0, 2.0 - a, 0.0, 1.0);
|
||||
fragColor = vec4(0.0, 2.0 - a, 0.0, 1.0);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,5 @@ layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 0) uniform float a;
|
||||
|
||||
void main() {
|
||||
fragColor = vec4(0.0, 1.0, 0.0, 1.0) * a;
|
||||
fragColor = vec4(0.0, 1.0, 0.0, 1.0) * a;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,8 +11,7 @@ layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 0) uniform float a;
|
||||
|
||||
void main() {
|
||||
mat4 m = mat4(1.0);
|
||||
m *= a;
|
||||
fragColor = vec4(0.0, 1.0, 0.0, 1.0) * m;
|
||||
mat4 m = mat4(1.0);
|
||||
m *= a;
|
||||
fragColor = vec4(0.0, 1.0, 0.0, 1.0) * m;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,6 @@ layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 0) uniform float a;
|
||||
|
||||
void main() {
|
||||
mat4 identity = mat4(a);
|
||||
fragColor = vec4(0.0, 1.0, 0.0, 1.0) * identity;
|
||||
mat4 identity = mat4(a);
|
||||
fragColor = vec4(0.0, 1.0, 0.0, 1.0) * identity;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 0) uniform float a;
|
||||
|
||||
void main() {
|
||||
mat4 identity = mat4(a);
|
||||
fragColor = identity * vec4(0.0, 1.0, 0.0, 1.0);
|
||||
mat4 identity = mat4(a);
|
||||
fragColor = identity * vec4(0.0, 1.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 0) uniform float a;
|
||||
|
||||
void main() {
|
||||
mat4 m = mat4(1.0) * mat4(a);
|
||||
fragColor = vec4(0.0, 1.0, 0.0, 1.0) * m;
|
||||
mat4 m = mat4(1.0) * mat4(a);
|
||||
fragColor = vec4(0.0, 1.0, 0.0, 1.0) * m;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,6 @@ layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 0) uniform float a;
|
||||
|
||||
void main() {
|
||||
float one = dot(vec2(1.0), vec2(0.0, a));
|
||||
fragColor = vec4(0.0, one, 0.0, 1.0);
|
||||
float one = dot(vec2(1.0), vec2(0.0, a));
|
||||
fragColor = vec4(0.0, one, 0.0, 1.0);
|
||||
}
|
||||
|
||||
@@ -17,4 +17,3 @@ void main() {
|
||||
fragColor = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,5 +17,3 @@ void main() {
|
||||
fragColor = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -17,4 +17,3 @@ void main() {
|
||||
fragColor = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,4 +17,3 @@ void main() {
|
||||
fragColor = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,4 +17,3 @@ void main() {
|
||||
fragColor = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,4 +17,3 @@ void main() {
|
||||
fragColor = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,4 +17,3 @@ void main() {
|
||||
fragColor = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,4 +17,3 @@ void main() {
|
||||
fragColor = vec4(0.0, 1.0, 0.0, 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,4 +17,3 @@ void main() {
|
||||
fragColor = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user