Render Pass and Shader Question v111

image

  1. What is this new “Data Type”?

  2. What is “Unsigned Byte” Data Type? When should I use this?

  3. What is “Half Float” Data Type? WHen should I use this?

  4. How to close the shader preview? There used to be a button in the top right corner above the preview box. but now it’s gone.

  1. What is this Shader Derivative patch for?
  2. What should we connect to the input? a texture? uv?
  3. What is the output of this patch? vec2? texture?
  4. When / what scenario when we might want to use dFdx or dFdy or fwidth?
  5. What is the most common application for this patch? any example?

@josh_beckwith @Tomas_Pietravallo @enuriru I summon shader gods to the rescue. :pray: :innocent: :pray:

1/2/3. Data type is for precision. Half float is good for more precise calculations, but less performant.
4. It seems hiding doesn’t work anymore :grimacing:
5. An introduction to shader derivative functions | A Clockwork Berry
6/7. You can pass any signal through.
8/9. A lot. But shader derivative functions doesn’t work properly on android devices so if you ever need them, you have implement them by hand.

4 Likes

1/2/3 ahhhh so that’s why when i’m doing some convolution or any texture sampling composition the pixel edges look choppy when i downsampling the scale? is that correct?
5. whoaa… thanks for this.
8/9 can you give a bit of clue of the most common problem or goals to achieve by implementing this derivative function? like the most layman understanding. cuz i’m completely lost about this. also, by implement by hand, do you mean we have to do some math work ourself? or trying to do workaround by kinda “faking” the effect? sorry i’m lost. teach me sensei :pray: :rofl:

8/9 You need to shift the image by one pixel & take the difference.

Pseudo code:

vec2 uv = fragment(std::getVertexTexCoord());
float x = uv.x;
x+=(1./screenSize.x);
vec4 nonShifted = Image.sample(uv);
vec4 shifted = Image.sample(vec2(x, uv.y));
vec4 dx = (nonShifted-shifted);

Edit: reading

3 Likes

I have never tried faking the derivatives but that’s a good idea! Here’s one approach with patches, based on your pseudo code

4 Likes