python-3.x - 有什么方法可以根据我绘制的二维数据更改 GLSL 中的背景颜色
问题描述
我想改变我的二维图的背景,使其强度根据数据增加或减少。我在下面编写的程序的工作方式是改变线条的颜色,但我希望同样的事情发生在我的背景上。
这是我从下面的代码中得到的结果:
VS = """
#version 450
// Attribute variable that contains coordinates of the vertices.
layout(location = 0) in vec2 position;
out vec2 p;
uniform float count;
// Main function, which needs to set `gl_Position`.
in vec3 vertex_position;
void main() {
p = position;
gl_Position = vec4(position.x, position.y, 0., 1.);
}
"""
FS = """
#version 450
// Output variable of the fragment shader, which is a 4D vector containing the
// RGBA components of the pixel color.
in vec2 p;
out vec4 out_color;
uniform vec2 u_resolution;
// Main fragment shader function.
void main()
{
// We simply set the pixel color to yellow.
vec2 st = gl_FragCoord.xy/u_resolution;
vec3 color = vec3(p.y);
float pct = smoothstep( p.y-0.9, p.y, st.y) -
smoothstep( p.y, p.y+0.9, st.y);
color = (1.0-pct)*color+pct*vec3(0.0,0.0,0.0);
out_color = vec4(color,1.0);
}
"""
这就是我想要的结果:
解决方案
推荐阅读
- aws-amplify - AWS APPSYNC 如何应用 aws_api_key 授权
- javascript - 恢复被覆盖的字符串原型
- python - 可视化 google quickdraw 数据
- javascript - 如何使用 HighCharts 库实现这一点
- android - 将本地 .aar 文件添加到 Titanium SDK 9 Android 模块
- c# - 如何使用 dot net core IService 集合注入多个通用接口依赖项
- ag-grid - 对突出显示的图表使用不透明度不起作用
- python-3.x - 在Linux中相对移动鼠标
- android - CollapsingToolBarLayout 不会与 RecyclerView 一起折叠
- sapui5 - 通过聚合绑定项目的 id