Jump to content

  • Log In with Google      Sign In   
  • Create Account

Ray Tracing using D3DXIntersect?


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
5 replies to this topic

#1 Tispe   Members   -  Reputation: 1046

Like
0Likes
Like

Posted 21 October 2012 - 02:29 AM

Greetings

I am wondering if excessive use of the D3DXIntersect function will put a lot of strain on the CPU. I plan to use this or something like it in a project where in each frame I use this for each pixel. Since calling D3DXIntersect several million times per frame per mesh might not be such a smart thing to do, are there any other ways to implement this, like in HLSL?

This is not exactly ray tracing an image as the topic may suggest, but rather using "ray tracing" ontop of rasterizing to achieve effects ingame.

Cheers

Sponsor:

#2 Tom KQT   Members   -  Reputation: 1621

Like
0Likes
Like

Posted 21 October 2012 - 03:17 AM

If I remember correctly, D3DXIntersect is quite slow. Certainly not fast enough to be called many times per frame.
When I used a similar functionality of the havok physics engine, I got almost uncomparably better speed.

#3 Adam_42   Crossbones+   -  Reputation: 2619

Like
0Likes
Like

Posted 21 October 2012 - 06:01 AM

If you want to do it on the GPU you could use MRT to output an identifier saying which model you're rendering to a second render target. The depth buffer will ensure each pixel holds the correct result after rendering. You can than use that render target as input to another shader to process the results.

Depending on exactly what you want to do you may find that you'll need to use DirectX 10/11 functionality to achieve it. However even on DX9 simply reading back that extra render target on the CPU (which isn't very efficient) will still be much quicker than doing all those D3DXIntersect calls.

#4 Tispe   Members   -  Reputation: 1046

Like
0Likes
Like

Posted 21 October 2012 - 06:23 AM

Is it possible to use some sort of D3DXIntersect implementation in the Pixel Shader? As in accessing vertex/index buffers and check if a ray is intersecting the mesh?

#5 Tispe   Members   -  Reputation: 1046

Like
0Likes
Like

Posted 21 October 2012 - 08:51 AM

I am thinking that I might be able to implement D3DXIntersectTri in the Pixel Shader.

I will need to get the three vertices making up the face into the Pixel Shader, uninterpolated. Is that possible without hardcoding it in the vertex declaration?

#6 Gavin Williams   Members   -  Reputation: 776

Like
0Likes
Like

Posted 24 October 2012 - 05:41 AM

What your talking about is out of my depth so I can't directly help you, but doesn't DX11 have a way to identify primitives at least in some parts of the pipeline. If you have the primitive values stored for an object (stored into some textures for instance) you might be able to index into those to get your triangle vertices. That would involve duplication of your model data, but depending upon what you need it could work.

You could read up on the Geometry Shader which operates on complete primitives, including adjacent primitives. But again, I can hardly help you or explain it further, I've never used the Geometry Shader.




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