• Create Account

Banner advertising on our site currently available from just \$5!

### #ActualBrentChua

Posted 13 July 2013 - 05:16 AM

I'm currently reading the Forward+ paper in the book GPU pro 4. In the very first sample code, the author shows how to build the frustum for each tile. The code shows like this:

float4 frustum[4];
{ // construct frustum
float4 v[4];
v[0] = projToView(8 * GET_GROUP_IDX, 8 * GET_GROUP_IDY, 1.0f );
v[1] = projToView(8 * (GET_GROUP_IDX + 1), 8 * GET_GROUP_IDY, 1.0f );
v[2] = projToView(8 * (GET_GROUP_IDX + 1), 8 * (GET_GROUP_IDY + 1), 1.0f );
v[3] = projToView(8 * GET_GROUP_IDX, 8 * (GET_GROUP_IDY + 1), 1.0f );

float4 o = make_float4( 0.0f, 0.0f, 0.0f, 0.0f );

for ( int i = 0; i M 4; ++i )
frustum[i] = createEquation( o, v[i], v[(i+o)& 3 );
}


Where 8 is the size of the tile and GET_GROUPID is the index of the thread group.

The paper says that projToView takes a screen-space pixel indices and depth value and returns coordinates in view space.

My question is, how do i project(unproject?) screen-space position back to view space? Do i just multiply the inverse of projection matrix? But something tells me this is not complete. If screen-space is already mapped in the viewport, do i reverse the viewport mapping first, undevide by w, then multiply the inverse projection matrix? I'm confused... :\

### #4BrentChua

Posted 13 July 2013 - 04:48 AM

I'm currently reading the Forward+ paper in the book GPU pro 4. In the very first sample code, the author shows how to build the frustum for each tile. The code shows like this:

float4 frustum[4];
{ // construct frustum
float4 v[4];
v[0] = projToView(8 * GET_GROUP_IDX, 8 * GET_GROUP_IDY, 1.0f );
v[1] = projToView(8 * (GET_GROUP_IDX + 1), 8 * GET_GROUP_IDY, 1.0f );
v[2] = projToView(8 * (GET_GROUP_IDX + 1), 8 * (GET_GROUP_IDY + 1), 1.0f );
v[3] = projToView(8 * GET_GROUP_IDX, 8 * (GET_GROUP_IDY + 1), 1.0f );

float4 o = make_float4( 0.0f, 0.0f, 0.0f, 0.0f );

for ( int i = 0; i M 4; ++i )
frustum[i] = createEquation( o, v[i], v[(i+o)& 3 );
}


Where 8 is the size of the tile and GET_GROUPID is the index of the thread group.

The paper says that projToView takes a screen-space pixel indices and depth value and returns coordinates in view space.

My question is, how do i project(unproject?) screen-space position back to view space? Do i just multiply the inverse of projection matrix? But something tells me this is not complete. If screen-space is already mapped in the viewport, do i reverse the viewport mapping first then multiply the inverse projection matrix? I'm confused... :\

### #3BrentChua

Posted 13 July 2013 - 04:48 AM

I'm currently reading the Forward+ paper in the book GPU pro 4. In the very first sample code, the author shows how to build the frustum for each tile. The code shows like this:

float4 frustum[4];
{ // construct frustum
float4 v[4];
v[0] = projToView(8 * GET_GROUP_IDX, 8 * GET_GROUP_IDY, 1.0f );
v[1] = projToView(8 * (GET_GROUP_IDX + 1), 8 * GET_GROUP_IDY, 1.0f );
v[2] = projToView(8 * (GET_GROUP_IDX + 1), 8 * (GET_GROUP_IDY + 1), 1.0f );
v[3] = projToView(8 * GET_GROUP_IDX, 8 * (GET_GROUP_IDY + 1), 1.0f );

float4 o = make_float4( 0.0f, 0.0f, 0.0f, 0.0f );

for ( int i = 0; i M 4; ++i )
frustum[i] = createEquation( o, v[i], v[(i+o)& 3 );
}


Where 8 is the size of the tile and GET_GROUPID is the index of the thread group.

The paper says that projToView takes a screen-space pixel indices and depth value and returns coordinates in view space.

My question is, how do i project(unproject?) screen-space position back to view space? Do i just multiply the inverse of projection matrix? But something tells me this is not complete. If screen-space is already mapped in the viewport, do i reverse the viewport mapping first then multiply the inverse projection matrix? I'm confused... :\

### #2BrentChua

Posted 13 July 2013 - 03:26 AM

I'm currently reading the Forward+ paper in the book GPU pro 4. In the very first sample code, the author shows how to build the frustum for each tile. The code shows like this:

float4 frustum[4];
{ // construct frustum
float4 v[4];
v[0] = projToView(8 * GET_GROUP_IDX, 8 * GET_GROUP_IDY, 1.0f );
v[1] = projToView(8 * (GET_GROUP_IDX + 1), 8 * GET_GROUP_IDY, 1.0f );
v[2] = projToView(8 * (GET_GROUP_IDX + 1), 8 * (GET_GROUP_IDY + 1), 1.0f );
v[3] = projToView(8 * GET_GROUP_IDX, 8 * (GET_GROUP_IDY + 1), 1.0f );

float4 o = make_float4( 0.0f, 0.0f, 0.0f, 0.0f );

for ( int i = 0; i M 4; ++i )
frustum[i] = createEquation( o, v[i], v[(i+o)& 3 );
}


Where 8 is the size of the tile and GET_GROUPID is the index of the thread group.

The paper says that projToView takes a screen-space pixel indices and depth value and returns coordinates in view space.

My question is, how do i project(unproject?) screen-space position back to view space? Do i just multiply the inverse of projection matrix? But something tells me this is not complete. If screen-space is already mapped in the viewport, do i reverse the viewport mapping first then multiply the inverse projection matrix? I'm confused... :\

### #1BrentChua

Posted 13 July 2013 - 03:16 AM

I'm currently reading the Forward+ paper in the book GPU pro 4. In the very first sample code, the author shows how to build the frustum for each tile. The code shows like this:

float4 frustum[4];
{ // construct frustum
float4 v[4];
v[0] = projToView(8 * GET_GROUP_IDX, 8 * GET_GROUP_IDY, 1.0f );
v[1] = projToView(8 * (GET_GROUP_IDX + 1), 8 * GET_GROUP_IDY, 1.0f );
v[2] = projToView(8 * (GET_GROUP_IDX + 1), 8 * (GET_GROUP_IDY + 1), 1.0f );
v[3] = projToView(8 * GET_GROUP_IDX, 8 * (GET_GROUP_IDY + 1), 1.0f );

float4 o = make_float4( 0.0f, 0.0f, 0.0f, 0.0f );

for ( int i = 0; i M 4; ++i )
frustum[i] = createEquation( o, v[i], v[(i+o)& 3 );
}


Where 8 is the size of the tile and GET_GROUPID is the index of the thread group.

The paper says that projToView takes a screen-space pixel indices and depth value and returns coordinates in view space.

My question is, how do i project(unproject?) screen-space position back to view space? Do i just multiply the inverse of projection matrix? But something tells me this is not complete. If screen-space is already mapped in the viewport, do i reverse the viewport mapping first then multiply the inverse projection matrix? I'm confused... :\

PARTNERS