Jump to content

View more

Image of the Day

The night is still, but the invasion brings chaos. #screenshotsaturday #hanako #indiegame #gameart #ue4 #samurai https://t.co/cgILXuokoS
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Interpolating data using sampling in a pixel shader

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
4 replies to this topic

#1 SquirrelPop   Members   

117
Like
0Likes
Like

Posted 13 June 2012 - 12:45 PM

I'm sending a array of data to the GPU (as a 1D texture) that I sample in my pixel shader. I use the data to draw a figure onto a quad in the PS. Everything's kosher until I zoom in. After getting very close, my figure is highly aliased with large stair-steps, even though I believe my sampler's filtering is set up correctly.
What part of the equation am I missing here? I appreciate the suggestions! The following code is SharpDX, but the important parts should be easy to read.
[source lang="csharp"] Texture1DDescription textureDesc = new Texture1DDescription(); t1dDesc.ArraySize = 1; t1dDesc.Usage = ResourceUsage.Immutable; t1dDesc.Width = dataArray.Length; t1dDesc.Format = Format.R32_Float; t1dDesc.BindFlags = BindFlags.ShaderResource; t1dDesc.CpuAccessFlags = CpuAccessFlags.None; t1dDesc.OptionFlags = ResourceOptionFlags.None; t1dDesc.MipLevels = 1; DataStream ds = DataStream.Create(dataArray, false, false, false); dataTexture = new Texture1D(d3dDevice, textureDesc, ds); ds.Dispose(); this.dataTextureView = new ShaderResourceView(d3dDevice, dataTexture); this.dataSampler = new SamplerState(d3dDevice, new SamplerStateDescription() { Filter = Filter.MinMagMipLinear, AddressU = TextureAddressMode.Clamp, AddressV = TextureAddressMode.Clamp, AddressW = TextureAddressMode.Clamp });[/source]

HLSL:

float4 PS(PixelShaderInput input) : SV_TARGET

{

	float4 color =  float4(0,0,0,0);

	float dataValue = data.Sample(dataSampler, input.texcoord.x);

	if(input.texcoord.y <= dataValue)

	{

		  color = dataValue;

	}

  

	return color;

}


Awful.jpg

Edited by SquirrelPop, 13 June 2012 - 12:48 PM.


#2 Dawoodoz   Members   

459
Like
0Likes
Like

Posted 13 June 2012 - 03:06 PM

I would run the executable from PIX to see step by step where things go wrong. I would start by confirming that the texture contain what I expect.

"App". is an acronym and must always be followed by a dot.

https://en.oxforddictionaries.com/punctuation/punctuation-in-abbreviations


#3 xoofx   Members   

1101
Like
0Likes
Like

Posted 13 June 2012 - 09:09 PM

Keep in mind that SamplerStateDescription (like in C++) is not initialized, so you should probably better set min/max lod...

#4 SquirrelPop   Members   

117
Like
0Likes
Like

Posted 14 June 2012 - 10:20 AM

Keep in mind that SamplerStateDescription (like in C++) is not initialized, so you should probably better set min/max lod...


I cut out those values to make the code paste shorter, but I do have them in there.
ComparisonFunction = Comparison.Never,
			    MaximumAnisotropy = 16,
			    MipLodBias = 0,
			    MinimumLod = 0,
			    MaximumLod = 16


I didn't expect any difference, but I did try deleting them and I didn't see any effect, since I don't think those settings apply.

#5 SquirrelPop   Members   

117
Like
0Likes
Like

Posted 14 June 2012 - 10:22 AM

I would run the executable from PIX to see step by step where things go wrong. I would start by confirming that the texture contain what I expect.


I will give that a shot. Visual Studio 12 doesn't seem to be able to do any graphics debugging when DX is embedded in a Metro app, which is what I am doing. I'll give PIX a shot, but I'm not hopeful. I will probably need to extract this from the Metro container and just do a vanilla DirectX version in order to use the tools.

Thank you.




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.