Friday, April 29, 2011

Global Illumination Research

Lionhead Studio's GI System

http://www.gdcvault.com/play/1014350/Mega-Meshes-Modeling-Rendering-and

The technique here is similar to Bunnell's but the presentation is a bit confusing even though the idea is simple.

Offline Stage
  
       1) Generate lighting probes. Light probes are generated for the surface of static objects and for irradiance volume sample points for dynamic objects. A light probe just stores the set of "surface probes" that it can see which is calculated via raycasts.

       2) Generate surface probes. Random points on geometry, then optimized.

       3) Compute visibility. This is where the set of surface points visible to each light probe is computed.

       4) Create SH vector palette.



Online Stage

      1) Calculate direct illumination for surface probes.

      2) Propagate lighting to lighting probes.

----------------------------------------------------

Geomerics Enlighten

http://www.geomerics.com/downloads/radiosity_architecture.pdf

DirectX 11 Tessellation Notes

Good tutorial and introduction to programming the DirectX11 tessellator

http://www.geeks3d.com/20101126/direct3d-11-tessellation-tutorial/



Hull Shader Stage

This stage is divided into two parts, ConstantHS and MainHS.

ConstantHS is invoked once per primitive and it's function is to output the Tessellation Factor.

MainHS is invoked per control point and it's purpose is to calculate any basis change on the primitive.





Tessellator Unit

Tessellator outputs up to 8192 triangles per input patch. The exact triangle amount is passed as a parameter.

This stage creates new triangles that compose a regular grid with texture coordinates ranging from 0 to 1.

Tessellation can be achieved in 3 different ways: integer, even-fractional, odd-fractional. Integer is a straightforward symmetric subdivision. The fractional versions subdivide the edges and interpolate between different lod levels for a smoother transition.




Domain Shader Stage

The domain shader is invoked once per vertex output from the tessellator and it's role is to compute the parametric position based on the control points from the hull shader. This is also where displacement maps would be applied.

Thursday, April 28, 2011

DirectX 11 Overview Notes

A paper on the DirectX10 design decisions and the rationale for those decisions
http://download.microsoft.com/download/f/2/d/f2d5ee2c-b7ba-4cd0-9686-b6508b5479a1/direct3d10_web.pdf


Details on Migrating from D3D9 to D3D11
http://msdn.microsoft.com/en-us/library/ff476190.aspx


Good General Overview of the Direct3D11 Systems
http://developer.download.nvidia.com/presentations/2008/NVISION/NVISION08_Direct3D_11_Overview.pdf


DirectX11 is not supported on Windows XP. This forum explains why:
http://www.gamedev.net/topic/552391-having-support-for-dx9--dx10--dx11/


Resources for Porting DirectX9 to DirectX11
http://developer.amd.com/assets/Riguer-DX10_tips_and_tricks_for_print.pdf

http://developer.amd.com/documentation/articles/pages/7112007172.aspx

http://msdn.microsoft.com/en-us/library/bb205073%28v=vs.85%29.aspx






New Features

Shader Model 5
Compute Shader
Dynamic Shader Linkage
Multi-threading - multi-threaded resource creation and command buffer creation
Tesselation




Computer Shader - New Resource Types

Shader Model 5 introduces a new set of read/write resources.

RWBuffer
RWTexture1D, RWTexture1DArray
RWTexture2D, RWTexture2DArray
RWTexture3D

These resources require a resource variable to access memory as there are no methods for accessing memory directly.

Structured Buffers

Structured buffers are arrays of structures defined by the user.

StructuredBuffer
RWStructuredBuffer

Atomic Functions which implement interlocked operations are allowed on int and uint elements of RWStructuredBuffer.



Byte Address Buffer

ByteAddressBuffer
RWByteAddressBuffer

Are buffers addressed by 4-byte aligned byte offsets.


Unordered Access Buffer or Texture

An unordered access resource (which includes buffers, textures and texture arrays - without multisampling) allows temporally unordered read/write access from multiple threads. Conflicts are avoided using atomic functions.

Use the D3D11_BIND_UNORDERED_ACCESS flag from D3D11_BIND_FLAG when creating buffers or texture2D resources.

These resources can only be bound to pixel and compute shaders.


Append and Consume Buffer

These buffers provide a queue like functionality where the append buffer is the input and the consume is the output.

AppendStructuredBuffer
ConsumeStructuredBuffer



Atomic Functions

Atomic functions are used to access the new resources types and shared memory from compute shaders.



Compute shaders are created with the new ID3D11Device::CreateComputeShader function call.



Direct3D 11 Devices

Device can be run in immediate or deferred mode. Deferred mode is only needed for multi-threaded applications.



Direct3D 11 Resources

