Jump to content

  • Log In with Google      Sign In   
  • Create Account

How can I call the Geometry Shader twice?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 ~Helgon   Members   -  Reputation: 357

Like
0Likes
Like

Posted 01 December 2012 - 05:34 PM

Hi, I wan't to execute my GS dependent of the distance to the object. If the object is very close i want to execute the GS twice.

My thoughts (and the problems that occurs while trial and error) are that my maxvertexcount is 8. So i can't generate more points dependent of any variable/value what ever. But how can i call the GS then? I thought to call the GS out of the GS Method. I've tried something like that:

// inside the GeometryShader 
VertexOut t[3];
  t[0] = v[1];
  t[1] = v[2];
  t[2] = v[3];
  GS(t, stream);

but the error is: Fehler 5 error X3500: 'GS': recursive functions not allowed in gs_5_0 as already expected but at least I've tried it.

My GeometryShder looks like that at the moment.

Does someone has an idea how i can solve the problem?

[maxvertexcount(8)]
void GS(triangle VertexOut gin[3], inout TriangleStream<GeoOut> stream)
{
float distance;
ComputeDistance(gin[0], distance);
[branch]
if(distance < 15.0f)
{
   VertexOut v[6];
   Subdivide(gin, v);
   OutputSubdivision(v, stream);
}
else if(distance > 15.0f &amp;&amp; distance < 30.0f)
{
  // here i want to get double tessellation
  VertexOut v[6];
  Subdivide(gin, v);
  OutputSubdivision(v, stream);
}
else if(distance > 30.0f)
{
  GeoOut v[3];
  for(int i = 0; i < 3; ++i)
  {
   v[i].PosW = mul(float4(gin[i].PosL, 1.0f), gWorld).xyz;
   v[i].NormalW = mul(gin[i].NormalL, (float3x3)gWorldInvTranspose);
   v[i].PosH = mul(float4(gin[i].PosL, 1.0f), gWorldViewProj);
   v[i].Tex = mul(gin[i].Tex, (float3x3)gWorldInvTranspose);
   stream.Append(v[i]);
  }
}
}

Regards Helgon

Edited by ~Helgon, 01 December 2012 - 05:35 PM.

from time to time i find time


Sponsor:

#2 MJP   Moderators   -  Reputation: 11446

Like
0Likes
Like

Posted 01 December 2012 - 06:40 PM

Why aren't you just doing this using the tessellation shaders?

#3 ~Helgon   Members   -  Reputation: 357

Like
0Likes
Like

Posted 01 December 2012 - 07:57 PM

It's the next chapter of the book and this exercise should be solved without it :P

from time to time i find time


#4 Bacterius   Crossbones+   -  Reputation: 8945

Like
0Likes
Like

Posted 02 December 2012 - 04:54 AM

How about just setting the maximum vertex count higher? It's a maximum, you don't need to output that many (I think). In any case, a geometry shader which outputs a variable number of vertices is going to be horribly inefficient anyway, so at this point I think it would be OK to do it like that. But if you can compute which geometry shader should be used from the CPU side, you should have multiple shaders and select the right one before starting the frame.

The slowsort algorithm is a perfect illustration of the multiply and surrender paradigm, which is perhaps the single most important paradigm in the development of reluctant algorithms. The basic multiply and surrender strategy consists in replacing the problem at hand by two or more subproblems, each slightly simpler than the original, and continue multiplying subproblems and subsubproblems recursively in this fashion as long as possible. At some point the subproblems will all become so simple that their solution can no longer be postponed, and we will have to surrender. Experience shows that, in most cases, by the time this point is reached the total work will be substantially higher than what could have been wasted by a more direct approach.

 

- Pessimal Algorithms and Simplexity Analysis


#5 ~Helgon   Members   -  Reputation: 357

Like
0Likes
Like

Posted 02 December 2012 - 07:06 AM

Yeah, I've also realized a little bit after posting that's a max and not exact count Posted Image

from time to time i find time





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS