2017-12-05 16 views
0

최근에 누군가가 자신의 쉐이더를 OBS에 통합 할 수있는 모듈을 OBS Studio에 추가했습니다. 나는 쉐이더를 작성한 적이 없지만, 어떤 자료를 읽은 후에는 요점을 얻었습니다. 특정 픽셀의 RGBA 값을 나타내는 약간의 메모리를 반환하는 함수입니다.보간을위한 Texture2D 객체 유지하기 HLSL

여기에 문제가 있는데, 너무 익숙하지 않아 몇 가지 다른 고급 쉐이더 언어가있는 것처럼 보입니다. 나는 하나의 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); 
} 

답변

0

그래서, 다행히 그것은 쉐이더 오류를 실패 할 때 실제로 OBS의 로그에 출력되는 것으로 나타났다. 전 세계적으로 변수를 선언하면서 뭔가 떠 올랐습니다. 제대로 시작 할 수있는 권리 데이터 형식으로 호출하지 않았다 LERP 내가 사용하는보고 있었다 NOT 어떤 사실이었다 ... 짧은 그래서

10:53:49.413: C:\Program Files (x86)\obs-studio\bin\64bit\ (Pixel shader, technique Draw, pass 0)(38,40-50): error X3004: undeclared identifier 'blur_factor' 
10:53:49.413: C:\Program Files (x86)\obs-studio\bin\64bit\ (Pixel shader, technique Draw, pass 0)(38,12-51): error X3013: 'lerp': no matching 3 parameter intrinsic function 
10:53:49.413: C:\Program Files (x86)\obs-studio\bin\64bit\ (Pixel shader, technique Draw, pass 0)(38,12-51): error X3013: Possible intrinsic functions are: 
10:53:49.413: C:\Program Files (x86)\obs-studio\bin\64bit\ (Pixel shader, technique Draw, pass 0)(38,12-51): error X3013:  lerp(float|half|min10float|min16float, float|half|min10float|min16float, float|half|min10float|min16float) 

: 초기 코드에 대해 나는이있어 썼다.

11:12:46.880: C:\Program Files (x86)\obs-studio\bin\64bit\ (Pixel shader, technique Draw, pass 0)(27,3-31): error X3025: global variables are implicitly constant, enable compatibility mode to allow modification 

아 ... 그래서 ... 전역 변수 :

texture2d previmage[8]; 

float4 mainImage(VertData v_in) : TARGET{ 
    //...etc etc 
    //manipulating the array, copying over the texture2d OBS provides 
} 

은 그 때 나는이 얻을 그래서 ... 내가 texture2d 년대의 배열을 만들 수있는 가정 쉐이더를 작성하기로 결정 던지기 후 HLSL에서는 내가 알지 못하는 이상한 행동을하고 있으며,이 접근법을 약간 묵음으로 만듭니다 ... 상수 값을 수정할 수없고 프레임 버퍼가 필요합니다.

잠재적 인 해결책? 정적 변수! 이제

float4 mainImage(VertData v_in) : TARGET 
{ 
    int i = 0; 
    static texture2d previmage[8] = {image,image,image,image,image,image,image,image}; 

    if(v_in.uv.x == 1 && v_in.uv.y == 1){ 
     for(i = 0; i <= 6; i++){ 
      previmage[i+1] = previmage[i]; 
     } 
     previmage[0] = image; 
    } 

    float4 sum = 0; 
    float4 samples[8]; 

    for(i = 0; i < 8; i++){ 
     samples[i] = previmage[i].Sample(textureSampler, v_in.uv); 
     sum += samples[i]; 
    } 

    return sum/8.0; 
} 

... 음 적어도 것은 오류를 던지고되지 않고 화면에 렌더링하는 것은, 불행하게도 ... 내가/효과를 볼 수 없습니다 ... 잠재적으로 의미있다하지 않습니다 여기에 오류가 있습니다. 또는 ... 아마도 8 프레임으로는 눈에 띄는 동작 흐림 효과를 내기에는 충분하지 않습니다.