zippoL

05-30-2016, 05:52 PM

Hey!

I have searched for two days now on Google and I can't find any useful information about how to manually calculate the texels offset.

I need to calculate 4 neighbor texel offsets for each processed fragment while:

Option 1.) Downsampling(From full resolution to half resolution).

Option 2.) Upsampling(From half resolution to full resolution).

Option 3.) On the same level, i.e. both textures have the same size.

I need to downsample a depth texture and find the maximum depth. I also need to upsample another texture and at the same time preserve some details with the help of depth buffers.

I know how to calculate the offsets while performing the gaussian blur.

Example:

const float OFFSETS[4] = float[](0.0, 1.0, 2.0, 3.0);

in vec2 texCoordFS;

for(int i = 1; i < 4; i++)

{

vec2 uv0 = texCoordFS + vec2(OFFSETS[i] / textureWidth, 0.0);

vec2 uv1 = texCoordFS - vec2(OFFSETS[i] / textureWidth, 0.0);

}

for(int i = 1; i < 4; i++)

{

vec2 uv0 = texCoordFS + vec2(0.0, OFFSETS[i] / textureHeight);

vec2 uv1 = texCoordFS - vec2(0.0, OFFSETS[i] / textureHeight);

}

Let us assume that we are going to render a fullscreen quad and we have UV-coordinates for each corner.

For option nr 1(sample 4 times from the full resolution texture), nr 2(sample 4 times from the half resolution texture) and nr 3, I have no idea which of the following I need to use for option 1, 2, 3:

const vec2 OFFSETS0[4] = vec2[]

(

vec2(0.0, 0.5),

vec2(0.5, 0.0),

vec2(-0.5, 0.0),

vec2(0.0, -0.5)

);

const vec2 OFFSETS1[4] = vec2[]

(

vec2(0.0, 1.0),

vec2(1.0, 0.0),

vec2(-1.0, 0.0),

vec2(0.0, -1.0)

);

const vec2 OFFSETS2[4] = vec2[]

(

vec2(-1.0, -1.0),

vec2(-1.0, 1.0),

vec2(1.0, -1.0),

vec2(1.0, 1.0)

);

const vec2 OFFSETS3[4] = vec2[]

(

vec2(-0.5, -0.5),

vec2(-0.5, 0.5),

vec2(0.5, -0.5),

vec2(0.5, 0.5)

);

I guess on option nr 3, I can use OFFSETS1 or OFFSETS2 ?

I have searched for two days now on Google and I can't find any useful information about how to manually calculate the texels offset.

I need to calculate 4 neighbor texel offsets for each processed fragment while:

Option 1.) Downsampling(From full resolution to half resolution).

Option 2.) Upsampling(From half resolution to full resolution).

Option 3.) On the same level, i.e. both textures have the same size.

I need to downsample a depth texture and find the maximum depth. I also need to upsample another texture and at the same time preserve some details with the help of depth buffers.

I know how to calculate the offsets while performing the gaussian blur.

Example:

const float OFFSETS[4] = float[](0.0, 1.0, 2.0, 3.0);

in vec2 texCoordFS;

for(int i = 1; i < 4; i++)

{

vec2 uv0 = texCoordFS + vec2(OFFSETS[i] / textureWidth, 0.0);

vec2 uv1 = texCoordFS - vec2(OFFSETS[i] / textureWidth, 0.0);

}

for(int i = 1; i < 4; i++)

{

vec2 uv0 = texCoordFS + vec2(0.0, OFFSETS[i] / textureHeight);

vec2 uv1 = texCoordFS - vec2(0.0, OFFSETS[i] / textureHeight);

}

Let us assume that we are going to render a fullscreen quad and we have UV-coordinates for each corner.

For option nr 1(sample 4 times from the full resolution texture), nr 2(sample 4 times from the half resolution texture) and nr 3, I have no idea which of the following I need to use for option 1, 2, 3:

const vec2 OFFSETS0[4] = vec2[]

(

vec2(0.0, 0.5),

vec2(0.5, 0.0),

vec2(-0.5, 0.0),

vec2(0.0, -0.5)

);

const vec2 OFFSETS1[4] = vec2[]

(

vec2(0.0, 1.0),

vec2(1.0, 0.0),

vec2(-1.0, 0.0),

vec2(0.0, -1.0)

);

const vec2 OFFSETS2[4] = vec2[]

(

vec2(-1.0, -1.0),

vec2(-1.0, 1.0),

vec2(1.0, -1.0),

vec2(1.0, 1.0)

);

const vec2 OFFSETS3[4] = vec2[]

(

vec2(-0.5, -0.5),

vec2(-0.5, 0.5),

vec2(0.5, -0.5),

vec2(0.5, 0.5)

);

I guess on option nr 3, I can use OFFSETS1 or OFFSETS2 ?