Robert Dunlop 的个人资料Robert Dunlop's Space照片日志列表更多 工具 帮助

日志


5月5日

Trig Identities

...and a nice collection of trigonometric identities to boot:
 

Integrated Metric Tensors

Finally, located an  article that clarifies Integrated Metric Tensors, as presented in the DX SDK under the UVAtlas documentation.  This clarifeis them a great deal:
 
 
I still need to read and digest that fully and see what sense I can make out of its use in UVAtlas and other possible applications....
4月17日

Detecting Range Intersection

There are only so many ways one coiuld code a test for the intersection of two ranges of values, yet there is one that I had forgotten about for some time.  Funny thing is, I knew I had forgotten it, I just couldn't remember what "it" was
 
The method I am referring to looks like this:
 
if ((aMax-bMin)*(bMax-aMin)>0) { // ranges intersect }
 
This tests to see if the direction from the start of each range to the end of the other are the same.  Intersecting ranges will lie in the same direction, and thus produce a positive result.
 
This test is nice because it only uses one conditional statement, rather than a minimum of two conditionals with other methods.  One thing I had not considered before, though, is that it could be a quick way to test axis aligned boxes in a shader.  For example:
 
float3 v1=vMaxA-vMinB;
float3 v2=vMaxB-vMinA;
if (all(saturate(v1*v2)) { // intersects }
 
I'm not sure what the best HLSL instructions to use are yet, I've tried compiling different versions of that conditional test (saturate vs max(v,(0,0,0,0) etc) for a vertex shader and there is about a 4 instruction slot range in shader size.
 
For pixel shaders there are a couple of additional instructions that could be utilized with this, namely the all (enumlated for vertex shaders in HLSL) and the clip instruction.
 
This could also be used for other tasks besides AA boxes - for example, with a matrix transformation, you could evaluate four pairs of parallel clipping planes at one time.