gpt4 book ai didi

c++ - 如何使用着色器制作复古/ NEON /发光效果?

转载 作者:太空狗 更新时间:2023-10-29 21:35:41 26 4
gpt4 key购买 nike

假设这个概念是创建一个由具有 NEON 美学的立方体组成的 map ,例如:Example

目前我有这个顶点着色器:

// Uniforms
uniform mat4 u_projection;
uniform mat4 u_view;
uniform mat4 u_model;

// Vertex atributes
in vec3 a_position;
in vec3 a_normal;
in vec2 a_texture;

vec3 u_light_direction = vec3(1.0, 2.0, 3.0);

// Vertex shader outputs
out vec2 v_texture;
out float v_intensity;

void main()
{
vec3 normal = normalize((u_model * vec4(a_normal, 0.0)).xyz);
vec3 light_dir = normalize(u_light_direction);
v_intensity = max(0.0, dot(normal, light_dir));
v_texture = a_texture;
gl_Position = u_projection * u_view * u_model * vec4(a_position, 1.0);
}

还有这个像素着色器:

in float v_intensity;
in vec2 v_texture;

uniform sampler2D u_texture;

out vec4 fragColor;

void main()
{
fragColor = texture(u_texture, v_texture) * vec4(v_intensity, v_intensity, v_intensity, 1.0);
}

我如何使用它来创建 NEON 效果,例如 3D 立方体示例中的效果?立方体只是带有网格/ Material 的模型。唯一的变化是将 Material 颜色设置为黑色,将轮廓设置为亮粉色或蓝色(可能带有光晕)。

感谢任何帮助。 :)

最佳答案

您通常会将此实现为后处理效果。首先将明亮、饱和的颜色渲染到纹理中,然后在将该纹理绘制到屏幕时应用光晕效果。

关于c++ - 如何使用着色器制作复古/ NEON /发光效果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41673995/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com