English 中文(简体)
我的Xna pixel shader为什么将这一案文变成蓝色?
原标题:Why doesnt my xna pixel shader turn this texture blue?
  • 时间:2011-11-15 00:56:21
  •  标签:
  • xna-4.0
  • hlsl

我有一个真正简单的子板:

float4 PixelShaderFunction(float2 uv : TEXCOORD0) : COLOR0
{
    return float4(0, 1, 0, 1);
}

technique Technique1
{
    pass Pass1
    {
        PixelShader = compile ps_3_0 PixelShaderFunction();
    }
}

I have a texture:

        Vector4[] textureData = new Vector4[width * height];
        for (int y = 0; y < height; y++)
        {
            for (int x = 0; x < width; x++)
            {
                textureData[y * width + x] = new Vector4(1, 0, 0, 1);
            }
        }
        myTexture = new Texture2D(GraphicsDevice, width, height, false, SurfaceFormat.Vector4);
        myTexture.SetData(textureData);

我引用这一法典:

        spriteBatch.Begin(SpriteSortMode.Texture,
                          BlendState.Additive,
                          SamplerState.PointWrap,
                          DepthStencilState.DepthRead,
                          RasterizerState.CullNone);

        myEffect.CurrentTechnique.Passes[0].Apply();
        spriteBatch.Draw(myTexture, new Rectangle(0, 0, width, height), Color.White);

        spriteBatch.End();

我本来会看到,通过在粉碎板上打上“Apply()”号,随后的间谍riteBatch.Draw()号电话本会通过我的粉碎机发出我的训ex。 由于粉碎机的功能始终如一地回归浮(0、1、0和1),我预计结果会成为一个绿色广场,但会带来红树,就像粉碎机没有触及它一样。

我失踪了什么?

最佳回答

象我这样认为,我刚刚需要把雕像从3版改为2版。

问题回答

您从来不实际地在座标上打上<条码>,因此,它将继续使用缺省字。

此外,现在还有更清洁的方法。 您可以把其作为参数的作用传到<条码>上:http://blogs.msdn.com/b/shawnhar/archive/04/05/spritebatch-and-custom-shaders-in-xna-Ga-studio-4-0.aspx” rel=“nofollow”上,详见





相关问题
Packing attributes in a texture, deferred rendering

I m rolling a deferred shader pipe, and due to the need to keep the G-buffers in a unified format a need to compress attributes is needed. I ve sadly been unable to find some good information on how ...

HLSL and ID3DXFont/ID3DXSprite

I ve started at the beginning, and my code will capably display the grand total of some text. I ve been adding support for sprites. The trouble that I ve run in to, is that it doesn t seem to ...

Using DirectX headers from Wine to compile under MingW

I have been attempting to build HLSL shader support into VLC player. I have hit a brick wall due to lack of utility methods in d3d9.h in MingW to load a .fx file and compile the shader. So under ...

DirectX Sphere Texture Coordinates

I have a sphere with per-vertex normals and I m trying to derive the texture coordinates for the object using the algorithm: U = Asin(Norm.X) / PI + 0.5 V = Asin(Norm.Y) / PI + 0.5 With a polka dot ...

Rendering a point light using 6 spot lights?

I m trying to render 6 spot lights to create a point light for a shadow mapping algorithm. I m not sure if I m doing this right, I ve more or less followed the instructions here when setting up my ...

HLSL DirectX9: Is there a getTime() function or similar?

I m currently working on a project using C++ and DirectX9 and I m looking into creating a light source which varies in colour as time goes on. I know C++ has a timeGetTime() function, but was ...

Fetching the vertices from the backbuffer (HLSL) on XNA

Hello and sorry for the obscure title :} I`ll try to explain the best i can. First of all, i am new to HLSL but i understand about the pipeline and stuff that are from the fairy world. What i`m ...

热门标签