How to choose vertices for the vertex shader

Hello everyone and thanks in advance to all the helpers.

My question is how can I choose which vertices to send to the vertex shader ?

When I apply a vertex shader to a display object which I created with display.newImage it gets only the four corners.

I hope my English is clear enough, if not I will add some code that may clarify my intentions.

Hi.

You probably want a mesh. This will require a little bit more work but you have full control.

What are you trying to do?

I’m trying to add my own vertices to the image, not for a particular case, I’m just trying to understand how to work with vertex shaders.

My understanding is that meshes are passed to the vertex shader automatically, can I add a mesh to a dispalyImage or is there

a way to display an image on a mesh object ?

thank you very much for your help.

for a frame of reference here’s what I’m actually trying to do.

that’s the shader - it’s the wobble shader from the guide.

kernel.vertex = [[P\_POSITION vec2 VertexKernel( P\_POSITION vec2 position ) { P\_POSITION float amplitude = 100.; position.y += sin( 3.0 \* CoronaTotalTime + CoronaTexCoord.x ) \* amplitude \* CoronaTexCoord.y; return position; }]]

all I do is to apply it on a displayImage.

what it does is - it wobbles the bottom two corners, I want to make it wobble the middle of the bottom two corners also.

EDIT:

https://www.youtube.com/watch?v=ZMWKyMdSUfc

I found the answer, it’s new polygon instead of new image. thank you for your response

A mesh is basically the generalized form of a display object. It accepts a fill like any of them do.

Meshes might be a little confusing at first since you need to lay out the triangles / rects yourself. You can check out various objects in wireframe to see how they break down into triangles, which might help your intuition.

If you need it, you can even adjust how the parts of the image (the “fragments”, since we’re talking shaders) attach to the vertices, using the uv methods.

Hi.

You probably want a mesh. This will require a little bit more work but you have full control.

What are you trying to do?

I’m trying to add my own vertices to the image, not for a particular case, I’m just trying to understand how to work with vertex shaders.

My understanding is that meshes are passed to the vertex shader automatically, can I add a mesh to a dispalyImage or is there

a way to display an image on a mesh object ?

thank you very much for your help.

for a frame of reference here’s what I’m actually trying to do.

that’s the shader - it’s the wobble shader from the guide.

kernel.vertex = [[P\_POSITION vec2 VertexKernel( P\_POSITION vec2 position ) { P\_POSITION float amplitude = 100.; position.y += sin( 3.0 \* CoronaTotalTime + CoronaTexCoord.x ) \* amplitude \* CoronaTexCoord.y; return position; }]]

all I do is to apply it on a displayImage.

what it does is - it wobbles the bottom two corners, I want to make it wobble the middle of the bottom two corners also.

EDIT:

https://www.youtube.com/watch?v=ZMWKyMdSUfc

I found the answer, it’s new polygon instead of new image. thank you for your response

A mesh is basically the generalized form of a display object. It accepts a fill like any of them do.

Meshes might be a little confusing at first since you need to lay out the triangles / rects yourself. You can check out various objects in wireframe to see how they break down into triangles, which might help your intuition.

If you need it, you can even adjust how the parts of the image (the “fragments”, since we’re talking shaders) attach to the vertices, using the uv methods.