14.12.2012 Views

Direct3D HLSL Programming using RenderMonkey IDE

Direct3D HLSL Programming using RenderMonkey IDE

Direct3D HLSL Programming using RenderMonkey IDE

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Generate Better PS_1_x Code<br />

Through Good <strong>HLSL</strong> Use<br />

• Signed Scale (_bx2)<br />

value * 2 - 1<br />

generates _bx2 modifier on the source register<br />

• Times 2, 4, 8, Divide by 2, 4, 8<br />

1. Source register modifiers: for n = 2, 4, 8, 0.5, 0.25, 0.125,<br />

multiplying the source value by n will generate the modifier.<br />

Example: return Value*2 generates _x2 modifier on the source reg.<br />

2. Destination modifiers:<br />

– for X = 2, 4, 8, 0.5, 0.25, 0.125, declare<br />

– Use that variable to generate a destination modifier:<br />

static const float N = 2;<br />

float4 f=(Value1+Value2)*N;<br />

static const float N = X;<br />

Example: generates<br />

Game Developer Conference, San Jose, CA, March 7 th 2003<br />

add_x2 r0,v0, v1

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!