Anti Aliasing by Viewport Post Processing w/o Derivatives in GLES 2.0
Asked Answered
B

5

0

I have found a sample project regarding Anti Aliasing by Viewport Post Processing via Derivatives (dFdx, dFdy and fwidth) in GLES 3.0.
Where can I get Anti Aliasing by Viewport Post Processing via another method in GLES 2.0?
Thx in advance.

Beverly answered 28/7, 2022 at 19:53 Comment(0)
U
0

pos is the UV, frag is FRAGCOORD, and pixel is the width/height of one pixel or 1.0 / VIEWPORT_SIZE

Upas answered 29/7, 2022 at 16:15 Comment(0)
U
0

Here is how to do it in GLES2

// partial derivative on x-axis
vec2 deriv_x(vec2 pos, vec4 frag, vec2 pixel) {
	vec2 offset = vec2(pixel.x, 0.0);
	vec2 pos_plus = pos + offset;
	vec2 pos_minus = pos - offset;
	int coord = int(frag.x) / 2;
	bool even = int(coord * 2) == int(frag.x);
	return even ? (pos_plus - pos) : (pos - pos_minus);
}

// partial derivative on y-axis
vec2 deriv_y(vec2 pos, vec4 frag, vec2 pixel) {
	vec2 offset = vec2(0.0, pixel.y);
	vec2 pos_plus = pos + offset;
	vec2 pos_minus = pos - offset;
	int coord = int(frag.y) / 2;
	bool even = int(coord * 2) == int(frag.y);
	return even ? (pos_plus - pos) : (pos - pos_minus);
}
Upas answered 29/7, 2022 at 5:19 Comment(0)
B
0

Upas Hi,

Thanks for quick reply.

I know the base logic that gives the derivatives between the center pixel and each neighbour pixel on mentioned axis.
But little confusing about the function parameters (vec2 pos, vec4 frag, vec2 pixel). Original dFdx/dFdy takes only one parameter. Still I am hesitant which info in parameters should be included in the function.

Any possibility to give a sample code snippet to call the function from fragment() with some quick comments?
e.g.:
vec2 pos = .... ..... ..... ..... // ........... ............. ...............
vec4 frag = .... .... ...... .... // ......... ............ ............. ...........
vec2 pixel = .... ...... .... ..... // ......... ........... ........... ..............

Thx in advance...

Beverly answered 29/7, 2022 at 11:51 Comment(0)
U
0

pos is the UV, frag is FRAGCOORD, and pixel is the width/height of one pixel or 1.0 / VIEWPORT_SIZE

Upas answered 29/7, 2022 at 16:15 Comment(0)
B
0

Upas

Super!!!!..... thx for the efforts......

Beverly answered 29/7, 2022 at 17:8 Comment(0)
B
0

Upas
I am still grateful to you. You opened up a blocked path to me.
So, and unfortunately for you, this means that a flood of questions (some maybe illiterated 🙁 ) will come soon.
Hope to get your precious help regularly.

Beverly answered 9/8, 2022 at 11:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.