[Impeller] Add FlutterFragCoord to impellerc shader lib (flutter/engine#37126)
This commit is contained in:
@@ -1107,6 +1107,7 @@ FILE: ../../../flutter/impeller/compiler/reflector.cc
|
|||||||
FILE: ../../../flutter/impeller/compiler/reflector.h
|
FILE: ../../../flutter/impeller/compiler/reflector.h
|
||||||
FILE: ../../../flutter/impeller/compiler/runtime_stage_data.cc
|
FILE: ../../../flutter/impeller/compiler/runtime_stage_data.cc
|
||||||
FILE: ../../../flutter/impeller/compiler/runtime_stage_data.h
|
FILE: ../../../flutter/impeller/compiler/runtime_stage_data.h
|
||||||
|
FILE: ../../../flutter/impeller/compiler/shader_lib/flutter/runtime_effect.glsl
|
||||||
FILE: ../../../flutter/impeller/compiler/shader_lib/impeller/blending.glsl
|
FILE: ../../../flutter/impeller/compiler/shader_lib/impeller/blending.glsl
|
||||||
FILE: ../../../flutter/impeller/compiler/shader_lib/impeller/branching.glsl
|
FILE: ../../../flutter/impeller/compiler/shader_lib/impeller/branching.glsl
|
||||||
FILE: ../../../flutter/impeller/compiler/shader_lib/impeller/color.glsl
|
FILE: ../../../flutter/impeller/compiler/shader_lib/impeller/color.glsl
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#ifndef RUNTIME_EFFECT_GLSL_
|
||||||
|
#define RUNTIME_EFFECT_GLSL_
|
||||||
|
|
||||||
|
#if defined(IMPELLER_GRAPHICS_BACKEND)
|
||||||
|
|
||||||
|
in vec2 _fragCoord;
|
||||||
|
vec2 FlutterFragCoord() {
|
||||||
|
return _fragCoord;
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined(SKIA_GRAPHICS_BACKEND)
|
||||||
|
|
||||||
|
vec2 FlutterFragCoord() {
|
||||||
|
return gl_FragCoord.xy;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
#error "Runtime effect builtins are not supported for this graphics backend."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
precision highp float;
|
precision highp float;
|
||||||
|
|
||||||
|
#include <flutter/runtime_effect.glsl>
|
||||||
|
|
||||||
layout(location = 0) uniform vec4 u_color;
|
layout(location = 0) uniform vec4 u_color;
|
||||||
layout(location = 1) uniform float u_alpha;
|
layout(location = 1) uniform float u_alpha;
|
||||||
layout(location = 2) uniform vec4 u_sparkle_color;
|
layout(location = 2) uniform vec4 u_sparkle_color;
|
||||||
@@ -86,7 +88,7 @@ float turbulence(vec2 uv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vec2 p = gl_FragCoord.xy;
|
vec2 p = FlutterFragCoord();
|
||||||
vec2 uv = p * u_resolution_scale;
|
vec2 uv = p * u_resolution_scale;
|
||||||
vec2 density_uv = uv - mod(p, u_noise_scale);
|
vec2 density_uv = uv - mod(p, u_noise_scale);
|
||||||
float radius = u_max_radius * u_radius_scale;
|
float radius = u_max_radius * u_radius_scale;
|
||||||
|
|||||||
@@ -2,6 +2,9 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
out vec2 v_position;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
gl_Position = vec4(1.0);
|
gl_Position = vec4(1.0);
|
||||||
|
v_position = vec2(1.0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
precision highp float;
|
precision highp float;
|
||||||
|
|
||||||
|
#include <flutter/runtime_effect.glsl>
|
||||||
|
|
||||||
layout(location = 0) uniform vec4 u_color;
|
layout(location = 0) uniform vec4 u_color;
|
||||||
layout(location = 1) uniform float u_alpha;
|
layout(location = 1) uniform float u_alpha;
|
||||||
layout(location = 2) uniform vec4 u_sparkle_color;
|
layout(location = 2) uniform vec4 u_sparkle_color;
|
||||||
@@ -93,7 +95,7 @@ float turbulence(vec2 uv) {
|
|||||||
void main() {
|
void main() {
|
||||||
// This block of code triggers the compiler to emit the uniforms out of order
|
// This block of code triggers the compiler to emit the uniforms out of order
|
||||||
// if they are not explicitly sorted.
|
// if they are not explicitly sorted.
|
||||||
vec2 p = gl_FragCoord.xy;
|
vec2 p = FlutterFragCoord();
|
||||||
vec2 uv = p * u_resolution_scale;
|
vec2 uv = p * u_resolution_scale;
|
||||||
vec2 density_uv = uv - mod(p, u_noise_scale);
|
vec2 density_uv = uv - mod(p, u_noise_scale);
|
||||||
float radius = u_max_radius * u_radius_scale;
|
float radius = u_max_radius * u_radius_scale;
|
||||||
|
|||||||
Reference in New Issue
Block a user