Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#ActualSquirrelPop

Posted 13 June 2012 - 12:48 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;

}


[attachment=9452:Awful.jpg]

#3SquirrelPop

Posted 13 June 2012 - 12:48 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:
[source lang="cpp"]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;}[/source]

[attachment=9452:Awful.jpg]

#2SquirrelPop

Posted 13 June 2012 - 12:46 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:
[source lang="cpp"]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;}[/source]

[attachment=9452:Awful.jpg]

#1SquirrelPop

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:[attachment=9452:Awful.jpg]
[source lang="cpp"]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;}[/source]

PARTNERS