Implementation instructions are in the files.
1. Magnifying glass:
Opens a magnifying window where mouse is or fixed position with different size and scale.
Code: Select all
* Settings:
*
* magnify_enable: Opens magnifying window.
* magnify_fixedwindow: Fix window position.
* magnify_fixedcursor: Fix cursor position.
* magnify_windowpos: window position.
* magnify_cursorpos: cursor position.
* magnify_windowsize: Size of the magnifying window in screen scale.
* magnify_Scale: Magnifying scale.
http://pastebin.com/raw/RTKzjtsu
Code: Select all
//sample usage:
// float4 filteredcolor = BicubicFilter(TextureColor, Sampler1, coord, float2(srcsize));
// **Sampler1 is linear sampler.
3. FPS History:
A debug UI hud/function to show FPS history.
Code: Select all
* Settings:
* Debug::FPS TimeScale (second): set history range (x axis)
* Debug::FPS LineWidth: set Line width.
4. 10bit-float3 packing/unpacking:
Use 2 16bit-floats to store 3 10bit-floats.
Code: Select all
//packing float3 into f16 x2
float2 pack10F(float3 v) {
uint3 u16 = f32tof16(abs(v));
//replace lower 5 bit.
u16.x = (u16.x & 0x7FE0) | (( u16.z & 0x7C00) >> 10); // .x: (bit10 e0) | (bit5 m0) | (bit0 e2)
u16.y = (u16.y & 0x7FE0) | (( u16.z & 0x03E0) >> 5 ); // .y: (bit10 e1) | (bit5 m1) | (bit0 m2)
return f16tof32(u16.xy);
}
// unpack 3 10bit floats from 2 16bit floats
float3 unpack10F(float2 v) {
uint3 u16;
u16.xy = f32tof16(abs(v));
u16.z = ((u16.x & 0x1F) << 10) | ((u16.y & 0x1F) << 5);
return max(0, f16tof32(u16 & 0x7FE0));
}
//sample usage:
// the first pass write to RGBA16F rendertarget.
float4 PS_pass0(float4 pos: SV_POSITION, float4 txcoord: TEXCOORD0) : SV_Target {
//negative val not supported.
float3 c = { 0.1, 0.22, 0.333};
float3 w = {10.6, 1.22, 0.003};
return float4( pack10F(c), pack10F(w));
}
// second pass retrieve data from RGBA16F texture
float4 PS_pass1(float4 pos: SV_POSITION, float4 txcoord: TEXCOORD0) : SV_Target {
// WARNING!
// Interpolation will disrupt the retrieved data.
// Use point sampler or texObj.Load() only.
float4 data = TexRGBA16F.Sample(samplerPoint, txcoord.xy);
float3 c = unpack10F(data.xy);
float3 w = unpack10F(data.zw);
return c * w;
}