Mesh translation with shaders

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Ogeeice

Is it possible to somehow move the edge of a mesh. Like let’s say a vertical plane, it has four edges can a shader allow you to change the top edge translation and if yes how do I achieve this

:bust_in_silhouette: Reply From: Xian

Before I say something, I want you to know any changes you make to the mesh using shaders would only be purely visual. So, meaning your collision shape won’t change at all. If that doesn’t bother you then here:

uniform float topMargin : hint_range(1.0,128.0) = 1.0;

void vertex() {
	UV=UV*uv1_scale.xy+uv1_offset.xy;
	VERTEX.y *=  topMargin; 
	//this will make it grow taller in both directions(top and bottom). 
	VERTEX.y += topMargin - 1.0;
 	//this will move it up.
}

in shaderparam there should be a new item called topMargin, use it to adjust how much the must be.

Xian | 2020-09-03 04:44

Thanks I’ll give it a try

Ogeeice | 2020-09-03 23:23