在GLSL中绘制全屏后期处理内部发光

时间:2013-01-08 21:49:53

标签: opengl glsl

我正在寻找一种在GLSL中沿着屏幕四边(内部发光)创建发光效果的方法。我知道如何在片段着色器中创建矩形程序以及如何将其模糊以使其向外发光。但我无法弄清楚我是如何沿着屏幕四边形设置一个朝向内部的发光,具有可配置的发光距离和模糊等级。任何链接到相关的示例或文档? 这就是我需要的: enter image description here

Da代码:

const vec2 resolution = vec2(800,600);
float rect( vec2 p, vec2 b, float smooth )
{
vec2 v = abs(p) - b;
float d = length(max(v,0.0));
return 1.0-pow(d, smooth);
}

void main( void ) {

vec2 unipos = (gl_FragCoord.xy / resolution);
vec2 pos = unipos*2.0-1.0;
pos.x *= resolution.x / resolution.y;


float d1 = rect(pos - vec2(-1.0,0.0), vec2(1,1), 0.1); 
vec3 clr1 = vec3(0.2,0.6,1.0) *d1; 



gl_FragColor = vec4( clr1 , 1.0 );

}

此代码使用外部发光创建全屏矩形,而我只需要发光,它应该是内部的。

0 个答案:

没有答案