Skip to content
Snippets Groups Projects
Commit 20043f98 authored by Rico Possienka's avatar Rico Possienka
Browse files

use time based shader for line renderer

parent dee69e22
No related branches found
No related tags found
No related merge requests found
...@@ -8,15 +8,14 @@ Material: ...@@ -8,15 +8,14 @@ Material:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_Name: line m_Name: line
m_Shader: {fileID: 211, guid: 0000000000000000f000000000000000, type: 0} m_Shader: {fileID: 4800000, guid: 23ee1bed62f682b4a8ce14453c28ac00, type: 3}
m_ShaderKeywords: m_ShaderKeywords:
m_LightmapFlags: 0 m_LightmapFlags: 0
m_EnableInstancingVariants: 0 m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0 m_DoubleSidedGI: 0
m_CustomRenderQueue: -1 m_CustomRenderQueue: -1
stringTagMap: {} stringTagMap: {}
disabledShaderPasses: disabledShaderPasses: []
- ALWAYS
m_SavedProperties: m_SavedProperties:
serializedVersion: 3 serializedVersion: 3
m_TexEnvs: m_TexEnvs:
...@@ -76,6 +75,7 @@ Material: ...@@ -76,6 +75,7 @@ Material:
- _GlossMapScale: 1 - _GlossMapScale: 1
- _Glossiness: 0.5 - _Glossiness: 0.5
- _GlossyReflections: 1 - _GlossyReflections: 1
- _InvFade: 1
- _LightingEnabled: 0 - _LightingEnabled: 0
- _Metallic: 0 - _Metallic: 0
- _Mode: 0 - _Mode: 0
...@@ -95,3 +95,4 @@ Material: ...@@ -95,3 +95,4 @@ Material:
- _ColorAddSubDiff: {r: 0, g: 0, b: 0, a: 0} - _ColorAddSubDiff: {r: 0, g: 0, b: 0, a: 0}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1} - _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SoftParticleFadeParams: {r: 0, g: 0, b: 0, a: 0} - _SoftParticleFadeParams: {r: 0, g: 0, b: 0, a: 0}
- _TintColor: {r: 0.5, g: 0.5, b: 0.5, a: 0.5}
This diff is collapsed.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DataContainer : ScriptableObject
{
TextAsset csvFile;
public DataPath.DataPoint[] dataPoints;
public void Read() { }
}
fileFormatVersion: 2
guid: 49596d1540a70d14aa850ce101ce2576
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
...@@ -83,8 +83,6 @@ public class DataPath : MonoBehaviour ...@@ -83,8 +83,6 @@ public class DataPath : MonoBehaviour
{ {
var lr = this.GetComponent<LineRenderer>(); var lr = this.GetComponent<LineRenderer>();
Vector3[] positions = new Vector3[points.Count]; Vector3[] positions = new Vector3[points.Count];
Color[] colors = new Color[points.Count];
Color32 col = ConvertAndroidColor(this.id_hash);
var map = LocationProviderFactory.Instance.mapManager; var map = LocationProviderFactory.Instance.mapManager;
//Vector3 prevPosition = map.GeoToWorldPosition(new Vector2d(points[0].lat, points[0].lon)); //Vector3 prevPosition = map.GeoToWorldPosition(new Vector2d(points[0].lat, points[0].lon));
...@@ -94,18 +92,12 @@ public class DataPath : MonoBehaviour ...@@ -94,18 +92,12 @@ public class DataPath : MonoBehaviour
//DEBUG //DEBUG
//position.y = 1; //position.y = 1;
positions[i] = position; positions[i] = position;
colors[i] = col;
//Debug.DrawLine(prevPosition, position, col);
//prevPosition = position;
} }
//lr.SetColors() //lr.SetColors()
this.positions = positions; this.positions = positions;
lr.positionCount = positions.Length; lr.positionCount = positions.Length;
lr.SetPositions(positions); lr.SetPositions(positions);
lr.startColor = col;
lr.endColor = col;
Gradient gradient; Gradient gradient;
...@@ -116,18 +108,18 @@ public class DataPath : MonoBehaviour ...@@ -116,18 +108,18 @@ public class DataPath : MonoBehaviour
// Populate the color keys at the relative time 0 and 1 (0 and 100%) // Populate the color keys at the relative time 0 and 1 (0 and 100%)
colorKey = new GradientColorKey[2]; colorKey = new GradientColorKey[2];
colorKey[0].color = Color.Lerp(col, Color.black, 0.5f);
colorKey[0].color = Color.black;
colorKey[0].time = 0.0f; colorKey[0].time = 0.0f;
colorKey[1].color = Color.Lerp(col, Color.white, 0.5f); colorKey[1].color = Color.white;
colorKey[1].time = 1.0f; colorKey[1].time = 1.0f;
// Populate the alpha keys at relative time 0 and 1 (0 and 100%) // Populate the alpha keys at relative time 0 and 1 (0 and 100%)
alphaKey = new GradientAlphaKey[2]; alphaKey = new GradientAlphaKey[2];
alphaKey[0].alpha = 1.0f; alphaKey[0].alpha = 1.0f;
alphaKey[0].time = 0.0f; alphaKey[0].time = 0.0f;
alphaKey[1].alpha = 0.0f; alphaKey[1].alpha = 1.0f;
alphaKey[1].time = 1.0f; alphaKey[1].time = 1.0f;
gradient.SetKeys(colorKey, alphaKey); gradient.SetKeys(colorKey, alphaKey);
......
fileFormatVersion: 2
guid: dd4cb96ece5fb9e47a4d92faae84bc5d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Shader "mViz/Line"
{
Properties
{
_MainTex("Texture", 2D) = "white" {}
}
SubShader
{
Blend One One
Tags { "RenderType" = "Opaque" }
LOD 100
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
// make fog work
#pragma multi_compile_fog
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float4 color : COLOR;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 color : COLOR;
UNITY_FOG_COORDS(1)
float4 vertex : SV_POSITION;
};
sampler2D _MainTex;
float4 _MainTex_ST;
v2f vert(appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
o.color = v.color;
UNITY_TRANSFER_FOG(o,o.vertex);
return o;
}
float f(float x, float s) {
return (1.0 - ((x * s)) * ((x * s)));
}
fixed4 frag(v2f i) : SV_Target
{
// sample the texture
//fixed4 col = tex2D(_MainTex, i.uv);
float t = _Time.r;
t = t % 1.0;
float x = i.color.r + t;
x = x % 2 - 1; //[-1..1]
//fixed4 col = i.color;
float4 red = float4(1, 0, 0, 1);
fixed4 col = red * clamp(f(x+t, 20), 0, 1);
// apply fog
UNITY_APPLY_FOG(i.fogCoord, col);
return col;
}
ENDCG
}
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: 23ee1bed62f682b4a8ce14453c28ac00
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment