Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

How to choose vertices for the vertex shader
Started by MATAN1992 Aug 21 2017 01:50 PM

3 replies to this topic

Best Answer StarCrunch , 21 August 2017 - 02:43 PM

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.

[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

MATAN1992

[GLOBAL: userInfoPane.html]
MATAN1992
  • Observer

  • 24 posts
  • Corona SDK

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.

 



[TOPIC: post.html]
#2

StarCrunch

[GLOBAL: userInfoPane.html]
StarCrunch
  • Contributor

  • 848 posts
  • Corona SDK

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?



[TOPIC: post.html]
#3

MATAN1992

[GLOBAL: userInfoPane.html]
MATAN1992
  • Observer

  • 24 posts
  • Corona SDK

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:

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



[TOPIC: post.html]
#4

StarCrunch

[GLOBAL: userInfoPane.html]
StarCrunch
  • Contributor

  • 848 posts
  • Corona SDK

  Best Answer

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.




[topic_controls]
[/topic_controls]