【发布时间】:2017-12-08 03:49:49
【问题描述】:
最近有人向 OBS Studio 添加了一个模块,允许任何人将自己的着色器合并到 OBS 中。我从来没有接触过编写着色器,但是在阅读了一些材料之后,我明白了要点,它是一个返回一些内存的函数,表示特定像素的 RGBA 值。
这就是问题所在,我对此太陌生了,在我看来好像有几种不同的高级着色器语言?我不知道 OBS Studio 使用的是哪一个,https://github.com/nleseul/obs-shaderfilter 的作者似乎也不知道。任何指向什么语法/什么文档的指针当然都会非常感激。
我的目标是做一个非常愚蠢的运动模糊。也就是说,虽然我的目标是我想在某种缓冲区中保留几帧以供使用,但我认为这对于其他效果来说是一件非常有用的事情......这就是我卡住的地方.这是我从Shaders for Game Programmers and Artists pg.87 得到的内容,适用于使用着色器插件*
uniform float4 blur_factor;
texture2d previmage;
//texture2d image; //this is the input data we're playing around with
float4 mainImage(VertData v_in) : TARGET
{
float4 originalFrame = image.Sample(textureSampler, v_in.uv);
float4 oldFrame = previmage.Sample(textureSampler, v_in.uv);
//this function's going pixel by pixel, I should be pushing
//to the frame buffer here* or there should be some way of modifying
//the frame buffer pixel by pixel, second option makes more sense to do
if(v_in.uv.x == 1 && v_in.uv.y == 1){
//it couldn't have been this easy...it's never this easy
//uncommenting the line below clearly causes a problem, I don't have a debugger for this
//previmage = image;
//this doesn't work either, wishful thinking
//previmage = texture2d(image);
}
//this may not actually be the function to use for a motion blur but at the very least it's mixing two textures together so that I'd have a proof of concept working*
return lerp(originalFrame,oldFrame,blur_factor);
}
【问题讨论】:
标签: hlsl