Some simple XNA/HLSL questions

后端 未结 1 2225
无人共我
无人共我 2021-02-20 07:16

I\'ve been getting into HLSL programming lately and I\'m very curious as to HOW some of the things I\'m doing actually work.

For example, I\'ve got this very simple shad

1条回答
  •  旧巷少年郎
    2021-02-20 07:34

    mySampler is assgined to a sample register, the first is S0.

    SpriteBatch uses the same register to draw textures so you have initilized it before for sure.

    this register are in relation with GraphicDevice.Textures and GraphicDevice.SamplerStates arrays.

    In fact, in your shader you can use this sentence:

     sampler TextureSampler : register(s0);
    

    EDIT:

    if you need to use a second texture in your shader you can make this:

     HLSL
          sampler MaskTexture : register(s1);
    
     C#:
          GraphicsDevice.Textures[1] = MyMaskTexture;
          GraphicsDevice.SamplerStates[1].AddresU = TextureAddresMode....
    

    Color0 is not a registry and does not hold the current pixel color. It's referred to the vertex structure you are using.

    When you define a vertex like a VertexPositionColor, the vertex contains a Position, and a Color, but if you want to define a custom vertex with two colors, you need a way to discriminate between the two colors... the channels.

    The number suffix means the channel you are referring in the current vertex.

    0 讨论(0)
提交回复
热议问题