Monogame und CustomShaders
-
hi,
hoffe das der richtige Forumteil...
Ich würd gern eigene Shader verwenden...
Allerdings bleibt es schwarz wo die Textur zu sein sollte.texture = Content.Load<Texture2D>("test"); effect = Content.Load<Effect>("plain.mgfxo");
spriteBatch.Begin(SpriteSortMode.Immediate,BlendState.AlphaBlend,SamplerState.LinearClamp, DepthStencilState.Default ,RasterizerState.CullNone, effect); spriteBatch.Draw(texture, new Rectangle(0, 0, 543, 414), Color.White); spriteBatch.End();
Die plain.fx Datei :
//------------------------------ TEXTURE PROPERTIES ---------------------------- // This is the texture that SpriteBatch will try to set before drawing texture ScreenTexture; // Our sampler for the texture, which is just going to be pretty simple sampler TextureSampler = sampler_state { Texture = <ScreenTexture>; }; //------------------------ PIXEL SHADER ---------------------------------------- // This pixel shader will simply look up the color of the texture at the // requested point float4 PixelShaderFunction(float2 TextureCoordinate : TEXCOORD0) : COLOR0 { float4 color = tex2D(TextureSampler, TextureCoordinate); float value = (color.r + color.g + color.b) / 3; color.r = value; color.g = value; color.b = value; return color; } //-------------------------- TECHNIQUES ---------------------------------------- // This technique is pretty simple - only one pass, and only a pixel shader technique Plain { pass Pass1 { PixelShader = compile ps_5_0 PixelShaderFunction(); } }
Disassembly aus RenderDoc:
Shader hash 23ac371b-3a41a70e-bd3c8758-13c026a5 ps_5_0 dcl_globalFlags refactoringAllowed dcl_sampler s0, mode_default dcl_resource_texture2d (float,float,float,float) t0 dcl_input_ps linear v0.xy dcl_output o0.xyzw dcl_temps 1 0: sample_indexable(texture2d)(float,float,float,float) r0.xyzw, v0.xyxx, texture0.xyzw, sampler0 1: add r0.x, r0.y, r0.x 2: add r0.x, r0.z, r0.x 3: mov o0.w, r0.w 4: mul o0.xyz, r0.xxxx, l(0.333333, 0.333333, 0.333333, 0.000000) 5: ret
Convertiert hab ichs mit : 2MGFX.exe plain.fx plain.mgfxo /DX11
Bin da noch recht neu, erst gestern mit monogame angefangen^^ vllt hat da jemand ne idee?
-
Nutze : Visual Studio 2013,C#,Windows 7,Monogame/Xna,Directx