Following player in worldspace

Node-based Shader Editor

Following player in worldspace

Postby KillaN » Wed Nov 29, 2017 4:03 pm

Hey folks,

So far Amplify has been great but i ran into an issue the other day.
I want to track the player in my watershader to create ripple effects (Top-Down ortho Rendertexture with ripple particles as mask) but so far no luck. (Reference is Mario Odesseys water system, seems to do something similar)

I tried getting the players position in script and applying it to a vector3 and using it as texture coordinates.
Multiplying or Adding it to worldposition isn't working. Same goes for vertex position/normal.

Is there a way for a texture to follow either the player or rendercamera (can't select a camera with WSCameraPos)?
Example: https://youtu.be/aZJQuHZQakQ?t=11m43s
(Don't mind the music haha)
KillaN
 
Posts: 3
Joined: Wed Nov 29, 2017 8:17 am

Re: Following player in worldspace

Postby Amplify_Borba » Wed Nov 29, 2017 7:07 pm

Hey there!

No problem at all, that's a great song, and thank you for getting in touch!

It mostly depends on the type of effect you would like to create and the intended approach, as there are a few ways of tackling this, I would kindly suggest that you check out our ForceShield sample, which is located in the AmplifyShaderEditor/Examples/Community/ForceShield folder as a starting point.

The impact effect node setup and its script will hopefully point you the right way, but don't hesitate to get in touch with us if you have any further questions, we'll be glad to assist you!
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: Following player in worldspace

Postby KillaN » Wed Nov 29, 2017 11:17 pm

Thanks! Maybe this is a better explanation:
Here's the material setup for the ripples: Image
I want to use this in a particle effect, render it on the player position to a rendertexture and use it as a mask to drive the vertex Y offset.

In a nutshell: All i need is an output that's shown in the Uncharted GDC talk (11:54, snow and lava deformation)
It uses a particle system, trailing the player, to see where deformation is happening on the snow.

I tried to work with the forceshield sample, but still i can't seem to add the ripple effect as a mask on top of the impact position output.

Thanks for pointing me to the ForceShield shader though! Definitely learned from it.
KillaN
 
Posts: 3
Joined: Wed Nov 29, 2017 8:17 am

Re: Following player in worldspace

Postby Amplify_Borba » Thu Nov 30, 2017 7:17 pm

Not a problem, always glad to help!

To clarify, you cannot use either a local position or a world position directly as a texture coordinate.

So, in order for them to be transformed into some tipe of UVs, you need to transform your position to normalized device coordinates, but in relation with the camera rendering the mask. For that you'll need to pass to your shader the model view projection matrix from the camera which is rendering the mask.

Inside the shader, you'll have to multiply the local vertex position by this matrix. What this will do is give you the object position as seen from that camera through values between -1 and 1, so you will now have to offset and scale those values to be between 0 and 1 ( which are the normalized device coordinates ).

This value can then be used to fetch the render texture and apply the mask results. There might be some tweaking you need to do to further match how the render texture itself is being written, but this is the general idea.

You may also check the following links for some additional information regarding this type of effects:

- ( gdcvault ) Deformable Snow Rendering in Batman: Arkham Origins

- ( Youtube ) Deformable Snow Rendering in Batman: Arkham Origins

Please do let us know if the above explanation and references were helpful, feel free to get back to us should you have any further questions, 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: Following player in worldspace

Postby KillaN » Thu Nov 30, 2017 9:14 pm

Thanks for the elaborate explanation! This does make more sense :)
I'll get on it. Thanks again for your time!
KillaN
 
Posts: 3
Joined: Wed Nov 29, 2017 8:17 am

Re: Following player in worldspace

Postby Amplify_Borba » Mon Dec 04, 2017 5:12 pm

Thank you for getting back in touch, its good to know that the information shared was helpful!

Have you had the chance to rate and review Amplify Shader Editor? It would be awesome if you could share your experience with the Unity community, the Unity Asset Store thrives on user interaction and direct feedback.

Every bit helps, your feedback is extremely valuable to us!

Feel free to get back in touch if you have further issues or questions, 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


Return to Amplify Shader Editor

Who is online

Users browsing this forum: No registered users and 4 guests