Quantcast
Channel: Community | MonoGame - Latest topics
Viewing all articles
Browse latest Browse all 6821

Effect - setting parameters

$
0
0

@gotji wrote:

I’m moving my tile map drawing from SpriteBatch to VertexBuffer method. I’ve decided to write my own FX to refresh my memory(I have experience from XNA). First I encountered problems with setting parameters from code:

// CS class
this._dungeonShader.Parameters["tileDataTexture"].SetValue(this._tileDataTexture);
this._dungeonShader.Parameters["tilePaletteTexture"].SetValue(this._tileDataTexture);
…
// FX file
Texture2D tileDataTexture;
Texture2D tilePaletteTexture;
sampler s_tileData = sampler_state {
    Texture = <tileDataTexture >;
};
sampler s_tilePalette = sampler_state {
    Texture = <tilePaletteTexture>;
};

Result was very strange and both samplers were returning wrong values. Furthermore samplers result depended on the order of texture declaration and when I changed it to:

//Texture2D tileDataTexture;
//Texture2D tilePaletteTexture;
Texture2D tilePaletteTexture;
Texture2D tileDataTexture;

I’ve received different result. After changing my game code to:

/*this._dungeonShader.Parameters["tileDataTexture"].SetValue(this._tileDataTexture);
this._dungeonShader.Parameters["tilePaletteTexture"].SetValue(this._tileDataTexture);*/
this._graphicsDevice.Textures[0] = this._tileDataTexture;
this._graphicsDevice.Textures[1] = this._paletteTexture;

it worked as it should.

Now I’m trying to define SamplerState.PointClamp in FX file:

SamplerState Sampler {
    MipFilter = POINT;
    MinFilter = POINT;
    MagFilter = POINT;
    AddressU = Clamp;
    AddressV = Clamp;
    AddressW = Clamp;
    MaxMipLevel = 0;
};

Again without success and again when I used directly GraphicsDevice it worked:

this._graphicsDevice.SamplerStates[0] = SamplerState.PointClamp;

This is my first HLSL experience after several years but I don’t remember that I had such a problems with XNA. Can someone tell me what am I doing wrong? Or maybe this is bug?

Posts: 4

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 6821

Trending Articles