D3D11 introduces a more generalized model of resources. Resources represent memory accessors/views of various types. They can be specified as typed, typeless, read, write, read/write, CPU, GPU, CPU/GPU. Up to 128 resources can be addressed by each pipeline stage at any time.

Typeless resources don't specify a specific type (eg: int, sint, float, srgb) but they do specify the number of bits allocated to each color component.

Resource Views are used to interpret typeless resources as a particular type. Conceptually, they are similar to casting (interpreting) a memory address in C/C++. The resource view must have the same allocation of bits to each color component as the typeless resource (eg: a R8G8B8A8 resource view can only be used for R8G8B8A8 typeless resources).

A resource view also exposes capabilities like reading back depth/stencil surfaces in a shader, rendering a dynamic cube map in a single pass and rendering simultaneously to multiple slices in a volume texture.

ID3D11DepthStencilView Access a texture resource during depth-stencil testing.
ID3D11RenderTargetView Access a texture resource that is used as a render-target.
ID3D11ShaderResourceView Access a shader resource such as a constant buffer, a texture buffer, a texture or a sampler.
ID3D11UnorderedAccessView Access an unordered resource using a pixel shader or a compute shader.



Subresources

Subresources are used to represent individual pieces of a resource. For example, the mip levels of a texture are all subresources that can be addressed in shaders.

Subresources are addressed by MipSlice, ArraySlice (index into array of textures), MipLevel. A specialized function is provided to calculate the 1D subresource index from these values: D3D11CalcSubresource().

MipSlice + (ArraySlice * MipLevels)




Buffers in Direct3D11

A buffer resource is a collection of fully typed data grouped into elements. You can use buffers to store a wide variety of data, including position vectors, normal vectors, texture coordinates in a vertex buffer, indexes in an index buffer, or device state. A buffer element is made up of 1 to 4 components. Buffer elements can include packed data values (like R8G8B8A8 surface values), single 8-bit integers, or four 32-bit floating point values.

A buffer is created as an unstructured resource. Because it is unstructured, a buffer cannot contain any mipmap levels, it cannot get filtered when read, and it cannot be multisampled.


Buffer types:

Vertex and Index buffers are like their D3D9 counterparts. The Constant Buffer is used to supply shader constants to shaders.

To read a shader-constant buffer from a shader, use the load HLSL intrinsic function. Each shader stage allows up to 15 shader-constant buffers; each buffer can hold up to 4096 constants.





Direct3D 11 Graphics Pipeline

The pipeline progresses in this order:

1) Input Assembler Stage
2) Vertex Shader
3) Hull Shader
4) Tesselator
5) Domain Shader
6) Geometry Shader
7) Stream Output Stage
8) Rasterizer Stage
9) Pixel Shader
10) Output Merger Stage

Notice that Compute Shader is not a part of the rendering pipeline but is a general purpose shading stage.



Compute Shader

This presentation gives a good overview of what Compute Shaders are and what they can do. Like SPUs they provide more general purpose multi-threaded programming but they are more restricted than SPUs.

http://s08.idav.ucdavis.edu/boyd-dx11-compute-shader.pdf



Tesselation Overview

Hull Shader - produces output control points and patch constants.

The hull shader is invoked once per patch.

The hull shader is basically responsible for determining how much to tessellate and passes tessellation factors (amount to tessellate) and tessellator mode declarations to the tessellator. It passes patch control points after basic conversion to the domain shader.  The tessellator does not see or use the control points.


Tessellator Stage - fixed function pipeline that subdivides a domain (quad, tri or line) into smaller objects (triangles, points or lines). The dimension and use of these control points is determined by the user.

The tessellator outputs the topology to the primitive assembly and U, V, {W} domain points to the domain shader.


Domain-Shader Stage - programmable stage that calculates the vertex position of a subdivided point in the patch.

The domain shader is invoked for each point from the tessellator and takes the control points, tessellation factors and U V {W} domain points to output a single vertex.

The domain shader is where displacement mapping occurs and where the patch smoothing operation is applied.




Tutorial on Direct3D11 Tessellation
http://www.geeks3d.com/20101126/direct3d-11-tessellation-tutorial/



New Texture Compression Formats


BC6 (aka BC6H)

- High dynamic range
- 6:1 compression (16 bpc RGB)
- Targeting high (not lossless) visual quality


BC7

- LDR with alpha
- 3:1 compression for RGB, 4:1 for RGBA
- High visual quality


New block compression methods

Specifications here:

http://www.opengl.org/registry/specs/ARB/texture_compression_bptc.txt



Direct3D 11 Reference

A blog detailing the development of a DirectX11 based engine, Hieroglyph 3
http://www.gamedev.net/blog/411-chronicles-of-the-hieroglyph/

The D3D11 stuff starts here http://www.gamedev.net/blog/411-chronicles-of-the-hieroglyph/page__st__88