Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17825

Sampler not working outside pixelshader

$
0
0
Hello, I am, like many others before me, making a displacement map tesselator. I want render some terrain using a quad, a texture containing heightdata and the geometryshader/tesselator. So far, Ive managed the utilize the texture on the pixelshader (I return different colors depending on the height). I have also managed to tesselate my surface, i.e. subdivided my quad into lots of triangles . What doesnt work however is the sampling step on the domain shader. I want to offset the vertices using the heightmap. I tried calling the same function "textureMap.Sample(textureSampler, texcoord)" as on the pixelshader but got compiling errors. Instead I am now using the "SampleLevel" function to use the 0 mipmap version of the input texture. But yeah non of this seem to be working. I wont get anything except [0, 0, 0, 0] from my sampler. Below is some code: The working pixelshader, the broken domain shader where I want to sample, and the instanciations of the samplerstates on the CPU side. Been stuck on this for a while! Any help would be much appreciated! Texture2D textureMap: register(t0); SamplerState textureSampler : register(s0); //Pixel shader float4 PS(PS_IN input) : SV_TARGET { float4 textureColor = textureMap.Sample(textureSampler, input.texcoord); return textureColor; } GS_IN DS(HS_CONSTANT_DATA input, float3 uvwCoord : SV_DomainLocation, const OutputPatch<DS_IN, 3> patch) { GS_IN output; float2 texcoord = uvwCoord.x * patch[0].texcoord.xy + uvwCoord.y * patch[1].texcoord.xy + uvwCoord.z * patch[2].texcoord.xy; float4 textureColor = textureMap.SampleLevel(textureSampler, texcoord.xy, 0); //fill and return output.... } //Sampler SharpDX.Direct3D11.SamplerStateDescription samplerDescription; samplerDescription = SharpDX.Direct3D11.SamplerStateDescription.Default(); samplerDescription.Filter = SharpDX.Direct3D11.Filter.MinMagMipLinear; samplerDescription.AddressU = SharpDX.Direct3D11.TextureAddressMode.Wrap; samplerDescription.AddressV = SharpDX.Direct3D11.TextureAddressMode.Wrap; this.samplerStateTextures = new SharpDX.Direct3D11.SamplerState(d3dDevice, samplerDescription); d3dDeviceContext.PixelShader.SetSampler(0, samplerStateTextures); d3dDeviceContext.VertexShader.SetSampler(0, samplerStateTextures); d3dDeviceContext.HullShader.SetSampler(0, samplerStateTextures); d3dDeviceContext.DomainShader.SetSampler(0, samplerStateTextures); d3dDeviceContext.GeometryShader.SetSampler(0, samplerStateTextures);

Viewing all articles
Browse latest Browse all 17825

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>