代码拉取完成,页面将自动刷新
shader_type canvas_item;
uniform sampler2D centerss;
uniform int cells;
/*
void fragment()
{
vec3 centers[100];
for (int i=0; i<centers.length(); i++)
{
centers[i] = vec3(0.0, 0.0, 0.0);
}
centers[1] = vec3(0.5, 0.25, 1.0);
centers[2] = vec3(0.7, 0.5, 1.0);
centers[3] = vec3(0.6, 0.8, 1.0);
COLOR = vec4(0.0, 0.0, 0.0, 1.0);
float influnce = 0.0;
for (int i=0; i<centers.length(); i++)
{
float distance_to_center = distance(centers[i].xy / TEXTURE_PIXEL_SIZE, UV / TEXTURE_PIXEL_SIZE);
influnce += (1.0 / distance_to_center) * centers[i].z;
}
if(influnce > 0.2)
{
COLOR = vec4(1.0);
}
else
{
COLOR = vec4(0.0);
}
}
*/
void fragment()
{
COLOR = vec4(0.0, 0.0, 0.0, 1.0);//init texture
vec4 centers[300];
for(int i=0; i<300; i++)
{
centers[i] = vec4(0.0);
}
for(int i=0; i<cells; i++)
{
centers[i] = vec4(texture(centerss, vec2(float(i)/300.0, 0.5)).r, texture(centerss, vec2(float(i)/300.0, 0.5)).g, texture(centerss, vec2(float(i)/300.0, 0.5)).b, 1.0);
}
int team = 0;
float influnce = 0.0;
for (int i=0; i<centers.length(); i++)
{
float distance_to_center = distance(centers[i].xy / TEXTURE_PIXEL_SIZE, UV / TEXTURE_PIXEL_SIZE);
influnce += (1.0 / distance_to_center) * centers[i].w;
if(centers[i].z > 0.5) team+=1;
else team -= 1;
}
if(influnce > 0.2)
{
if(team>0)
COLOR = vec4(1.0, 0.0, 0.0, 1.0);
else
COLOR = vec4(0.0, 0.0, 1.0, 1.0);
}
else
{
COLOR = vec4(0.0);
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。