pmndrs / lamina

🍰 An extensible, layer based shader material for ThreeJS
MIT License
1.01k stars 41 forks source link

Why does CustomLayer example change the position if the comment says it shouldn't be transformed? #28

Closed TimPietrusky closed 2 years ago

TimPietrusky commented 2 years ago

Am I the only one that thinks that the implementation of https://github.com/pmndrs/lamina/blob/main/README.md?plain=1#L205-L216 is confusing when looking at the comment?

For me it sounds like, that a CustomLayer should't change the position via the vertex-shader, but in the example it totally does exactly that:

  // Optionally Define a vertex shader!
  // Same rules as fragment shaders, except no blend modes.
  // Return a non-transformed vec3 position.
  static vertexShader = `   
    // Varyings must be prefixed by "v_"
    varying vec3 v_Position;
    void main() {
      v_Position = position;
      return position * 2.;
    }

So Return a non-transformed vec3 position. sounds to me that return position * 2.; shouldn't be done (I mean of course you can do that, but as a best practise it shouldn't right?).

When I copied the example I was surprised that my mesh had increased in size.

FarazzShaikh commented 2 years ago

Sorry typo, meant “non-projected”. Will fix

basically you don’t need to project the position by multiplying it with modelViewPosition

TimPietrusky commented 2 years ago

Awesome, thank you very much!