How to save Vertex positions to Mesh

Node-based Shader Editor

How to save Vertex positions to Mesh

Postby TheoKain » Sat Nov 03, 2018 2:18 am

I'm looking for a way to save some vertex animation from an ASE Shader I created, to a mesh in unity. So far, I've had trouble finding any detailed instructions, but I've heard mention of using RenderTexture, Graphics.blit and readpixel()... I just don't know exactly how to send modified vertex information back to the CPU via this technique.

I'm not a shader expert by any means so any help would be much appreciated.
TheoKain
 
Posts: 4
Joined: Sat Nov 03, 2018 2:05 am

Re: How to save Vertex positions to Mesh

Postby Amplify_Borba » Mon Nov 05, 2018 11:31 am

Hello, thank you for getting in touch and for your support!

This seems to be beyond the scope of our shader editor, could you please provide more information and an example of the type of effect you're trying to achieve?
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am

Re: How to save Vertex positions to Mesh

Postby TheoKain » Mon Nov 05, 2018 2:38 pm

Thanks for the reply!

I've been instructed about this technique but have yet to test or implement successfully.
To be able to save vertex offsets calculations done in the shader back into a mesh object in unity (for opengl es3.0 hardware) apparently there is only one way to do it.
- Calculate unique uv's and map to vertices in c# script
- Set indices of the mesh and have them display as points
- Upload meshdata to the gpu

- Then In the shader, the unique UV's are passed to POSITION
- The (WorldPosition * Vertex pos) is passed to the TEXCOORD0
- This is then output in the frag program

- From there, back in c#, the script reads the buffer and converts the output back into a vertex array
- vertex array reassigned to mesh and now vertex transformations can be saved.

Obviously this is not simple and I've been struggling with it for two days now. I've been told that the skinner project on github implements something like this.
The relevant parts are the shader => https://github.com/keijiro/Skinner/blob ... ment.cginc
and the mesh preperation => https://github.com/keijiro/Skinner/blob ... erModel.cs

I'm currently trying to implement the shader, but I don't know how to pass these two lines in the shader graph
// POSITION <= UV on the attribute buffer
o.position = float4(v.texcoord.x * 2 - 1, 0, 0, 1);
// TEXCOORD <= World position
o.texcoord = mul(unity_ObjectToWorld, v.vertex).xyz;

Any help would be appreciated!
TheoKain
 
Posts: 4
Joined: Sat Nov 03, 2018 2:05 am

Re: How to save Vertex positions to Mesh

Postby Amplify_Borba » Mon Nov 05, 2018 3:42 pm

Thank you for elaborating, could you also let us know if you're building a standard surface shader or using a template through ASE?

The reason we ask is because in surface shaders you can write the absolute positions of the vertex, while in the templates you'll need to do a workaround through a Custom Expression. We'll be happy to share additional information as soon as we know more, thanks!
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am

Re: How to save Vertex positions to Mesh

Postby TheoKain » Mon Nov 05, 2018 3:53 pm

I'm using the ASE LWRP shader with the Lightweight Unlit template, and also the Lightweight PBR.

Thanks!
TheoKain
 
Posts: 4
Joined: Sat Nov 03, 2018 2:05 am

Re: How to save Vertex positions to Mesh

Postby Amplify_Borba » Tue Nov 06, 2018 9:22 am

Thank you for the additional details, I'll get back to you with further information as soon as the developer is able to look into this situation.
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am


Return to Amplify Shader Editor

Who is online

Users browsing this forum: No registered users and 0 guests

cron