pmndrs / lamina

šŸ° An extensible, layer based shader material for ThreeJS
MIT License
1.01k stars 41 forks source link

Possible to update vertex positions? #14

Closed nwpointer closed 2 years ago

nwpointer commented 2 years ago

first off wanted to say lamina is awesome, have really enjoyed playing around with it so far!

I was interested in making some custom layers that modified vertex positions eg:

  1. fullscreen layer (gl_Position = vec4(position * 2.0, 1.0) ...)
  2. height-map displacement layer (gl_Position.z += texture2d(map, uv).r)

Is this kinda thing out of scope for Lamina?

took a stab at implementing these but ran into issues because the ${body.vert} is included before gl_position is set and currently gl_position is determined entirely by unmodifiable input values. (modelViewMatrix, position, & projectionMatrix).

FarazzShaikh commented 2 years ago

Hey! Thanks for using this!

There is an experimental Branch for vertex shader support here: https://github.com/pmndrs/lamina/tree/experimental/vertex-shaders

However, Iā€™d recommend you to wait for the 1.1.0 release that will come out in the next couple days as it will natively support displacement layers with loads of options and a much simpler API. Hereā€™s a sneak peek: https://github.com/pmndrs/lamina/blob/1.1.0/src/core/Displace.ts

edit: to answer your question, in current release (1.0.x) there is no vertex shader support

nwpointer commented 2 years ago

gotcha - thanks for the sneak peek at 1.1.0 :)

FarazzShaikh commented 2 years ago

Closed via 1.1.1

michaeljblum commented 2 years ago

Vertex manipulation looks awesome on really small objects, e.g. a sphere with args [0.5,64,64], but imperceivable on larger objects, same sphere with args [20,64,64].

I'm still learning glsl so I can't say for sure how to scale the shader's effect. Is there any way of achieving for larger objects what is readily available for much smaller ones? I tried messing around with parameters but nothing worked.