Created Lightning Gun effect (Uses LineRenderer, very slow) Created GPU Lightning renderer (very fast, still needs integration)
55 lines
1,021 B
Text
55 lines
1,021 B
Text
#ifndef GPUTRAIL_VARIABLES_CS_INCLUDED
|
|
#define GPUTRAIL_VARIABLES_CS_INCLUDED
|
|
|
|
#include "GPUTrailInput.cginc"
|
|
#include "GPUTrailVertex.cginc"
|
|
|
|
// #define LERP_TYPE_NONE 0
|
|
// #define LERP_TYPE_SPLINE 1
|
|
|
|
struct Trail
|
|
{
|
|
float startTime;
|
|
uint totalInputNum;
|
|
};
|
|
|
|
struct Node
|
|
{
|
|
float3 pos;
|
|
float time;
|
|
half4 color;
|
|
};
|
|
|
|
uint _TrailNum;
|
|
uint _NodeNumPerTrail;
|
|
uint _InputNodeNum;
|
|
// uint _LerpType;
|
|
float _MinNodeDistance;
|
|
float _Time;
|
|
float _Life;
|
|
float3 _ToCameraDir; // for orthographics camera
|
|
float3 _CameraPos; // for perspective camera
|
|
float _StartWidth;
|
|
float _EndWidth;
|
|
|
|
|
|
uint calcTrailIdx(uint nodeIdx)
|
|
{
|
|
return nodeIdx / _NodeNumPerTrail;
|
|
}
|
|
uint calcNodeIdx(uint trailIdx, uint nodeIdxInTrail)
|
|
{
|
|
return (trailIdx * _NodeNumPerTrail) + (nodeIdxInTrail % _NodeNumPerTrail);
|
|
}
|
|
|
|
inline bool useToCameraDir()
|
|
{
|
|
return all(_ToCameraDir == 0);
|
|
}
|
|
|
|
inline float3 calcToCameraDir(float3 pos)
|
|
{
|
|
return useToCameraDir() ? normalize(_CameraPos - pos) : _ToCameraDir;
|
|
}
|
|
|
|
#endif // GPUTRAIL_VARIABLES_CS_INCLUDED
|