私は次のような問題があります。ShaderはMonogameで動作しません(シェーダがないと見えます)| C#
私は自分のゲームで素晴らしい花の効果をしたいです。しかし、私は私のシェーダとshader.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);
}
は、これは私のブルームクラスの呼び出されるメソッドの抜粋です。
右シェーダなしで、シェーダで左/// <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
質問自体にはコードが含まれておらず、今後の作業を中止できる外部リンクを表示しなければ回答が不可能なため、下落しました。 – SurvivalMachine
確かに、数週間前に誰かが私のコードをいつも外部のリンクに投稿すべきだと言いましたが、私はあなたに私の質問にそれを投稿すべきだと言いました...私はちょっと倒れました...私はここに投稿できましたクラスあたり約100〜300行のクラスが7つあり、誰もそれを見ないでしょう。したがって、本当に助けたい人のための外部リンクを投稿するのが最良の選択です。 – genaray
リンクは何もないよりも優れています。質問にコードを投稿すると、それはプロジェクト全体ではなく、関連する部分だけです。 – SurvivalMachine