c # – How to access a texture inside a Vertex Shader. SharpDX 4.2

This is a continuation of the question found here:

vertex manipulation in shader instanced hlsl SHARPDX 4.2

Now that I've been able to change the vertex positions in a vertex shader via vertex links, I need to be able to undo unnecessary triangles / vertexes in the scene. To do this, I had several options:

Option 1: Create a ByteMap and send the data via a constant buffer inside a geometry shader. The ByteMap would not be composed of the same ByteMap that I send via the vertexShader. This would again consist of 0s and 1s, but each vertex WITHOUT the end of a block would be canceled in a Geometry shader, if that is even possible. I've tried this option and it failed because I do not know how to correctly send the byteMap through a constant buffer.

Option 2: Create a Texture1D and access Texture1D from VertexShader, then transfer the code into a Geometry shaometry if it works. I am currently trying this iteration but I am failing and I need help.

Here is what I've had so far:


                                                                                int totalWidth = SC_Globals.tinyChunkWidth * SC_Globals.tinyChunkHightight * SC_Globals.tinyChunkDepth * SC_Globals.numberFInstancesPerObjectInWidth * SC_Globals.numberO

Texture1DDescription desc = new Texture1DDescription ();
desc.Width = totalWidth;
desc.MipLevels = 1;
desc.ArraySize = 1;
desc.Format = Format.B8G8R8A8_UNorm;
desc.Usage = ResourceUsage.Default;
desc.BindFlags = BindFlags.ShaderResource;
desc.CpuAccessFlags = CpuAccessFlags.None;
desc.OptionFlags = ResourceOptionFlags.None;

int[] byteMap = chunkdat.arrayOfSomeMap.SelectMany (a => a) .ToArray ();
byte[] arrayOfBytes = new byte[byteMap.Length];

for (int i = 0; i <byteMap.Length; i ++)
arrayOfBytes[i] = (byte) byteMap[i];

int rowPitch = 4 * desc.Width;
DataStream dataStream = new DataStream (rowPitch, true, true);
dataStream.WriteRange (arrayOfBytes, 0, arrayOfBytes.Length);
DataBox data = new DataBox (dataStream.DataPointer, rowPitch, rowPitch);

DataBox[] arrayOfBoxes = new DataBox[1];
arrayOfBoxes[0] = data;

Texture1D mapTexture = new Texture1D (device, description, arrayOfBoxes);

textureView = new ShaderResourceView (device, mapTexture);

Inside the Vertex Shader, I use this:

        int x = input.indexPos.x;
int y = input.indexPos.y;
int z = input.indexPos.z;

int currentIndex = x + (tinyChunkWidth * (y + (tinyChunkHeight * z)));

int mainX = input.instancePosition1.x% 4;
int mainY = input.instancePosition1.y% 4;
int mainZ = input.instancePosition1.z% 4;

int indexMain = mainX + mapWidth * (mainY + mapHeight * mainZ);
int indexTotal = (indexMain * 64) + (currentIndex);

float colordata = mapTexture[indexTotal]; // does not work
float colordata = mapTexture.Load (indexTotal); // does not work

I do not know why I can not get colorData from the texture inside the VertexShader. Can someone help?

Thank you,

It does not work either:

These examples on the Microsoft website do not work either:

I code in SharpDX 4.2 but I try to get answers from everywhere. I've tried tex2Dlod and it does not work either. tex1Dlod either.