Jump to content
  • Advertisement
Sign in to follow this  
Shnoutz

Geometry shader wont compile...

This topic is 2287 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am building a marching cube geometry shader but it does not compile... Can someone verify my shader?


[maxvertexcount(15)]
void gs_main(point Cluster cluster[1], inout TriangleStream < Pixel > pixels)
{
// Determine cube index
int cubeIndex = 0;
for(int i = 0; i < 8; ++i)
if(cluster[0].densities <= 0.5f)
cubeIndex |= (1 << i);

// Get intersecting edges
uint cubeEdge = bufEdgeTable[cubeIndex];
if(cubeEdge)
{
// Iterators
uint i, j;

// Gather edges
uint edgeCount = 0;
uint edges[12][2];
for(i = 0; i < 12; ++i)
{
if(cubeEdge & (1 << i))
{
edges[edgeCount][0] = bufVertexTable[i * 2 + 0];
edges[edgeCount][1] = bufVertexTable[i * 2 + 1];
++edgeCount;
}
}

// Gather triangle indices
uint triangleCount = 0;
uint triangles[5][3];
for(i = 0; bufTriangleTable[cubeIndex * 16 + i] != -1; i += 3)
{
triangles[triangleCount][0] = bufTriangleTable[cubeIndex * 16 + i + 0];
triangles[triangleCount][1] = bufTriangleTable[cubeIndex * 16 + i + 1];
triangles[triangleCount][2] = bufTriangleTable[cubeIndex * 16 + i + 2];
++triangleCount;
}

float4 positions[12];

for(i = 0; i < edgeCount; ++i)
{
float theta = (0.5f - cluster[0].densities[edges[0]]) / (cluster[0].densities[edges[1]] - cluster[0].densities[edges[0]]);
positions = lerp(cluster[0].corners[edges[0]], cluster[0].corners[edges[1]], theta);
}

for(i = 0; i < triangleCount; ++i)
{
for(j = 0; j < 3; ++j)
{
Pixel pixel;
pixel.hposition = mul(matViewProjection, positions[triangles[j]]);
pixel.density = 1.0f;
pixels.Append(pixel);
}
pixels.RestartStrip();
}
}
}


This is the error I get:

[color=#444444]error X4580: emitting a system-interpreted value which is not written in every execution path of the shader

Clearly there is something wrong here...

Share this post


Link to post
Share on other sites
Advertisement
Hmm I'm not familiar with geometry shaders, but the error sounds a lot like what you get if you've not assigned a value to an out parameter in every possible execution path.
eg, your pixels parameter

Share this post


Link to post
Share on other sites
This is how I defined "Pixel":


struct Pixel
{
float4 hposition : SV_POSITION;
float density : DENSITY;
}


I was able to shuffle some code and get the shader to compile... But things that should work do not work...

this works :



uint edgeCount = 0;
for(i = 0; i < 12; ++i)
{
if(cubeEdge & (1 << i))
{
positions[edgeCount] = ...
}
++edgeCount;
}


while this does not :



for(i = 0; i < 12; ++i)
{
if(cubeEdge & (1 << i))
{
positions = ...
}
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!