c # – manipulation of vertex in shader instanced hlsl SHARPDX 4.2

I'm using the same vertex shader and pixel shader for my instances. I send a ONE FLAT array containing all the instantiated block bytes that make up the terrain of the Minecraft cube. My goal is to make a phone call … nothing works. I am able to use an entry element that has the vertex-specific index stored in memory so that all vertex instances share the same index. It should be very easy after that to extract the 0 or 1 byte inside the array of flat blocks that contains all the data.

It should work. The indexes of the vertices are perfect. The indexes of instanced pieces are perfect …

What is the h *** not working? There is the impression that something is wrong in the matrix, because the bytes of songs are randomly restored on the screen of my computer. All I see is wrong. I filled all my structures to send to the shader and correctly filled the InputElements … ??? I've tried sending a dice array instead … Each matrix M11 through M44 contains the byte index and I send it as a table to the shader and BAM … nothing always works … doing it on the processor would be completely fine as I have already done a thousand times. I've been a hermit in front of my computer for days / weeks / months coding a dumb pitch and this would be my best for now. But it does not work.

Whether you are a hermit like me or not, help me please. TO ALL HERMITS encodings or not of this world. Please help

enter the description of the image here

add MatrixBuffer: register (b0)
{
float4x4 world;
view float4x4;
float4x4 proj;
};

cbuffer inData: register (b1)
{
int chunkMap[4096];
}

struct VertexInputType
{
position float4: POSITION;
float4 indexPos: POSITION1;
float4 instancePosition1: INSTANCEPOSITION1;
};

struct PixelInputType
{
position float4: SV_POSITION;
float4 color: COLOR;
};

float planeSize = 1;

static int mapWidth = 4;
static int mapHeight = 4;
static int mapDepth = 4;

static int tinyChunkWidth = 4;
static int tinyChunkHeight = 4;
static int tinyChunkDepth = 4;

IsTransparent bool (int xMain, int yMain, int zMain, x int, int y, int z)
{
int indexMain = xMain + mapWidth * (yMain + mapHeight * zMain);
int indexSec = x + tinyChunkWidth * (y + tinyChunkHeight * z);

if ((x <0) || (y <0) || (z < 0) || (x >= tinyChunkWidth) || (y> = tinyChunkHeight) || (z> = tinyChunkDepth)) returns true;
{
return chunkMap[(indexMain * 64) + indexSec] == 0;
}
}
PixelInputType TextureVertexShader (VertexInputType input)
{
PixelInputType output;

input.position.w = 1.0f;

int xMain = 0;
int yMain = 0;
int zMain = 0;



xMain = round (fmod ((input.instancePosition1.x * 10), mapWidth * tinyChunkWidth));
yMain = round (fmod ((input.instancePosition1.y * 10), mapHeight * tinyChunkHeight));
zMain = round (fmod ((input.instancePosition1.z * 10), mapDepth * tinyChunkDepth));

xMain = round (xMain / mapWidth);
yMain = round (yMain / mapHeight);
zMain = round (zMain / mapDepth);


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

int indexMain = xMain + mapWidth * (yMain + mapHeight * zMain);

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

int currentByte = chunkMap[(indexMain * 64) + indexSec];

input.position.x + = input.instancePosition1.x;
input.position.y + = input.instancePosition1.y;
input.position.z + = input.instancePosition1.z;

output.position = mul (input.position, world);
output.position = mul (output.position, view);
output.position = mul (output.position, proj);

if (currentByte == 1)
{
output color = float4 (0,1,0,1);
return the exit;
}
other
{

output color = float4 (0,0,1,1);
return the exit;
}
}

Who said I was a coding hermit? Shut up.

This is my current result. And it does not make sense and I do not understand why …

enter the description of the image here

Seriously. What is going on. I'm sending a simple array to the GPU. Whatever padding I put, it should not really matter because there is only one element in the buffer structure. Is the GPU pipeline causing problems? Is it because the GPU randomly places data in the table, which makes no sense if it is? It is IMPOSSIBLE that the problem comes from my index of each vertex because I configure them BEFORE starting rendering, they are configured as a Vector4 input element with x, y, where z is the index position of the byte.

Or what I try is impossible? This should not be unless it is related to some great things the GPU does when instantiating objects. Or I'm just blind and I do not know what the f *** im coding.