Skip to content
This repository was archived by the owner on Nov 30, 2020. It is now read-only.

Commit 0716ce0

Browse files
authored
Merge pull request #99 from Kink3d/util-custommovec
Added custom motion vector texture utility
2 parents a87de09 + 0e17ed0 commit 0716ce0

30 files changed

+520
-0
lines changed

PostProcessing/Utilities.meta

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

PostProcessing/Utilities/CustomMotionTexture.meta

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.

PostProcessing/Utilities/CustomMotionTexture/ExampleProfile.asset.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.

PostProcessing/Utilities/CustomMotionTexture/ExampleScene.unity.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
public class ExampleWheelController : MonoBehaviour {
6+
7+
private Rigidbody rb;
8+
public float acceleration;
9+
public Renderer motionVectorRenderer; //Reference to the custom motion vector renderer
10+
11+
static class Uniforms
12+
{
13+
internal static readonly int _MotionAmount = Shader.PropertyToID("_MotionAmount");
14+
}
15+
16+
17+
void Start ()
18+
{
19+
rb = GetComponent<Rigidbody> (); //Get reference to rigidbody
20+
rb.maxAngularVelocity = 100; //Set max velocity for rigidbody
21+
}
22+
23+
void Update ()
24+
{
25+
if (Input.GetKey (KeyCode.UpArrow)) //Rotate forward
26+
rb.AddRelativeTorque (new Vector3 (-1 * acceleration, 0, 0), ForceMode.Acceleration); //Add forward torque to mesh
27+
else if (Input.GetKey (KeyCode.DownArrow)) //Rotate backward
28+
rb.AddRelativeTorque (new Vector3 (1 * acceleration, 0, 0), ForceMode.Acceleration); //Add backward torque to mesh
29+
float m = -rb.angularVelocity.x / 100; //Calculate multiplier for motion vector texture
30+
if(motionVectorRenderer) //If the custom motion vector texture renderer exists
31+
motionVectorRenderer.material.SetFloat (Uniforms._MotionAmount, Mathf.Clamp(m, -0.25f, 0.25f)); //Set the multiplier on the renderer's material
32+
}
33+
}

PostProcessing/Utilities/CustomMotionTexture/ExampleWheelController.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

PostProcessing/Utilities/CustomMotionTexture/Materials.meta

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.

0 commit comments

Comments
 (0)