I was working on this idea of drawing a rotating cone rotating on the y axis with a parametric equation, using a computeshadercompute shader with a function CS(SV_GroupID, uint3 nDTid like: SV_DispatchThreadID, SV_GroupThreadID).
CS(SV_GroupID, uint3 nDTid : SV_DispatchThreadID, SV_GroupThreadID).
To avoid multiple rendering, I was using a test on nDTidnDTid to draw only in a given nDTid.xynDTid.xy interval.
I
I found this tricky and finally I decided to use a Dispatch(1,1,1)Dispatch(1,1,1) and numthreads[1,1numthreads[1,1,1],1] which remove the requirement for the nDTidnDTid interval test and the cone is drawn only once.
What I have noticed is an eraticerratic framerate that I guess depends on the number of pixel drawn.
This becomes more an exerciceexercise than something applicable to my regular project, but is it of interest to limit DispatchDispatch and numthreadnumthread as I did with computeshaders and howcompute shaders? How can I reduce this eraticerratic framerate?
Below someis a code example and screenthe rendered result.
Preparing constant shaderPreparing constant shader
setting the computeshader.Setting the compute shader. Instead of progressing along the cone axis and drawdrawing a circle at each step, which required one transform /lightning lighting calculation per circle pixel drawn, I loop first for each pixel of the circle at the base and draw a line from top cone to this pixel. This requires only one transform /lightning lighting calculation per line drawn. It is not really efficient may I say, as top pixels can be drawn several times. This shader does not draw the base of the cone and did not z test-test. For some resonsreasons, the lightninglighting makes the cone reddish instead of going grey, which I have not solved yet.
screen shot Screen shot
An alternative solution is to use a geometry shader to output a triangle from the top to two successive pixel circlecircles.
