2016-09-18 1 views
0

그래서 다음과 같은 문제가 있습니다 :Shader가 Monogame에서 작동하지 않습니다 (셰이더가없는 것처럼 보입니다) | C#

내 게임에서 멋진 블룸 효과를 원합니다. 하지만 내 쉐이더와 쉐이더를 사용하려고 할 때 .draw(); 메서드는 변경되지 않은 것처럼 보입니다 ... 셰이더를 사용하지 않는 것 같습니다. 또한 셰이더 매개 변수를 변경하면 아무 것도 변경되지 않습니다. BloomThreshold를 10000f로 설정할 수 있으며 0f 또는 1f처럼 보입니다. 쉐이더의 전체 멍청한 놈에게 도움이 될 것입니다. 바로 쉐이더없이, 쉐이더와 왼쪽

는 :

: 이것은 내 꽃 클래스의 호출 방법의 발췌입니다

protected override void Draw (GameTime gameTime) { 
    bloom.BeginDraw(); 
    bloom.Draw(gameTime); 

    spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive); 
    spriteBatch.Draw(texture, new Rectangle(300, 300, 50, 50), Color.White); 
    spriteBatch.End(); 

    base.Draw(gameTime); 
} 

:

enter image description here

이 내 무승부 루프

/// <summary> 
    /// This should be called at the very start of the scene rendering. The bloom 
    /// component uses it to redirect drawing into its custom rendertarget, so it 
    /// can capture the scene image in preparation for applying the bloom filter. 
    /// </summary> 
    public void BeginDraw() 
    { 
     if (Visible) 
     { 
      GraphicsDevice.SetRenderTarget(sceneRenderTarget); 
     } 

    } 


    /// <summary> 
    /// This is where it all happens. Grabs a scene that has already been rendered, 
    /// and uses postprocess magic to add a glowing bloom effect over the top of it. 
    /// </summary> 
    public override void Draw(GameTime gameTime) 
    { 

     GraphicsDevice.SamplerStates[1] = SamplerState.LinearClamp; 

     // Pass 1: draw the scene into rendertarget 1, using a 
     // shader that extracts only the brightest parts of the image. 
     bloomExtractEffect.Parameters["BloomThreshold"].SetValue(
      Settings.BloomThreshold); 

     DrawFullscreenQuad(sceneRenderTarget, renderTarget1, 
          bloomExtractEffect, 
          IntermediateBuffer.PreBloom); 

     // Pass 2: draw from rendertarget 1 into rendertarget 2, 
     // using a shader to apply a horizontal gaussian blur filter. 
     SetBlurEffectParameters(1.0f/(float)renderTarget1.Width, 0); 

     DrawFullscreenQuad(renderTarget1, renderTarget2, 
          gaussianBlurEffect, 
          IntermediateBuffer.BlurredHorizontally); 


     // Pass 3: draw from rendertarget 2 back into rendertarget 1, 
     // using a shader to apply a vertical gaussian blur filter. 
     SetBlurEffectParameters(0, 1.0f/(float)renderTarget1.Height); 

     DrawFullscreenQuad(renderTarget2, renderTarget1, 
          gaussianBlurEffect, 
          IntermediateBuffer.BlurredBothWays); 

     // Pass 4: draw both rendertarget 1 and the original scene 
     // image back into the main backbuffer, using a shader that 
     // combines them to produce the final bloomed result. 
     GraphicsDevice.SetRenderTarget(null); 

     EffectParameterCollection parameters = bloomCombineEffect.Parameters; 

     parameters["BloomIntensity"].SetValue(Settings.BloomIntensity); 
     parameters["BaseIntensity"].SetValue(Settings.BaseIntensity); 
     parameters["BloomSaturation"].SetValue(Settings.BloomSaturation); 
     parameters["BaseSaturation"].SetValue(Settings.BaseSaturation); 

     //GraphicsDevice.Textures[1] = sceneRenderTarget; 

     bloomCombineEffect.Parameters["BaseTexture"].SetValue(sceneRenderTarget); 

     Viewport viewport = GraphicsDevice.Viewport; 

     DrawFullscreenQuad(renderTarget1, 
          viewport.Width, viewport.Height, 
          bloomCombineEffect, 
          IntermediateBuffer.FinalResult); 

          System.Console.WriteLine("Draw Called"); 

    } 

전체 classes and shader code can be found here

+1

질문 자체에는 어떤 코드도 포함되어 있지 않으며 앞으로는 작동을 멈추게 할 수있는 외부 링크를 보지 않으면 응답 할 수 없으므로 Downvoted입니다. – SurvivalMachine

+0

확실한 형제, 몇 주 전에 누군가가 내 코드를 항상 외부 링크에 게시해야한다고 말했고 이제는 내 질문에 게시해야한다고 말했어 ... 나는 약간 엉망이되어 ... 여기에 게시 할 수 있습니다. 그러나 클래스 당 100-300 라인을 가진 약 7 개의 클래스가있을 것이고 아무도 그것을 보지 않을 것입니다. 그래서 도움을주고 자하는 사람들을 위해 외부 링크를 게시하는 것이 가장 좋은 방법입니다. – genaray

+1

글쎄, 링크가 아무것도없는 것보다 낫습니다. 질문에 코드를 게시하면 전체 프로젝트가 아니며 관련 부분 만있을 수 있습니다. – SurvivalMachine

답변

1

스프라이트 배치 렌더링은 bloom.BeginDrawbloom.Draw 사이 여야합니다.

bloom.BeginDrawsceneRenderTarget에 바인딩됩니다. 장면을 렌더링해야합니다. 이 방법으로 렌더링 된 데이터는 bloom.Draw에서 처리되는 추가 처리를 위해 액세스 할 수 있습니다.

+0

고마워, 너무 젠체하는! 너는 나의 영웅이야 !! 그것은 마침내 일한다!! :) 정말 고맙습니다 ! – genaray

관련 문제