Актуальная версия
This commit is contained in:
458
Assets/RaceTracksPack/Shaders/AIBillboard.cginc
Normal file
458
Assets/RaceTracksPack/Shaders/AIBillboard.cginc
Normal file
@ -0,0 +1,458 @@
|
||||
// Amplify Impostors
|
||||
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
|
||||
|
||||
#ifndef AIBillboard_INCLUDED
|
||||
#define AIBillboard_INCLUDED
|
||||
|
||||
// turn the next define to 1 to activate neighbour frame clipping
|
||||
// use it only if your impostors show small artifacts at edges at some rotations
|
||||
#define AI_CLIP_NEIGHBOURS_FRAMES 0
|
||||
|
||||
float2 VectortoOctahedron( float3 N )
|
||||
{
|
||||
N /= dot( 1.0, abs(N) );
|
||||
if( N.z <= 0 )
|
||||
{
|
||||
N.xy = ( 1 - abs(N.yx) ) * ( N.xy >= 0 ? 1.0 : -1.0 );
|
||||
}
|
||||
return N.xy;
|
||||
}
|
||||
|
||||
float2 VectortoHemiOctahedron( float3 N )
|
||||
{
|
||||
N.xy /= dot( 1.0, abs(N) );
|
||||
return float2( N.x + N.y, N.x - N.y );
|
||||
}
|
||||
|
||||
float3 OctahedronToVector( float2 Oct )
|
||||
{
|
||||
float3 N = float3( Oct, 1.0 - dot( 1.0, abs(Oct) ) );
|
||||
if( N.z < 0 )
|
||||
{
|
||||
N.xy = ( 1 - abs(N.yx) ) * ( N.xy >= 0 ? 1.0 : -1.0 );
|
||||
}
|
||||
return normalize(N);
|
||||
}
|
||||
|
||||
float3 HemiOctahedronToVector( float2 Oct )
|
||||
{
|
||||
Oct = float2( Oct.x + Oct.y, Oct.x - Oct.y ) *0.5;
|
||||
float3 N = float3( Oct, 1 - dot( 1.0, abs(Oct) ) );
|
||||
return normalize(N);
|
||||
}
|
||||
|
||||
uniform float _FramesX;
|
||||
uniform float _FramesY;
|
||||
uniform float _Frames;
|
||||
uniform float _ImpostorSize;
|
||||
uniform float _Parallax;
|
||||
uniform sampler2D _Albedo;
|
||||
uniform sampler2D _Normals;
|
||||
uniform sampler2D _Specular;
|
||||
uniform sampler2D _Emission;
|
||||
uniform float _TextureBias;
|
||||
uniform float _ClipMask;
|
||||
uniform float _DepthSize;
|
||||
uniform float _ShadowBias;
|
||||
uniform float4 _Offset;
|
||||
|
||||
#ifdef EFFECT_HUE_VARIATION
|
||||
half4 _HueVariation;
|
||||
#endif
|
||||
|
||||
inline void OctaImpostorVertex( inout appdata_full v, inout float4 uvsFrame1, inout float4 uvsFrame2, inout float4 uvsFrame3, inout float4 octaFrame, inout float4 viewPos )
|
||||
{
|
||||
// Inputs
|
||||
float framesXY = _Frames;
|
||||
float prevFrame = framesXY - 1;
|
||||
float2 fractions = 1.0 / float2( framesXY, prevFrame );
|
||||
float fractionsFrame = fractions.x;
|
||||
float fractionsPrevFrame = fractions.y;
|
||||
float UVscale = _ImpostorSize;
|
||||
float parallax = -_Parallax; // check sign later
|
||||
|
||||
// Basic data
|
||||
v.vertex.xyz += _Offset.xyz;
|
||||
float3 worldOrigin = float3(unity_ObjectToWorld[0].w, unity_ObjectToWorld[1].w, unity_ObjectToWorld[2].w);
|
||||
#if defined(UNITY_PASS_SHADOWCASTER)
|
||||
float3 worldCameraPos = 0;
|
||||
if( unity_LightShadowBias.y == 0.0 ){
|
||||
if( _WorldSpaceLightPos0.w == 1 )
|
||||
worldCameraPos = _WorldSpaceLightPos0.xyz;
|
||||
else
|
||||
worldCameraPos = _WorldSpaceCameraPos;
|
||||
} else {
|
||||
worldCameraPos = UnityWorldSpaceLightDir( mul(unity_ObjectToWorld, v.vertex).xyz ) * -5000.0;
|
||||
}
|
||||
#else
|
||||
float3 worldCameraPos = _WorldSpaceCameraPos;
|
||||
#endif
|
||||
|
||||
float3 objectCameraDirection = normalize( mul( (float3x3)unity_WorldToObject, worldCameraPos - worldOrigin ) - _Offset.xyz );
|
||||
float3 objectCameraPosition = mul( unity_WorldToObject, float4( worldCameraPos, 1 ) ).xyz - _Offset.xyz; //ray origin
|
||||
|
||||
// Create orthogonal vectors to define the billboard
|
||||
float3 upVector = float3( 0,1,0 );
|
||||
float3 objectHorizontalVector = normalize( cross( objectCameraDirection, upVector ) );
|
||||
float3 objectVerticalVector = cross( objectHorizontalVector, objectCameraDirection );
|
||||
|
||||
// Billboard
|
||||
float2 uvExpansion = ( v.texcoord.xy - 0.5f ) * framesXY * fractionsFrame * UVscale;
|
||||
float3 billboard = objectHorizontalVector * uvExpansion.x + objectVerticalVector * uvExpansion.y + _Offset.xyz;
|
||||
|
||||
float3 localDir = billboard - objectCameraPosition - _Offset.xyz;
|
||||
|
||||
// Octahedron Frame
|
||||
#ifdef _HEMI_ON
|
||||
objectCameraDirection.y = max(0.001, objectCameraDirection.y);
|
||||
float2 frameOcta = VectortoHemiOctahedron( objectCameraDirection.xzy ) * 0.5 + 0.5;
|
||||
#else
|
||||
float2 frameOcta = VectortoOctahedron( objectCameraDirection.xzy ) * 0.5 + 0.5;
|
||||
#endif
|
||||
|
||||
// Setup for octahedron
|
||||
float2 prevOctaFrame = frameOcta * prevFrame;
|
||||
float2 baseOctaFrame = floor( prevOctaFrame );
|
||||
float2 fractionOctaFrame = ( baseOctaFrame * fractionsFrame );
|
||||
|
||||
// Octa 1
|
||||
float2 octaFrame1 = ( baseOctaFrame * fractionsPrevFrame ) * 2.0 - 1.0;
|
||||
#ifdef _HEMI_ON
|
||||
float3 octa1WorldY = HemiOctahedronToVector( octaFrame1 ).xzy;
|
||||
#else
|
||||
float3 octa1WorldY = OctahedronToVector( octaFrame1 ).xzy;
|
||||
#endif
|
||||
float3 octa1WorldX = normalize( cross( upVector , octa1WorldY ) + float3(-0.001,0,0));
|
||||
float3 octa1WorldZ = cross( octa1WorldX , octa1WorldY );
|
||||
|
||||
float dotY1 = dot( octa1WorldY , localDir );
|
||||
float3 octa1LocalY = normalize( float3( dot( octa1WorldX , localDir ), dotY1, dot( octa1WorldZ , localDir ) ) );
|
||||
|
||||
float lineInter1 = dot( octa1WorldY , -objectCameraPosition ) / dotY1; //minus??
|
||||
float3 intersectPos1 = ( lineInter1 * localDir + objectCameraPosition ); // should subtract offset??
|
||||
|
||||
float dotframeX1 = dot( octa1WorldX , -intersectPos1 );
|
||||
float dotframeZ1 = dot( octa1WorldZ , -intersectPos1 );
|
||||
|
||||
float2 uvFrame1 = float2( dotframeX1 , dotframeZ1 );
|
||||
|
||||
if( lineInter1 <= 0.0 )
|
||||
uvFrame1 = 0;
|
||||
|
||||
float2 uvParallax1 = octa1LocalY.xz * fractionsFrame * parallax;
|
||||
uvFrame1 = ( ( uvFrame1 / UVscale ) + 0.5 ) * fractionsFrame + fractionOctaFrame;
|
||||
uvsFrame1 = float4( uvParallax1, uvFrame1);
|
||||
|
||||
// Octa 2
|
||||
float2 fractPrevOctaFrame = frac( prevOctaFrame );
|
||||
float2 cornerDifference = lerp( float2( 0,1 ) , float2( 1,0 ) , saturate( ceil( ( fractPrevOctaFrame.x - fractPrevOctaFrame.y ) ) ));
|
||||
float2 octaFrame2 = ( ( baseOctaFrame + cornerDifference ) * fractionsPrevFrame ) * 2.0 - 1.0;
|
||||
#ifdef _HEMI_ON
|
||||
float3 octa2WorldY = HemiOctahedronToVector( octaFrame2 ).xzy;
|
||||
#else
|
||||
float3 octa2WorldY = OctahedronToVector( octaFrame2 ).xzy;
|
||||
#endif
|
||||
|
||||
float3 octa2WorldX = normalize( cross( upVector , octa2WorldY ) + float3(-0.001,0,0));
|
||||
float3 octa2WorldZ = cross( octa2WorldX , octa2WorldY );
|
||||
|
||||
float dotY2 = dot( octa2WorldY , localDir );
|
||||
float3 octa2LocalY = normalize( float3( dot( octa2WorldX , localDir ), dotY2, dot( octa2WorldZ , localDir ) ) );
|
||||
|
||||
float lineInter2 = dot( octa2WorldY , -objectCameraPosition ) / dotY2; //minus??
|
||||
float3 intersectPos2 = ( lineInter2 * localDir + objectCameraPosition );
|
||||
|
||||
float dotframeX2 = dot( octa2WorldX , -intersectPos2 );
|
||||
float dotframeZ2 = dot( octa2WorldZ , -intersectPos2 );
|
||||
|
||||
float2 uvFrame2 = float2( dotframeX2 , dotframeZ2 );
|
||||
|
||||
if( lineInter2 <= 0.0 )
|
||||
uvFrame2 = 0;
|
||||
|
||||
float2 uvParallax2 = octa2LocalY.xz * fractionsFrame * parallax;
|
||||
uvFrame2 = ( ( uvFrame2 / UVscale ) + 0.5 ) * fractionsFrame + ( ( cornerDifference * fractionsFrame ) + fractionOctaFrame );
|
||||
uvsFrame2 = float4( uvParallax2, uvFrame2);
|
||||
|
||||
|
||||
// Octa 3
|
||||
float2 octaFrame3 = ( ( baseOctaFrame + 1 ) * fractionsPrevFrame ) * 2.0 - 1.0;
|
||||
#ifdef _HEMI_ON
|
||||
float3 octa3WorldY = HemiOctahedronToVector( octaFrame3 ).xzy;
|
||||
#else
|
||||
float3 octa3WorldY = OctahedronToVector( octaFrame3 ).xzy;
|
||||
#endif
|
||||
|
||||
float3 octa3WorldX = normalize( cross( upVector , octa3WorldY ) + float3(-0.001,0,0));
|
||||
float3 octa3WorldZ = cross( octa3WorldX , octa3WorldY );
|
||||
|
||||
float dotY3 = dot( octa3WorldY , localDir );
|
||||
float3 octa3LocalY = normalize( float3( dot( octa3WorldX , localDir ), dotY3, dot( octa3WorldZ , localDir ) ) );
|
||||
|
||||
float lineInter3 = dot( octa3WorldY , -objectCameraPosition ) / dotY3; //minus??
|
||||
float3 intersectPos3 = ( lineInter3 * localDir + objectCameraPosition );
|
||||
|
||||
float dotframeX3 = dot( octa3WorldX , -intersectPos3 );
|
||||
float dotframeZ3 = dot( octa3WorldZ , -intersectPos3 );
|
||||
|
||||
float2 uvFrame3 = float2( dotframeX3 , dotframeZ3 );
|
||||
|
||||
if( lineInter3 <= 0.0 )
|
||||
uvFrame3 = 0;
|
||||
|
||||
float2 uvParallax3 = octa3LocalY.xz * fractionsFrame * parallax;
|
||||
uvFrame3 = ( ( uvFrame3 / UVscale ) + 0.5 ) * fractionsFrame + ( fractionOctaFrame + fractionsFrame );
|
||||
uvsFrame3 = float4( uvParallax3, uvFrame3);
|
||||
|
||||
// maybe remove this?
|
||||
octaFrame = 0;
|
||||
octaFrame.xy = prevOctaFrame;
|
||||
#if AI_CLIP_NEIGHBOURS_FRAMES
|
||||
octaFrame.zw = fractionOctaFrame;
|
||||
#endif
|
||||
|
||||
// view pos
|
||||
viewPos = 0;
|
||||
viewPos.xyz = UnityObjectToViewPos( billboard );
|
||||
|
||||
#ifdef EFFECT_HUE_VARIATION
|
||||
float hueVariationAmount = frac(unity_ObjectToWorld[0].w + unity_ObjectToWorld[1].w + unity_ObjectToWorld[2].w);
|
||||
viewPos.w = saturate(hueVariationAmount * _HueVariation.a);
|
||||
#endif
|
||||
|
||||
v.vertex.xyz = billboard;
|
||||
v.normal.xyz = objectCameraDirection;
|
||||
}
|
||||
|
||||
inline void OctaImpostorFragment( inout SurfaceOutputStandardSpecular o, out float4 clipPos, out float3 worldPos, float4 uvsFrame1, float4 uvsFrame2, float4 uvsFrame3, float4 octaFrame, float4 interpViewPos )
|
||||
{
|
||||
float depthBias = -1.0;
|
||||
float textureBias = _TextureBias;
|
||||
|
||||
// Octa1
|
||||
float4 parallaxSample1 = tex2Dbias( _Normals, float4( uvsFrame1.zw, 0, depthBias) );
|
||||
float2 parallax1 = ( ( 0.5 - parallaxSample1.a ) * uvsFrame1.xy ) + uvsFrame1.zw;
|
||||
float4 albedo1 = tex2Dbias( _Albedo, float4( parallax1, 0, textureBias) );
|
||||
float4 normals1 = tex2Dbias( _Normals, float4( parallax1, 0, textureBias) );
|
||||
float4 mask1 = tex2Dbias( _Emission, float4( parallax1, 0, textureBias) );
|
||||
float4 spec1 = tex2Dbias( _Specular, float4( parallax1, 0, textureBias) );
|
||||
|
||||
// Octa2
|
||||
float4 parallaxSample2 = tex2Dbias( _Normals, float4( uvsFrame2.zw, 0, depthBias) );
|
||||
float2 parallax2 = ( ( 0.5 - parallaxSample2.a ) * uvsFrame2.xy ) + uvsFrame2.zw;
|
||||
float4 albedo2 = tex2Dbias( _Albedo, float4( parallax2, 0, textureBias) );
|
||||
float4 normals2 = tex2Dbias( _Normals, float4( parallax2, 0, textureBias) );
|
||||
float4 mask2 = tex2Dbias( _Emission, float4( parallax2, 0, textureBias) );
|
||||
float4 spec2 = tex2Dbias( _Specular, float4( parallax2, 0, textureBias) );
|
||||
|
||||
// Octa3
|
||||
float4 parallaxSample3 = tex2Dbias( _Normals, float4( uvsFrame3.zw, 0, depthBias) );
|
||||
float2 parallax3 = ( ( 0.5 - parallaxSample3.a ) * uvsFrame3.xy ) + uvsFrame3.zw;
|
||||
float4 albedo3 = tex2Dbias( _Albedo, float4( parallax3, 0, textureBias) );
|
||||
float4 normals3 = tex2Dbias( _Normals, float4( parallax3, 0, textureBias) );
|
||||
float4 mask3 = tex2Dbias( _Emission, float4( parallax3, 0, textureBias) );
|
||||
float4 spec3 = tex2Dbias( _Specular, float4( parallax3, 0, textureBias) );
|
||||
|
||||
// Weights
|
||||
float2 fraction = frac( octaFrame.xy );
|
||||
float2 invFraction = 1 - fraction;
|
||||
float3 weights;
|
||||
weights.x = min( invFraction.x, invFraction.y );
|
||||
weights.y = abs( fraction.x - fraction.y );
|
||||
weights.z = min( fraction.x, fraction.y );
|
||||
|
||||
// Blends
|
||||
float4 blendedAlbedo = albedo1 * weights.x + albedo2 * weights.y + albedo3 * weights.z;
|
||||
float4 blendedNormal = normals1 * weights.x + normals2 * weights.y + normals3 * weights.z;
|
||||
float4 blendedMask = mask1 * weights.x + mask2 * weights.y + mask3 * weights.z;
|
||||
float4 blendedSpec = spec1 * weights.x + spec2 * weights.y + spec3 * weights.z;
|
||||
|
||||
float3 localNormal = blendedNormal.rgb * 2.0 - 1.0;
|
||||
float3 worldNormal = normalize( mul( unity_ObjectToWorld, float4( localNormal, 0 ) ).xyz );
|
||||
|
||||
float3 viewPos = interpViewPos.xyz;
|
||||
viewPos.z += ( ( parallaxSample1.a * weights.x + parallaxSample2.a * weights.y + parallaxSample3.a * weights.z ) * 2.0 - 1.0) * 0.5 * _DepthSize * length( unity_ObjectToWorld[2].xyz );
|
||||
#ifdef UNITY_PASS_SHADOWCASTER
|
||||
if( _WorldSpaceLightPos0.w == 0 ){
|
||||
viewPos.z += -_ShadowBias * unity_LightShadowBias.y;
|
||||
} else {
|
||||
viewPos.z += -_ShadowBias;
|
||||
}
|
||||
#endif
|
||||
|
||||
worldPos = mul( UNITY_MATRIX_I_V, float4( viewPos.xyz, 1 ) ).xyz;
|
||||
clipPos = mul( UNITY_MATRIX_P, float4( viewPos, 1 ) );
|
||||
#ifdef UNITY_PASS_SHADOWCASTER
|
||||
clipPos = UnityApplyLinearShadowBias( clipPos );
|
||||
#endif
|
||||
clipPos.xyz /= clipPos.w;
|
||||
if( UNITY_NEAR_CLIP_VALUE < 0 )
|
||||
clipPos = clipPos * 0.5 + 0.5;
|
||||
|
||||
#ifdef EFFECT_HUE_VARIATION
|
||||
half3 shiftedColor = lerp(blendedAlbedo.rgb, _HueVariation.rgb, interpViewPos.w);
|
||||
half maxBase = max(blendedAlbedo.r, max(blendedAlbedo.g, blendedAlbedo.b));
|
||||
half newMaxBase = max(shiftedColor.r, max(shiftedColor.g, shiftedColor.b));
|
||||
maxBase /= newMaxBase;
|
||||
maxBase = maxBase * 0.5f + 0.5f;
|
||||
shiftedColor.rgb *= maxBase;
|
||||
blendedAlbedo.rgb = saturate(shiftedColor);
|
||||
#endif
|
||||
|
||||
#if AI_CLIP_NEIGHBOURS_FRAMES
|
||||
float t = ceil( fraction.x - fraction.y );
|
||||
float4 cornerDifference = float4( t, 1 - t, 1, 1 );
|
||||
|
||||
float2 step_1 = ( uvsFrame1.zw - octaFrame.zw ) * _Frames;
|
||||
float4 step23 = ( float4( uvsFrame2.zw, uvsFrame3.zw ) - octaFrame.zwzw ) * _Frames - cornerDifference;
|
||||
|
||||
step_1 = step_1 * (1-step_1);
|
||||
step23 = step23 * (1-step23);
|
||||
|
||||
float3 steps;
|
||||
steps.x = step_1.x * step_1.y;
|
||||
steps.y = step23.x * step23.y;
|
||||
steps.z = step23.z * step23.w;
|
||||
steps = step(-steps, 0);
|
||||
|
||||
float final = dot( steps, weights );
|
||||
|
||||
clip( final - 0.5 );
|
||||
#endif
|
||||
|
||||
o.Albedo = blendedAlbedo.rgb;
|
||||
o.Normal = worldNormal;
|
||||
o.Emission = blendedMask.rgb;
|
||||
o.Specular = blendedSpec.rgb;
|
||||
o.Smoothness = blendedSpec.a;
|
||||
o.Occlusion = blendedMask.a;
|
||||
o.Alpha = ( blendedAlbedo.a - _ClipMask );
|
||||
clip( o.Alpha );
|
||||
}
|
||||
|
||||
inline void SphereImpostorVertex( inout appdata_full v, inout float2 frameUVs, inout float4 viewPos )
|
||||
{
|
||||
// INPUTS
|
||||
float sizeX = _FramesX;
|
||||
float sizeY = _FramesY - 1; // adjusted
|
||||
float3 fractions = 1 / float3( sizeX, _FramesY, sizeY );
|
||||
float2 sizeFraction = fractions.xy;
|
||||
float axisSizeFraction = fractions.z;
|
||||
|
||||
// Basic data
|
||||
v.vertex.xyz += _Offset.xyz;
|
||||
float3 worldOrigin = float3(unity_ObjectToWorld[0].w, unity_ObjectToWorld[1].w, unity_ObjectToWorld[2].w);
|
||||
#if defined(UNITY_PASS_SHADOWCASTER)
|
||||
float3 worldCameraPos = 0;
|
||||
if( unity_LightShadowBias.y == 0.0 ){
|
||||
if( _WorldSpaceLightPos0.w == 1 )
|
||||
worldCameraPos = _WorldSpaceLightPos0.xyz;
|
||||
else
|
||||
worldCameraPos = _WorldSpaceCameraPos;
|
||||
} else {
|
||||
worldCameraPos = UnityWorldSpaceLightDir( mul(unity_ObjectToWorld, v.vertex).xyz ) * -5000.0;
|
||||
}
|
||||
#else
|
||||
float3 worldCameraPos = _WorldSpaceCameraPos;
|
||||
#endif
|
||||
float3 objectCameraDirection = normalize( mul( (float3x3)unity_WorldToObject, worldCameraPos - worldOrigin ) - _Offset.xyz );
|
||||
|
||||
// Create orthogonal vectors to define the billboard
|
||||
float3 upVector = float3( 0,1,0 );
|
||||
float3 objectHorizontalVector = normalize( cross( objectCameraDirection, upVector ) );
|
||||
float3 objectVerticalVector = cross( objectHorizontalVector, objectCameraDirection );
|
||||
|
||||
// Create vertical radial angle
|
||||
float verticalAngle = frac( atan2( -objectCameraDirection.z, -objectCameraDirection.x ) / UNITY_TWO_PI ) * sizeX + 0.5;
|
||||
|
||||
// Create horizontal radial angle
|
||||
float verticalDot = dot( objectCameraDirection, upVector );
|
||||
float upAngle = ( acos( -verticalDot ) / UNITY_PI ) + axisSizeFraction * 0.5f;
|
||||
float yRot = sizeFraction.x * UNITY_PI * verticalDot * ( 2 * frac( verticalAngle ) - 1 );
|
||||
|
||||
// Billboard rotation
|
||||
float2 uvExpansion = v.texcoord.xy - 0.5;
|
||||
float cosY = cos( yRot );
|
||||
float sinY = sin( yRot );
|
||||
float2 uvRotator = mul( uvExpansion, float2x2( cosY , -sinY , sinY , cosY ) ) * _ImpostorSize;
|
||||
|
||||
// Billboard
|
||||
float3 billboard = objectHorizontalVector * uvRotator.x + objectVerticalVector * uvRotator.y + _Offset.xyz;
|
||||
|
||||
// Frame coords
|
||||
float2 relativeCoords = float2( floor( verticalAngle ), min( floor( upAngle * sizeY ), sizeY ) );
|
||||
float2 frameUV = ( v.texcoord.xy + relativeCoords ) * sizeFraction;
|
||||
|
||||
frameUVs.xy = frameUV;
|
||||
viewPos.xyz = UnityObjectToViewPos( billboard );
|
||||
|
||||
#ifdef EFFECT_HUE_VARIATION
|
||||
float hueVariationAmount = frac(unity_ObjectToWorld[0].w + unity_ObjectToWorld[1].w + unity_ObjectToWorld[2].w);
|
||||
viewPos.w = saturate(hueVariationAmount * _HueVariation.a);
|
||||
#endif
|
||||
|
||||
v.vertex.xyz = billboard;
|
||||
v.normal.xyz = objectCameraDirection;
|
||||
}
|
||||
|
||||
inline void SphereImpostorFragment( inout SurfaceOutputStandardSpecular o, out float4 clipPos, out float3 worldPos, float2 frameUV, float4 viewPos )
|
||||
{
|
||||
float4 albedoSample = tex2Dbias( _Albedo, float4( frameUV, 0, _TextureBias) );
|
||||
float4 normalSample = tex2Dbias( _Normals, float4( frameUV, 0, _TextureBias) );
|
||||
float4 specularSample = tex2Dbias( _Specular, float4( frameUV, 0, _TextureBias) );
|
||||
float4 emissionSample = tex2Dbias( _Emission, float4( frameUV, 0, _TextureBias) );
|
||||
|
||||
// Simple outputs
|
||||
float3 albedo = albedoSample.rgb;
|
||||
float3 emission = emissionSample.rgb;
|
||||
float3 specular = specularSample.rgb;
|
||||
float smoothness = specularSample.a;
|
||||
float occlusion = emissionSample.a;
|
||||
float alphaMask = albedoSample.a;
|
||||
|
||||
// Normal
|
||||
float4 remapNormal = normalSample * 2 - 1; // object normal is remapNormal.rgb
|
||||
float3 worldNormal = normalize( mul( (float3x3)unity_ObjectToWorld, remapNormal.xyz ) );
|
||||
|
||||
// Depth
|
||||
float depth = remapNormal.a * _DepthSize * 0.5;
|
||||
#if defined(UNITY_PASS_SHADOWCASTER)
|
||||
if( _WorldSpaceLightPos0.w == 0 ){
|
||||
depth = depth * 0.95 - 0.05 - _ShadowBias * unity_LightShadowBias.y;
|
||||
} else {
|
||||
depth = depth * 0.95 - 0.05 - _ShadowBias;
|
||||
}
|
||||
#endif
|
||||
viewPos.z += depth;
|
||||
|
||||
// Modified clip position and world position
|
||||
worldPos = mul( UNITY_MATRIX_I_V, float4( viewPos.xyz, 1 ) ).xyz;
|
||||
|
||||
clipPos = mul( UNITY_MATRIX_P, float4( viewPos.xyz, 1 ) );
|
||||
#ifdef UNITY_PASS_SHADOWCASTER
|
||||
clipPos = UnityApplyLinearShadowBias( clipPos );
|
||||
#endif
|
||||
clipPos.xyz /= clipPos.w;
|
||||
if( UNITY_NEAR_CLIP_VALUE < 0 )
|
||||
clipPos = clipPos * 0.5 + 0.5;
|
||||
|
||||
#ifdef EFFECT_HUE_VARIATION
|
||||
half3 shiftedColor = lerp(albedo.rgb, _HueVariation.rgb, viewPos.w);
|
||||
half maxBase = max(albedo.r, max(albedo.g, albedo.b));
|
||||
half newMaxBase = max(shiftedColor.r, max(shiftedColor.g, shiftedColor.b));
|
||||
maxBase /= newMaxBase;
|
||||
maxBase = maxBase * 0.5f + 0.5f;
|
||||
shiftedColor.rgb *= maxBase;
|
||||
albedo.rgb = saturate(shiftedColor);
|
||||
#endif
|
||||
|
||||
o.Albedo = albedo;
|
||||
o.Normal = worldNormal;
|
||||
o.Emission = emission;
|
||||
o.Specular = specular;
|
||||
o.Smoothness = smoothness;
|
||||
o.Occlusion = occlusion;
|
||||
o.Alpha = ( alphaMask - _ClipMask );
|
||||
clip( o.Alpha );
|
||||
}
|
||||
#endif
|
10
Assets/RaceTracksPack/Shaders/AIBillboard.cginc.meta
Normal file
10
Assets/RaceTracksPack/Shaders/AIBillboard.cginc.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bb2ad5b6d70af4dfebed60a9298b34da
|
||||
timeCreated: 1543339941
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,32 @@
|
||||
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
|
||||
|
||||
Shader "Legacy Shaders/Transparent/Diffuse double sided" {
|
||||
Properties {
|
||||
_Color ("Main Color", Color) = (1,1,1,1)
|
||||
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
|
||||
}
|
||||
|
||||
SubShader { Cull Off
|
||||
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
|
||||
LOD 200
|
||||
|
||||
CGPROGRAM
|
||||
#pragma surface surf Lambert alpha:fade
|
||||
|
||||
sampler2D _MainTex;
|
||||
fixed4 _Color;
|
||||
|
||||
struct Input {
|
||||
float2 uv_MainTex;
|
||||
};
|
||||
|
||||
void surf (Input IN, inout SurfaceOutput o) {
|
||||
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
|
||||
o.Albedo = c.rgb;
|
||||
o.Alpha = c.a;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Fallback "Legacy Shaders/Transparent/VertexLit"
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 25cea0ce7c734d64b808303f8409853e
|
||||
timeCreated: 1531407734
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
695
Assets/RaceTracksPack/Shaders/BillboardShader.shader
Normal file
695
Assets/RaceTracksPack/Shaders/BillboardShader.shader
Normal file
@ -0,0 +1,695 @@
|
||||
|
||||
Shader "Hidden/AI BILLBOARD"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[HideInInspector]
|
||||
[NoScaleOffset]_Albedo("Albedo & Alpha", 2D) = "white" {}
|
||||
[HideInInspector]
|
||||
[NoScaleOffset]_Normals("Normals & Depth", 2D) = "white" {}
|
||||
[HideInInspector]
|
||||
[NoScaleOffset]_Specular("Specular & Smoothness", 2D) = "black" {}
|
||||
[HideInInspector]
|
||||
[NoScaleOffset]_Emission("Emission & Occlusion", 2D) = "black" {}
|
||||
[HideInInspector]
|
||||
[HideInInspector]_Frames("Frames", Float) = 16
|
||||
|
||||
[HideInInspector]_ImpostorSize("Impostor Size", Float) = 1
|
||||
[HideInInspector]_Offset("Offset", Vector) = (0,0,0,0)
|
||||
[HideInInspector]
|
||||
_TextureBias("Texture Bias", Float) = -1
|
||||
[HideInInspector]
|
||||
_Parallax("Parallax", Range( -1 , 1)) = 1
|
||||
[HideInInspector]_DepthSize("DepthSize", Float) = 1
|
||||
[HideInInspector]
|
||||
_ClipMask("Clip", Range( 0 , 1)) = 0.5
|
||||
[HideInInspector]
|
||||
_ShadowBias("Shadow Bias", Range( 0 , 2)) = 0.25
|
||||
[HideInInspector]
|
||||
[Toggle(_HEMI_ON)] _Hemi("Hemi", Float) = 0
|
||||
[HideInInspector]
|
||||
[Toggle(EFFECT_HUE_VARIATION)] _Hue("Use SpeedTree Hue", Float) = 0
|
||||
[HideInInspector]
|
||||
_HueVariation("Hue Variation", Color) = (0,0,0,0)
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
CGINCLUDE
|
||||
#pragma target 3.0
|
||||
#define UNITY_SAMPLE_FULL_SH_PER_PIXEL 1
|
||||
ENDCG
|
||||
|
||||
Tags { "RenderType"="Opaque" "Queue"="Geometry" "DisableBatching"="True" }
|
||||
Cull Back
|
||||
|
||||
Pass
|
||||
{
|
||||
ZWrite On
|
||||
Name "ForwardBase"
|
||||
Tags { "LightMode"="ForwardBase" }
|
||||
|
||||
CGPROGRAM
|
||||
// compile directives
|
||||
#pragma vertex vert_surf
|
||||
#pragma fragment frag_surf
|
||||
#pragma multi_compile_fog
|
||||
#pragma multi_compile_fwdbase
|
||||
#pragma multi_compile_instancing
|
||||
#pragma multi_compile __ LOD_FADE_CROSSFADE
|
||||
#include "HLSLSupport.cginc"
|
||||
#if !defined( UNITY_INSTANCED_LOD_FADE )
|
||||
#define UNITY_INSTANCED_LOD_FADE
|
||||
#endif
|
||||
#if !defined( UNITY_INSTANCED_SH )
|
||||
#define UNITY_INSTANCED_SH
|
||||
#endif
|
||||
#if !defined( UNITY_INSTANCED_LIGHTMAPSTS )
|
||||
#define UNITY_INSTANCED_LIGHTMAPSTS
|
||||
#endif
|
||||
#include "UnityShaderVariables.cginc"
|
||||
#include "UnityShaderUtilities.cginc"
|
||||
#ifndef UNITY_PASS_FORWARDBASE
|
||||
#define UNITY_PASS_FORWARDBASE
|
||||
#endif
|
||||
#include "UnityCG.cginc"
|
||||
#include "Lighting.cginc"
|
||||
#include "UnityPBSLighting.cginc"
|
||||
#include "AutoLight.cginc"
|
||||
#include "UnityStandardUtils.cginc"
|
||||
|
||||
#include "AIBillboard.cginc"
|
||||
|
||||
#pragma shader_feature _HEMI_ON
|
||||
#pragma shader_feature EFFECT_HUE_VARIATION
|
||||
|
||||
struct v2f_surf {
|
||||
UNITY_POSITION(pos);
|
||||
#ifndef LIGHTMAP_ON
|
||||
#if SHADER_TARGET >= 30
|
||||
float4 lmap : TEXCOORD1;
|
||||
#endif
|
||||
#if UNITY_SHOULD_SAMPLE_SH
|
||||
half3 sh : TEXCOORD2;
|
||||
#endif
|
||||
#endif
|
||||
#ifdef LIGHTMAP_ON
|
||||
float4 lmap : TEXCOORD1;
|
||||
#endif
|
||||
float4 uvsFrame1 : TEXCOORD5;
|
||||
float4 uvsFrame2 : TEXCOORD6;
|
||||
float4 uvsFrame3 : TEXCOORD7;
|
||||
float4 octaFrame : TEXCOORD8;
|
||||
float4 viewPos : TEXCOORD9;
|
||||
UNITY_SHADOW_COORDS(3)
|
||||
UNITY_FOG_COORDS(4)
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
|
||||
v2f_surf vert_surf (appdata_full v ) {
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
v2f_surf o;
|
||||
UNITY_INITIALIZE_OUTPUT(v2f_surf,o);
|
||||
UNITY_TRANSFER_INSTANCE_ID(v,o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
OctaImpostorVertex( v, o.uvsFrame1, o.uvsFrame2, o.uvsFrame3, o.octaFrame, o.viewPos );
|
||||
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
|
||||
float3 worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
|
||||
fixed3 worldNormal = UnityObjectToWorldNormal(v.normal);
|
||||
#ifdef DYNAMICLIGHTMAP_ON
|
||||
o.lmap.zw = v.texcoord2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;
|
||||
#endif
|
||||
#ifdef LIGHTMAP_ON
|
||||
o.lmap.xy = v.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
|
||||
#endif
|
||||
|
||||
#ifndef LIGHTMAP_ON
|
||||
#if UNITY_SHOULD_SAMPLE_SH && !UNITY_SAMPLE_FULL_SH_PER_PIXEL
|
||||
o.sh = 0;
|
||||
#ifdef VERTEXLIGHT_ON
|
||||
o.sh += Shade4PointLights (
|
||||
unity_4LightPosX0, unity_4LightPosY0, unity_4LightPosZ0,
|
||||
unity_LightColor[0].rgb, unity_LightColor[1].rgb, unity_LightColor[2].rgb, unity_LightColor[3].rgb,
|
||||
unity_4LightAtten0, worldPos, worldNormal);
|
||||
#endif
|
||||
o.sh = ShadeSHPerVertex (worldNormal, o.sh);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
UNITY_TRANSFER_SHADOW(o, v.texcoord1.xy);
|
||||
UNITY_TRANSFER_FOG(o,o.pos);
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag_surf (v2f_surf IN, out float outDepth : SV_Depth ) : SV_Target {
|
||||
UNITY_SETUP_INSTANCE_ID(IN);
|
||||
#ifdef UNITY_COMPILER_HLSL
|
||||
SurfaceOutputStandardSpecular o = (SurfaceOutputStandardSpecular)0;
|
||||
#else
|
||||
SurfaceOutputStandardSpecular o;
|
||||
#endif
|
||||
|
||||
float4 clipPos;
|
||||
float3 worldPos;
|
||||
OctaImpostorFragment( o, clipPos, worldPos, IN.uvsFrame1, IN.uvsFrame2, IN.uvsFrame3, IN.octaFrame, IN.viewPos );
|
||||
|
||||
outDepth = clipPos.z;
|
||||
|
||||
#ifndef USING_DIRECTIONAL_LIGHT
|
||||
fixed3 lightDir = normalize(UnityWorldSpaceLightDir(worldPos));
|
||||
#else
|
||||
fixed3 lightDir = _WorldSpaceLightPos0.xyz;
|
||||
#endif
|
||||
|
||||
fixed3 worldViewDir = normalize(UnityWorldSpaceViewDir(worldPos));
|
||||
|
||||
UNITY_APPLY_DITHER_CROSSFADE(IN.pos.xy);
|
||||
IN.pos = clipPos;
|
||||
UNITY_LIGHT_ATTENUATION(atten, IN, worldPos)
|
||||
fixed4 c = 0;
|
||||
|
||||
UnityGI gi;
|
||||
UNITY_INITIALIZE_OUTPUT(UnityGI, gi);
|
||||
gi.indirect.diffuse = 0;
|
||||
gi.indirect.specular = 0;
|
||||
gi.light.color = _LightColor0.rgb;
|
||||
gi.light.dir = lightDir;
|
||||
|
||||
UnityGIInput giInput;
|
||||
UNITY_INITIALIZE_OUTPUT(UnityGIInput, giInput);
|
||||
giInput.light = gi.light;
|
||||
giInput.worldPos = worldPos;
|
||||
giInput.worldViewDir = worldViewDir;
|
||||
giInput.atten = atten;
|
||||
#if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON)
|
||||
giInput.lightmapUV = IN.lmap;
|
||||
#else
|
||||
giInput.lightmapUV = 0.0;
|
||||
#endif
|
||||
#if UNITY_SHOULD_SAMPLE_SH && !UNITY_SAMPLE_FULL_SH_PER_PIXEL
|
||||
giInput.ambient = IN.sh;
|
||||
#else
|
||||
giInput.ambient.rgb = 0.0;
|
||||
#endif
|
||||
giInput.probeHDR[0] = unity_SpecCube0_HDR;
|
||||
giInput.probeHDR[1] = unity_SpecCube1_HDR;
|
||||
#if UNITY_SPECCUBE_BLENDING || UNITY_SPECCUBE_BOX_PROJECTION
|
||||
giInput.boxMin[0] = unity_SpecCube0_BoxMin;
|
||||
#endif
|
||||
#if UNITY_SPECCUBE_BOX_PROJECTION
|
||||
giInput.boxMax[0] = unity_SpecCube0_BoxMax;
|
||||
giInput.probePosition[0] = unity_SpecCube0_ProbePosition;
|
||||
giInput.boxMax[1] = unity_SpecCube1_BoxMax;
|
||||
giInput.boxMin[1] = unity_SpecCube1_BoxMin;
|
||||
giInput.probePosition[1] = unity_SpecCube1_ProbePosition;
|
||||
#endif
|
||||
|
||||
LightingStandardSpecular_GI(o, giInput, gi);
|
||||
|
||||
c += LightingStandardSpecular (o, worldViewDir, gi);
|
||||
c.rgb += o.Emission;
|
||||
//UNITY_TRANSFER_FOG(IN,IN.pos);
|
||||
UNITY_APPLY_FOG(IN.fogCoord, c);
|
||||
return c;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "ForwardAdd"
|
||||
Tags { "LightMode"="ForwardAdd" }
|
||||
ZWrite Off
|
||||
Blend One One
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert_surf
|
||||
#pragma fragment frag_surf
|
||||
#pragma multi_compile_fog
|
||||
#pragma multi_compile_instancing
|
||||
#pragma multi_compile_fwdadd_fullshadows
|
||||
#pragma multi_compile __ LOD_FADE_CROSSFADE
|
||||
#pragma skip_variants INSTANCING_ON
|
||||
#include "HLSLSupport.cginc"
|
||||
#if !defined( UNITY_INSTANCED_LOD_FADE )
|
||||
#define UNITY_INSTANCED_LOD_FADE
|
||||
#endif
|
||||
#if !defined( UNITY_INSTANCED_SH )
|
||||
#define UNITY_INSTANCED_SH
|
||||
#endif
|
||||
#if !defined( UNITY_INSTANCED_LIGHTMAPSTS )
|
||||
#define UNITY_INSTANCED_LIGHTMAPSTS
|
||||
#endif
|
||||
#include "UnityShaderVariables.cginc"
|
||||
#include "UnityShaderUtilities.cginc"
|
||||
#ifndef UNITY_PASS_FORWARDADD
|
||||
#define UNITY_PASS_FORWARDADD
|
||||
#endif
|
||||
#include "UnityCG.cginc"
|
||||
#include "Lighting.cginc"
|
||||
#include "UnityPBSLighting.cginc"
|
||||
#include "AutoLight.cginc"
|
||||
#include "UnityStandardUtils.cginc"
|
||||
|
||||
#include "AIBillboard.cginc"
|
||||
|
||||
#pragma shader_feature _HEMI_ON
|
||||
#pragma shader_feature EFFECT_HUE_VARIATION
|
||||
|
||||
struct v2f_surf {
|
||||
UNITY_POSITION(pos);
|
||||
UNITY_SHADOW_COORDS(1)
|
||||
UNITY_FOG_COORDS(2)
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
float4 uvsFrame1 : TEXCOORD5;
|
||||
float4 uvsFrame2 : TEXCOORD6;
|
||||
float4 uvsFrame3 : TEXCOORD7;
|
||||
float4 octaFrame : TEXCOORD8;
|
||||
float4 viewPos : TEXCOORD9;
|
||||
};
|
||||
|
||||
v2f_surf vert_surf (appdata_full v ) {
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
v2f_surf o;
|
||||
UNITY_INITIALIZE_OUTPUT(v2f_surf,o);
|
||||
UNITY_TRANSFER_INSTANCE_ID(v,o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
OctaImpostorVertex( v, o.uvsFrame1, o.uvsFrame2, o.uvsFrame3, o.octaFrame, o.viewPos );
|
||||
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
|
||||
UNITY_TRANSFER_SHADOW(o, v.texcoord1.xy);
|
||||
UNITY_TRANSFER_FOG(o,o.pos);
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag_surf (v2f_surf IN, out float outDepth : SV_Depth ) : SV_Target {
|
||||
UNITY_SETUP_INSTANCE_ID(IN);
|
||||
#ifdef UNITY_COMPILER_HLSL
|
||||
SurfaceOutputStandardSpecular o = (SurfaceOutputStandardSpecular)0;
|
||||
#else
|
||||
SurfaceOutputStandardSpecular o;
|
||||
#endif
|
||||
float4 clipPos;
|
||||
float3 worldPos;
|
||||
OctaImpostorFragment( o, clipPos, worldPos, IN.uvsFrame1, IN.uvsFrame2, IN.uvsFrame3, IN.octaFrame, IN.viewPos );
|
||||
|
||||
outDepth = clipPos.z;
|
||||
|
||||
#ifndef USING_DIRECTIONAL_LIGHT
|
||||
fixed3 lightDir = normalize(UnityWorldSpaceLightDir(worldPos));
|
||||
#else
|
||||
fixed3 lightDir = _WorldSpaceLightPos0.xyz;
|
||||
#endif
|
||||
|
||||
fixed3 worldViewDir = normalize(UnityWorldSpaceViewDir(worldPos));
|
||||
|
||||
UNITY_APPLY_DITHER_CROSSFADE(IN.pos.xy);
|
||||
IN.pos = clipPos;
|
||||
UNITY_LIGHT_ATTENUATION(atten, IN, worldPos)
|
||||
fixed4 c = 0;
|
||||
|
||||
UnityGI gi;
|
||||
UNITY_INITIALIZE_OUTPUT(UnityGI, gi);
|
||||
gi.indirect.diffuse = 0;
|
||||
gi.indirect.specular = 0;
|
||||
gi.light.color = _LightColor0.rgb;
|
||||
gi.light.dir = lightDir;
|
||||
gi.light.color *= atten;
|
||||
c += LightingStandardSpecular (o, worldViewDir, gi);
|
||||
//UNITY_TRANSFER_FOG(IN,IN.pos);
|
||||
UNITY_APPLY_FOG(IN.fogCoord, c);
|
||||
return c;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Deferred"
|
||||
Tags { "LightMode"="Deferred" }
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert_surf
|
||||
#pragma fragment frag_surf
|
||||
#pragma multi_compile_instancing
|
||||
#pragma multi_compile __ LOD_FADE_CROSSFADE
|
||||
#pragma exclude_renderers nomrt
|
||||
#pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2
|
||||
#pragma multi_compile_prepassfinal
|
||||
#include "HLSLSupport.cginc"
|
||||
#if !defined( UNITY_INSTANCED_LOD_FADE )
|
||||
#define UNITY_INSTANCED_LOD_FADE
|
||||
#endif
|
||||
#if !defined( UNITY_INSTANCED_SH )
|
||||
#define UNITY_INSTANCED_SH
|
||||
#endif
|
||||
#if !defined( UNITY_INSTANCED_LIGHTMAPSTS )
|
||||
#define UNITY_INSTANCED_LIGHTMAPSTS
|
||||
#endif
|
||||
#include "UnityShaderVariables.cginc"
|
||||
#include "UnityShaderUtilities.cginc"
|
||||
#ifndef UNITY_PASS_DEFERRED
|
||||
#define UNITY_PASS_DEFERRED
|
||||
#endif
|
||||
#include "UnityCG.cginc"
|
||||
#include "Lighting.cginc"
|
||||
#include "UnityPBSLighting.cginc"
|
||||
#include "UnityStandardUtils.cginc"
|
||||
|
||||
#include "AIBillboard.cginc"
|
||||
|
||||
#pragma shader_feature _HEMI_ON
|
||||
#pragma shader_feature EFFECT_HUE_VARIATION
|
||||
|
||||
#ifdef LIGHTMAP_ON
|
||||
float4 unity_LightmapFade;
|
||||
#endif
|
||||
fixed4 unity_Ambient;
|
||||
|
||||
struct v2f_surf {
|
||||
UNITY_POSITION(pos);
|
||||
#ifndef DIRLIGHTMAP_OFF
|
||||
half3 viewDir : TEXCOORD1;
|
||||
#endif
|
||||
float4 lmap : TEXCOORD2;
|
||||
#ifndef LIGHTMAP_ON
|
||||
#if UNITY_SHOULD_SAMPLE_SH && !UNITY_SAMPLE_FULL_SH_PER_PIXEL
|
||||
half3 sh : TEXCOORD3;
|
||||
#endif
|
||||
#else
|
||||
#ifdef DIRLIGHTMAP_OFF
|
||||
float4 lmapFadePos : TEXCOORD4;
|
||||
#endif
|
||||
#endif
|
||||
float4 uvsFrame1 : TEXCOORD5;
|
||||
float4 uvsFrame2 : TEXCOORD6;
|
||||
float4 uvsFrame3 : TEXCOORD7;
|
||||
float4 octaFrame : TEXCOORD8;
|
||||
float4 viewPos : TEXCOORD9;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f_surf vert_surf (appdata_full v ) {
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
v2f_surf o;
|
||||
UNITY_INITIALIZE_OUTPUT(v2f_surf,o);
|
||||
UNITY_TRANSFER_INSTANCE_ID(v,o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
OctaImpostorVertex( v, o.uvsFrame1, o.uvsFrame2, o.uvsFrame3, o.octaFrame, o.viewPos );
|
||||
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
|
||||
float3 worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
|
||||
fixed3 worldNormal = UnityObjectToWorldNormal(v.normal);
|
||||
float3 viewDirForLight = UnityWorldSpaceViewDir(worldPos);
|
||||
#ifndef DIRLIGHTMAP_OFF
|
||||
o.viewDir = viewDirForLight;
|
||||
#endif
|
||||
#ifdef DYNAMICLIGHTMAP_ON
|
||||
o.lmap.zw = v.texcoord2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;
|
||||
#else
|
||||
o.lmap.zw = 0;
|
||||
#endif
|
||||
#ifdef LIGHTMAP_ON
|
||||
o.lmap.xy = v.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
|
||||
#ifdef DIRLIGHTMAP_OFF
|
||||
o.lmapFadePos.xyz = (mul(unity_ObjectToWorld, v.vertex).xyz - unity_ShadowFadeCenterAndType.xyz) * unity_ShadowFadeCenterAndType.w;
|
||||
o.lmapFadePos.w = (-UnityObjectToViewPos(v.vertex).z) * (1.0 - unity_ShadowFadeCenterAndType.w);
|
||||
#endif
|
||||
#else
|
||||
o.lmap.xy = 0;
|
||||
#if UNITY_SHOULD_SAMPLE_SH && !UNITY_SAMPLE_FULL_SH_PER_PIXEL
|
||||
o.sh = 0;
|
||||
o.sh = ShadeSHPerVertex (worldNormal, o.sh);
|
||||
#endif
|
||||
#endif
|
||||
return o;
|
||||
}
|
||||
|
||||
void frag_surf (v2f_surf IN , out half4 outGBuffer0 : SV_Target0, out half4 outGBuffer1 : SV_Target1, out half4 outGBuffer2 : SV_Target2, out half4 outEmission : SV_Target3
|
||||
#if defined(SHADOWS_SHADOWMASK) && (UNITY_ALLOWED_MRT_COUNT > 4)
|
||||
, out half4 outShadowMask : SV_Target4
|
||||
#endif
|
||||
, out float outDepth : SV_Depth
|
||||
) {
|
||||
UNITY_SETUP_INSTANCE_ID(IN);
|
||||
#ifdef UNITY_COMPILER_HLSL
|
||||
SurfaceOutputStandardSpecular o = (SurfaceOutputStandardSpecular)0;
|
||||
#else
|
||||
SurfaceOutputStandardSpecular o;
|
||||
#endif
|
||||
|
||||
float4 clipPos;
|
||||
float3 worldPos;
|
||||
OctaImpostorFragment( o, clipPos, worldPos, IN.uvsFrame1, IN.uvsFrame2, IN.uvsFrame3, IN.octaFrame, IN.viewPos );
|
||||
|
||||
outDepth = clipPos.z;
|
||||
|
||||
#ifndef USING_DIRECTIONAL_LIGHT
|
||||
fixed3 lightDir = normalize(UnityWorldSpaceLightDir(worldPos));
|
||||
#else
|
||||
fixed3 lightDir = _WorldSpaceLightPos0.xyz;
|
||||
#endif
|
||||
|
||||
fixed3 worldViewDir = normalize(UnityWorldSpaceViewDir(worldPos));
|
||||
|
||||
UNITY_APPLY_DITHER_CROSSFADE(IN.pos.xy);
|
||||
IN.pos = clipPos;
|
||||
half atten = 1;
|
||||
|
||||
UnityGI gi;
|
||||
UNITY_INITIALIZE_OUTPUT(UnityGI, gi);
|
||||
gi.indirect.diffuse = 0;
|
||||
gi.indirect.specular = 0;
|
||||
gi.light.color = 0;
|
||||
gi.light.dir = half3(0,1,0);
|
||||
|
||||
UnityGIInput giInput;
|
||||
UNITY_INITIALIZE_OUTPUT(UnityGIInput, giInput);
|
||||
giInput.light = gi.light;
|
||||
giInput.worldPos = worldPos;
|
||||
giInput.worldViewDir = worldViewDir;
|
||||
giInput.atten = atten;
|
||||
#if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON)
|
||||
giInput.lightmapUV = IN.lmap;
|
||||
#else
|
||||
giInput.lightmapUV = 0.0;
|
||||
#endif
|
||||
#if UNITY_SHOULD_SAMPLE_SH && !UNITY_SAMPLE_FULL_SH_PER_PIXEL
|
||||
giInput.ambient = IN.sh;
|
||||
#else
|
||||
giInput.ambient.rgb = 0.0;
|
||||
#endif
|
||||
giInput.probeHDR[0] = unity_SpecCube0_HDR;
|
||||
giInput.probeHDR[1] = unity_SpecCube1_HDR;
|
||||
#if defined(UNITY_SPECCUBE_BLENDING) || defined(UNITY_SPECCUBE_BOX_PROJECTION)
|
||||
giInput.boxMin[0] = unity_SpecCube0_BoxMin;
|
||||
#endif
|
||||
#ifdef UNITY_SPECCUBE_BOX_PROJECTION
|
||||
giInput.boxMax[0] = unity_SpecCube0_BoxMax;
|
||||
giInput.probePosition[0] = unity_SpecCube0_ProbePosition;
|
||||
giInput.boxMax[1] = unity_SpecCube1_BoxMax;
|
||||
giInput.boxMin[1] = unity_SpecCube1_BoxMin;
|
||||
giInput.probePosition[1] = unity_SpecCube1_ProbePosition;
|
||||
#endif
|
||||
LightingStandardSpecular_GI(o, giInput, gi);
|
||||
|
||||
outEmission = LightingStandardSpecular_Deferred (o, worldViewDir, gi, outGBuffer0, outGBuffer1, outGBuffer2);
|
||||
#if defined(SHADOWS_SHADOWMASK) && (UNITY_ALLOWED_MRT_COUNT > 4)
|
||||
outShadowMask = UnityGetRawBakedOcclusions (IN.lmap.xy, float3(0, 0, 0));
|
||||
#endif
|
||||
#ifndef UNITY_HDR_ON
|
||||
outEmission.rgb = exp2(-outEmission.rgb);
|
||||
#endif
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Meta"
|
||||
Tags { "LightMode"="Meta" }
|
||||
Cull Off
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert_surf
|
||||
#pragma fragment frag_surf
|
||||
#pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2
|
||||
#pragma skip_variants INSTANCING_ON
|
||||
#pragma shader_feature EDITOR_VISUALIZATION
|
||||
//#pragma multi_compile_instancing
|
||||
|
||||
#include "HLSLSupport.cginc"
|
||||
#if !defined( UNITY_INSTANCED_LOD_FADE )
|
||||
#define UNITY_INSTANCED_LOD_FADE
|
||||
#endif
|
||||
#if !defined( UNITY_INSTANCED_SH )
|
||||
#define UNITY_INSTANCED_SH
|
||||
#endif
|
||||
#if !defined( UNITY_INSTANCED_LIGHTMAPSTS )
|
||||
#define UNITY_INSTANCED_LIGHTMAPSTS
|
||||
#endif
|
||||
#include "UnityShaderVariables.cginc"
|
||||
#include "UnityShaderUtilities.cginc"
|
||||
#ifndef UNITY_PASS_META
|
||||
#define UNITY_PASS_META
|
||||
#endif
|
||||
#include "UnityCG.cginc"
|
||||
#include "Lighting.cginc"
|
||||
#include "UnityPBSLighting.cginc"
|
||||
#include "UnityStandardUtils.cginc"
|
||||
#include "UnityMetaPass.cginc"
|
||||
|
||||
#include "AIBillboard.cginc"
|
||||
|
||||
#pragma shader_feature _HEMI_ON
|
||||
#pragma shader_feature EFFECT_HUE_VARIATION
|
||||
|
||||
struct v2f_surf {
|
||||
UNITY_POSITION(pos);
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
float4 uvsFrame1 : TEXCOORD5;
|
||||
float4 uvsFrame2 : TEXCOORD6;
|
||||
float4 uvsFrame3 : TEXCOORD7;
|
||||
float4 octaFrame : TEXCOORD8;
|
||||
float4 viewPos : TEXCOORD9;
|
||||
};
|
||||
|
||||
v2f_surf vert_surf (appdata_full v ) {
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
v2f_surf o;
|
||||
UNITY_INITIALIZE_OUTPUT(v2f_surf,o);
|
||||
UNITY_TRANSFER_INSTANCE_ID(v,o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
OctaImpostorVertex( v, o.uvsFrame1, o.uvsFrame2, o.uvsFrame3, o.octaFrame, o.viewPos );
|
||||
|
||||
o.pos = UnityMetaVertexPosition(v.vertex, v.texcoord1.xy, v.texcoord2.xy, unity_LightmapST, unity_DynamicLightmapST);
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag_surf (v2f_surf IN, out float outDepth : SV_Depth ) : SV_Target {
|
||||
UNITY_SETUP_INSTANCE_ID(IN);
|
||||
#ifdef UNITY_COMPILER_HLSL
|
||||
SurfaceOutputStandardSpecular o = (SurfaceOutputStandardSpecular)0;
|
||||
#else
|
||||
SurfaceOutputStandardSpecular o;
|
||||
#endif
|
||||
|
||||
float4 clipPos;
|
||||
float3 worldPos;
|
||||
OctaImpostorFragment( o, clipPos, worldPos, IN.uvsFrame1, IN.uvsFrame2, IN.uvsFrame3, IN.octaFrame, IN.viewPos );
|
||||
|
||||
outDepth = clipPos.z;
|
||||
|
||||
#ifndef USING_DIRECTIONAL_LIGHT
|
||||
fixed3 lightDir = normalize(UnityWorldSpaceLightDir(worldPos));
|
||||
#else
|
||||
fixed3 lightDir = _WorldSpaceLightPos0.xyz;
|
||||
#endif
|
||||
|
||||
fixed3 worldViewDir = normalize(UnityWorldSpaceViewDir(worldPos));
|
||||
|
||||
UNITY_APPLY_DITHER_CROSSFADE(IN.pos.xy);
|
||||
IN.pos = clipPos;
|
||||
|
||||
UnityMetaInput metaIN;
|
||||
UNITY_INITIALIZE_OUTPUT(UnityMetaInput, metaIN);
|
||||
metaIN.Albedo = o.Albedo;
|
||||
metaIN.Emission = o.Emission;
|
||||
return UnityMetaFragment(metaIN);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "ShadowCaster"
|
||||
Tags { "LightMode"="ShadowCaster" }
|
||||
ZWrite On
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert_surf
|
||||
#pragma fragment frag_surf
|
||||
#pragma multi_compile_shadowcaster
|
||||
#pragma multi_compile __ LOD_FADE_CROSSFADE
|
||||
#ifndef UNITY_PASS_SHADOWCASTER
|
||||
#define UNITY_PASS_SHADOWCASTER
|
||||
#endif
|
||||
#pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2
|
||||
#pragma multi_compile_instancing
|
||||
#include "HLSLSupport.cginc"
|
||||
#if !defined( UNITY_INSTANCED_LOD_FADE )
|
||||
#define UNITY_INSTANCED_LOD_FADE
|
||||
#endif
|
||||
#include "UnityShaderVariables.cginc"
|
||||
#include "UnityShaderUtilities.cginc"
|
||||
#include "UnityCG.cginc"
|
||||
#include "Lighting.cginc"
|
||||
#include "UnityPBSLighting.cginc"
|
||||
#include "UnityStandardUtils.cginc"
|
||||
|
||||
#include "AIBillboard.cginc"
|
||||
|
||||
#pragma shader_feature _HEMI_ON
|
||||
#pragma shader_feature EFFECT_HUE_VARIATION
|
||||
|
||||
struct v2f_surf {
|
||||
V2F_SHADOW_CASTER;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
float4 uvsFrame1 : TEXCOORD5;
|
||||
float4 uvsFrame2 : TEXCOORD6;
|
||||
float4 uvsFrame3 : TEXCOORD7;
|
||||
float4 octaFrame : TEXCOORD8;
|
||||
float4 viewPos : TEXCOORD9;
|
||||
};
|
||||
|
||||
v2f_surf vert_surf (appdata_full v) {
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
v2f_surf o;
|
||||
UNITY_INITIALIZE_OUTPUT(v2f_surf,o);
|
||||
UNITY_TRANSFER_INSTANCE_ID(v,o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
OctaImpostorVertex( v, o.uvsFrame1, o.uvsFrame2, o.uvsFrame3, o.octaFrame, o.viewPos );
|
||||
|
||||
TRANSFER_SHADOW_CASTER_NORMALOFFSET(o)
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag_surf (v2f_surf IN, out float outDepth : SV_Depth ) : SV_Target {
|
||||
UNITY_SETUP_INSTANCE_ID(IN);
|
||||
#ifdef UNITY_COMPILER_HLSL
|
||||
SurfaceOutputStandardSpecular o = (SurfaceOutputStandardSpecular)0;
|
||||
#else
|
||||
SurfaceOutputStandardSpecular o;
|
||||
#endif
|
||||
|
||||
float4 clipPos;
|
||||
float3 worldPos;
|
||||
OctaImpostorFragment( o, clipPos, worldPos, IN.uvsFrame1, IN.uvsFrame2, IN.uvsFrame3, IN.octaFrame, IN.viewPos );
|
||||
|
||||
outDepth = clipPos.z;
|
||||
|
||||
UNITY_APPLY_DITHER_CROSSFADE(IN.pos.xy);
|
||||
IN.pos = clipPos;
|
||||
SHADOW_CASTER_FRAGMENT(IN)
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
Fallback "Diffuse"
|
||||
}
|
10
Assets/RaceTracksPack/Shaders/BillboardShader.shader.meta
Normal file
10
Assets/RaceTracksPack/Shaders/BillboardShader.shader.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 572f9be5706148142b8da6e9de53acdb
|
||||
timeCreated: 1521828552
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
454
Assets/RaceTracksPack/Shaders/Billboards.cginc
Normal file
454
Assets/RaceTracksPack/Shaders/Billboards.cginc
Normal file
@ -0,0 +1,454 @@
|
||||
|
||||
#ifndef BILLBOARDS_INCLUDED
|
||||
#define BILLBOARDS_INCLUDED
|
||||
|
||||
#define AI_CLIP_NEIGHBOURS_FRAMES 0
|
||||
|
||||
float2 VectortoOctahedron( float3 N )
|
||||
{
|
||||
N /= dot( 1.0, abs(N) );
|
||||
if( N.z <= 0 )
|
||||
{
|
||||
N.xy = ( 1 - abs(N.yx) ) * ( N.xy >= 0 ? 1.0 : -1.0 );
|
||||
}
|
||||
return N.xy;
|
||||
}
|
||||
|
||||
float2 VectortoHemiOctahedron( float3 N )
|
||||
{
|
||||
N.xy /= dot( 1.0, abs(N) );
|
||||
return float2( N.x + N.y, N.x - N.y );
|
||||
}
|
||||
|
||||
float3 OctahedronToVector( float2 Oct )
|
||||
{
|
||||
float3 N = float3( Oct, 1.0 - dot( 1.0, abs(Oct) ) );
|
||||
if( N.z < 0 )
|
||||
{
|
||||
N.xy = ( 1 - abs(N.yx) ) * ( N.xy >= 0 ? 1.0 : -1.0 );
|
||||
}
|
||||
return normalize(N);
|
||||
}
|
||||
|
||||
float3 HemiOctahedronToVector( float2 Oct )
|
||||
{
|
||||
Oct = float2( Oct.x + Oct.y, Oct.x - Oct.y ) *0.5;
|
||||
float3 N = float3( Oct, 1 - dot( 1.0, abs(Oct) ) );
|
||||
return normalize(N);
|
||||
}
|
||||
|
||||
uniform float _FramesX;
|
||||
uniform float _FramesY;
|
||||
uniform float _Frames;
|
||||
uniform float _ImpostorSize;
|
||||
uniform float _Parallax;
|
||||
uniform sampler2D _Albedo;
|
||||
uniform sampler2D _Normals;
|
||||
uniform sampler2D _Specular;
|
||||
uniform sampler2D _Emission;
|
||||
uniform float _TextureBias;
|
||||
uniform float _ClipMask;
|
||||
uniform float _DepthSize;
|
||||
uniform float _ShadowBias;
|
||||
uniform float4 _Offset;
|
||||
|
||||
#ifdef EFFECT_HUE_VARIATION
|
||||
half4 _HueVariation;
|
||||
#endif
|
||||
|
||||
inline void OctaImpostorVertex( inout appdata_full v, inout float4 uvsFrame1, inout float4 uvsFrame2, inout float4 uvsFrame3, inout float4 octaFrame, inout float4 viewPos )
|
||||
{
|
||||
// Inputs
|
||||
float framesXY = _Frames;
|
||||
float prevFrame = framesXY - 1;
|
||||
float2 fractions = 1.0 / float2( framesXY, prevFrame );
|
||||
float fractionsFrame = fractions.x;
|
||||
float fractionsPrevFrame = fractions.y;
|
||||
float UVscale = _ImpostorSize;
|
||||
float parallax = -_Parallax; // check sign later
|
||||
|
||||
// Basic data
|
||||
v.vertex.xyz += _Offset.xyz;
|
||||
float3 worldOrigin = float3(unity_ObjectToWorld[0].w, unity_ObjectToWorld[1].w, unity_ObjectToWorld[2].w);
|
||||
#if defined(UNITY_PASS_SHADOWCASTER)
|
||||
float3 worldCameraPos = 0;
|
||||
if( unity_LightShadowBias.y == 0.0 ){
|
||||
if( _WorldSpaceLightPos0.w == 1 )
|
||||
worldCameraPos = _WorldSpaceLightPos0.xyz;
|
||||
else
|
||||
worldCameraPos = _WorldSpaceCameraPos;
|
||||
} else {
|
||||
worldCameraPos = UnityWorldSpaceLightDir( mul(unity_ObjectToWorld, v.vertex).xyz ) * -5000.0;
|
||||
}
|
||||
#else
|
||||
float3 worldCameraPos = _WorldSpaceCameraPos;
|
||||
#endif
|
||||
|
||||
float3 objectCameraDirection = normalize( mul( (float3x3)unity_WorldToObject, worldCameraPos - worldOrigin ) - _Offset.xyz );
|
||||
float3 objectCameraPosition = mul( unity_WorldToObject, float4( worldCameraPos, 1 ) ).xyz - _Offset.xyz; //ray origin
|
||||
|
||||
// Create orthogonal vectors to define the billboard
|
||||
float3 upVector = float3( 0,1,0 );
|
||||
float3 objectHorizontalVector = normalize( cross( objectCameraDirection, upVector ) );
|
||||
float3 objectVerticalVector = cross( objectHorizontalVector, objectCameraDirection );
|
||||
|
||||
// Billboard
|
||||
float2 uvExpansion = ( v.texcoord.xy - 0.5f ) * framesXY * fractionsFrame * UVscale;
|
||||
float3 billboard = objectHorizontalVector * uvExpansion.x + objectVerticalVector * uvExpansion.y + _Offset.xyz;
|
||||
|
||||
float3 localDir = billboard - objectCameraPosition - _Offset.xyz;
|
||||
|
||||
// Octahedron Frame
|
||||
#ifdef _HEMI_ON
|
||||
objectCameraDirection.y = max(0.001, objectCameraDirection.y);
|
||||
float2 frameOcta = VectortoHemiOctahedron( objectCameraDirection.xzy ) * 0.5 + 0.5;
|
||||
#else
|
||||
float2 frameOcta = VectortoOctahedron( objectCameraDirection.xzy ) * 0.5 + 0.5;
|
||||
#endif
|
||||
|
||||
// Setup for octahedron
|
||||
float2 prevOctaFrame = frameOcta * prevFrame;
|
||||
float2 baseOctaFrame = floor( prevOctaFrame );
|
||||
float2 fractionOctaFrame = ( baseOctaFrame * fractionsFrame );
|
||||
|
||||
// Octa 1
|
||||
float2 octaFrame1 = ( baseOctaFrame * fractionsPrevFrame ) * 2.0 - 1.0;
|
||||
#ifdef _HEMI_ON
|
||||
float3 octa1WorldY = HemiOctahedronToVector( octaFrame1 ).xzy;
|
||||
#else
|
||||
float3 octa1WorldY = OctahedronToVector( octaFrame1 ).xzy;
|
||||
#endif
|
||||
float3 octa1WorldX = normalize( cross( upVector , octa1WorldY ) + float3(-0.001,0,0));
|
||||
float3 octa1WorldZ = cross( octa1WorldX , octa1WorldY );
|
||||
|
||||
float dotY1 = dot( octa1WorldY , localDir );
|
||||
float3 octa1LocalY = normalize( float3( dot( octa1WorldX , localDir ), dotY1, dot( octa1WorldZ , localDir ) ) );
|
||||
|
||||
float lineInter1 = dot( octa1WorldY , -objectCameraPosition ) / dotY1; //minus??
|
||||
float3 intersectPos1 = ( lineInter1 * localDir + objectCameraPosition ); // should subtract offset??
|
||||
|
||||
float dotframeX1 = dot( octa1WorldX , -intersectPos1 );
|
||||
float dotframeZ1 = dot( octa1WorldZ , -intersectPos1 );
|
||||
|
||||
float2 uvFrame1 = float2( dotframeX1 , dotframeZ1 );
|
||||
|
||||
if( lineInter1 <= 0.0 )
|
||||
uvFrame1 = 0;
|
||||
|
||||
float2 uvParallax1 = octa1LocalY.xz * fractionsFrame * parallax;
|
||||
uvFrame1 = ( ( uvFrame1 / UVscale ) + 0.5 ) * fractionsFrame + fractionOctaFrame;
|
||||
uvsFrame1 = float4( uvParallax1, uvFrame1);
|
||||
|
||||
// Octa 2
|
||||
float2 fractPrevOctaFrame = frac( prevOctaFrame );
|
||||
float2 cornerDifference = lerp( float2( 0,1 ) , float2( 1,0 ) , saturate( ceil( ( fractPrevOctaFrame.x - fractPrevOctaFrame.y ) ) ));
|
||||
float2 octaFrame2 = ( ( baseOctaFrame + cornerDifference ) * fractionsPrevFrame ) * 2.0 - 1.0;
|
||||
#ifdef _HEMI_ON
|
||||
float3 octa2WorldY = HemiOctahedronToVector( octaFrame2 ).xzy;
|
||||
#else
|
||||
float3 octa2WorldY = OctahedronToVector( octaFrame2 ).xzy;
|
||||
#endif
|
||||
|
||||
float3 octa2WorldX = normalize( cross( upVector , octa2WorldY ) + float3(-0.001,0,0));
|
||||
float3 octa2WorldZ = cross( octa2WorldX , octa2WorldY );
|
||||
|
||||
float dotY2 = dot( octa2WorldY , localDir );
|
||||
float3 octa2LocalY = normalize( float3( dot( octa2WorldX , localDir ), dotY2, dot( octa2WorldZ , localDir ) ) );
|
||||
|
||||
float lineInter2 = dot( octa2WorldY , -objectCameraPosition ) / dotY2; //minus??
|
||||
float3 intersectPos2 = ( lineInter2 * localDir + objectCameraPosition );
|
||||
|
||||
float dotframeX2 = dot( octa2WorldX , -intersectPos2 );
|
||||
float dotframeZ2 = dot( octa2WorldZ , -intersectPos2 );
|
||||
|
||||
float2 uvFrame2 = float2( dotframeX2 , dotframeZ2 );
|
||||
|
||||
if( lineInter2 <= 0.0 )
|
||||
uvFrame2 = 0;
|
||||
|
||||
float2 uvParallax2 = octa2LocalY.xz * fractionsFrame * parallax;
|
||||
uvFrame2 = ( ( uvFrame2 / UVscale ) + 0.5 ) * fractionsFrame + ( ( cornerDifference * fractionsFrame ) + fractionOctaFrame );
|
||||
uvsFrame2 = float4( uvParallax2, uvFrame2);
|
||||
|
||||
|
||||
// Octa 3
|
||||
float2 octaFrame3 = ( ( baseOctaFrame + 1 ) * fractionsPrevFrame ) * 2.0 - 1.0;
|
||||
#ifdef _HEMI_ON
|
||||
float3 octa3WorldY = HemiOctahedronToVector( octaFrame3 ).xzy;
|
||||
#else
|
||||
float3 octa3WorldY = OctahedronToVector( octaFrame3 ).xzy;
|
||||
#endif
|
||||
|
||||
float3 octa3WorldX = normalize( cross( upVector , octa3WorldY ) + float3(-0.001,0,0));
|
||||
float3 octa3WorldZ = cross( octa3WorldX , octa3WorldY );
|
||||
|
||||
float dotY3 = dot( octa3WorldY , localDir );
|
||||
float3 octa3LocalY = normalize( float3( dot( octa3WorldX , localDir ), dotY3, dot( octa3WorldZ , localDir ) ) );
|
||||
|
||||
float lineInter3 = dot( octa3WorldY , -objectCameraPosition ) / dotY3; //minus??
|
||||
float3 intersectPos3 = ( lineInter3 * localDir + objectCameraPosition );
|
||||
|
||||
float dotframeX3 = dot( octa3WorldX , -intersectPos3 );
|
||||
float dotframeZ3 = dot( octa3WorldZ , -intersectPos3 );
|
||||
|
||||
float2 uvFrame3 = float2( dotframeX3 , dotframeZ3 );
|
||||
|
||||
if( lineInter3 <= 0.0 )
|
||||
uvFrame3 = 0;
|
||||
|
||||
float2 uvParallax3 = octa3LocalY.xz * fractionsFrame * parallax;
|
||||
uvFrame3 = ( ( uvFrame3 / UVscale ) + 0.5 ) * fractionsFrame + ( fractionOctaFrame + fractionsFrame );
|
||||
uvsFrame3 = float4( uvParallax3, uvFrame3);
|
||||
|
||||
// maybe remove this?
|
||||
octaFrame = 0;
|
||||
octaFrame.xy = prevOctaFrame;
|
||||
#if AI_CLIP_NEIGHBOURS_FRAMES
|
||||
octaFrame.zw = fractionOctaFrame;
|
||||
#endif
|
||||
|
||||
// view pos
|
||||
viewPos = 0;
|
||||
viewPos.xyz = UnityObjectToViewPos( billboard );
|
||||
|
||||
#ifdef EFFECT_HUE_VARIATION
|
||||
float hueVariationAmount = frac(unity_ObjectToWorld[0].w + unity_ObjectToWorld[1].w + unity_ObjectToWorld[2].w);
|
||||
viewPos.w = saturate(hueVariationAmount * _HueVariation.a);
|
||||
#endif
|
||||
|
||||
v.vertex.xyz = billboard;
|
||||
v.normal.xyz = objectCameraDirection;
|
||||
}
|
||||
|
||||
inline void OctaImpostorFragment( inout SurfaceOutputStandardSpecular o, out float4 clipPos, out float3 worldPos, float4 uvsFrame1, float4 uvsFrame2, float4 uvsFrame3, float4 octaFrame, float4 interpViewPos )
|
||||
{
|
||||
float depthBias = -1.0;
|
||||
float textureBias = _TextureBias;
|
||||
|
||||
// Octa1
|
||||
float4 parallaxSample1 = tex2Dbias( _Normals, float4( uvsFrame1.zw, 0, depthBias) );
|
||||
float2 parallax1 = ( ( 0.5 - parallaxSample1.a ) * uvsFrame1.xy ) + uvsFrame1.zw;
|
||||
float4 albedo1 = tex2Dbias( _Albedo, float4( parallax1, 0, textureBias) );
|
||||
float4 normals1 = tex2Dbias( _Normals, float4( parallax1, 0, textureBias) );
|
||||
float4 mask1 = tex2Dbias( _Emission, float4( parallax1, 0, textureBias) );
|
||||
float4 spec1 = tex2Dbias( _Specular, float4( parallax1, 0, textureBias) );
|
||||
|
||||
// Octa2
|
||||
float4 parallaxSample2 = tex2Dbias( _Normals, float4( uvsFrame2.zw, 0, depthBias) );
|
||||
float2 parallax2 = ( ( 0.5 - parallaxSample2.a ) * uvsFrame2.xy ) + uvsFrame2.zw;
|
||||
float4 albedo2 = tex2Dbias( _Albedo, float4( parallax2, 0, textureBias) );
|
||||
float4 normals2 = tex2Dbias( _Normals, float4( parallax2, 0, textureBias) );
|
||||
float4 mask2 = tex2Dbias( _Emission, float4( parallax2, 0, textureBias) );
|
||||
float4 spec2 = tex2Dbias( _Specular, float4( parallax2, 0, textureBias) );
|
||||
|
||||
// Octa3
|
||||
float4 parallaxSample3 = tex2Dbias( _Normals, float4( uvsFrame3.zw, 0, depthBias) );
|
||||
float2 parallax3 = ( ( 0.5 - parallaxSample3.a ) * uvsFrame3.xy ) + uvsFrame3.zw;
|
||||
float4 albedo3 = tex2Dbias( _Albedo, float4( parallax3, 0, textureBias) );
|
||||
float4 normals3 = tex2Dbias( _Normals, float4( parallax3, 0, textureBias) );
|
||||
float4 mask3 = tex2Dbias( _Emission, float4( parallax3, 0, textureBias) );
|
||||
float4 spec3 = tex2Dbias( _Specular, float4( parallax3, 0, textureBias) );
|
||||
|
||||
// Weights
|
||||
float2 fraction = frac( octaFrame.xy );
|
||||
float2 invFraction = 1 - fraction;
|
||||
float3 weights;
|
||||
weights.x = min( invFraction.x, invFraction.y );
|
||||
weights.y = abs( fraction.x - fraction.y );
|
||||
weights.z = min( fraction.x, fraction.y );
|
||||
|
||||
// Blends
|
||||
float4 blendedAlbedo = albedo1 * weights.x + albedo2 * weights.y + albedo3 * weights.z;
|
||||
float4 blendedNormal = normals1 * weights.x + normals2 * weights.y + normals3 * weights.z;
|
||||
float4 blendedMask = mask1 * weights.x + mask2 * weights.y + mask3 * weights.z;
|
||||
float4 blendedSpec = spec1 * weights.x + spec2 * weights.y + spec3 * weights.z;
|
||||
|
||||
float3 localNormal = blendedNormal.rgb * 2.0 - 1.0;
|
||||
float3 worldNormal = normalize( mul( unity_ObjectToWorld, float4( localNormal, 0 ) ).xyz );
|
||||
|
||||
float3 viewPos = interpViewPos.xyz;
|
||||
viewPos.z += ( ( parallaxSample1.a * weights.x + parallaxSample2.a * weights.y + parallaxSample3.a * weights.z ) * 2.0 - 1.0) * 0.5 * _DepthSize * length( unity_ObjectToWorld[2].xyz );
|
||||
#ifdef UNITY_PASS_SHADOWCASTER
|
||||
if( _WorldSpaceLightPos0.w == 0 ){
|
||||
viewPos.z += -_ShadowBias * unity_LightShadowBias.y;
|
||||
} else {
|
||||
viewPos.z += -_ShadowBias;
|
||||
}
|
||||
#endif
|
||||
|
||||
worldPos = mul( UNITY_MATRIX_I_V, float4( viewPos.xyz, 1 ) ).xyz;
|
||||
clipPos = mul( UNITY_MATRIX_P, float4( viewPos, 1 ) );
|
||||
#ifdef UNITY_PASS_SHADOWCASTER
|
||||
clipPos = UnityApplyLinearShadowBias( clipPos );
|
||||
#endif
|
||||
clipPos.xyz /= clipPos.w;
|
||||
if( UNITY_NEAR_CLIP_VALUE < 0 )
|
||||
clipPos = clipPos * 0.5 + 0.5;
|
||||
|
||||
#ifdef EFFECT_HUE_VARIATION
|
||||
half3 shiftedColor = lerp(blendedAlbedo.rgb, _HueVariation.rgb, interpViewPos.w);
|
||||
half maxBase = max(blendedAlbedo.r, max(blendedAlbedo.g, blendedAlbedo.b));
|
||||
half newMaxBase = max(shiftedColor.r, max(shiftedColor.g, shiftedColor.b));
|
||||
maxBase /= newMaxBase;
|
||||
maxBase = maxBase * 0.5f + 0.5f;
|
||||
shiftedColor.rgb *= maxBase;
|
||||
blendedAlbedo.rgb = saturate(shiftedColor);
|
||||
#endif
|
||||
|
||||
#if AI_CLIP_NEIGHBOURS_FRAMES
|
||||
float t = ceil( fraction.x - fraction.y );
|
||||
float4 cornerDifference = float4( t, 1 - t, 1, 1 );
|
||||
|
||||
float2 step_1 = ( uvsFrame1.zw - octaFrame.zw ) * _Frames;
|
||||
float4 step23 = ( float4( uvsFrame2.zw, uvsFrame3.zw ) - octaFrame.zwzw ) * _Frames - cornerDifference;
|
||||
|
||||
step_1 = step_1 * (1-step_1);
|
||||
step23 = step23 * (1-step23);
|
||||
|
||||
float3 steps;
|
||||
steps.x = step_1.x * step_1.y;
|
||||
steps.y = step23.x * step23.y;
|
||||
steps.z = step23.z * step23.w;
|
||||
steps = step(-steps, 0);
|
||||
|
||||
float final = dot( steps, weights );
|
||||
|
||||
clip( final - 0.5 );
|
||||
#endif
|
||||
|
||||
o.Albedo = blendedAlbedo.rgb;
|
||||
o.Normal = worldNormal;
|
||||
o.Emission = blendedMask.rgb;
|
||||
o.Specular = blendedSpec.rgb;
|
||||
o.Smoothness = blendedSpec.a;
|
||||
o.Occlusion = blendedMask.a;
|
||||
o.Alpha = ( blendedAlbedo.a - _ClipMask );
|
||||
clip( o.Alpha );
|
||||
}
|
||||
|
||||
inline void SphereImpostorVertex( inout appdata_full v, inout float2 frameUVs, inout float4 viewPos )
|
||||
{
|
||||
// INPUTS
|
||||
float sizeX = _FramesX;
|
||||
float sizeY = _FramesY - 1; // adjusted
|
||||
float3 fractions = 1 / float3( sizeX, _FramesY, sizeY );
|
||||
float2 sizeFraction = fractions.xy;
|
||||
float axisSizeFraction = fractions.z;
|
||||
|
||||
// Basic data
|
||||
v.vertex.xyz += _Offset.xyz;
|
||||
float3 worldOrigin = float3(unity_ObjectToWorld[0].w, unity_ObjectToWorld[1].w, unity_ObjectToWorld[2].w);
|
||||
#if defined(UNITY_PASS_SHADOWCASTER)
|
||||
float3 worldCameraPos = 0;
|
||||
if( unity_LightShadowBias.y == 0.0 ){
|
||||
if( _WorldSpaceLightPos0.w == 1 )
|
||||
worldCameraPos = _WorldSpaceLightPos0.xyz;
|
||||
else
|
||||
worldCameraPos = _WorldSpaceCameraPos;
|
||||
} else {
|
||||
worldCameraPos = UnityWorldSpaceLightDir( mul(unity_ObjectToWorld, v.vertex).xyz ) * -5000.0;
|
||||
}
|
||||
#else
|
||||
float3 worldCameraPos = _WorldSpaceCameraPos;
|
||||
#endif
|
||||
float3 objectCameraDirection = normalize( mul( (float3x3)unity_WorldToObject, worldCameraPos - worldOrigin ) - _Offset.xyz );
|
||||
|
||||
// Create orthogonal vectors to define the billboard
|
||||
float3 upVector = float3( 0,1,0 );
|
||||
float3 objectHorizontalVector = normalize( cross( objectCameraDirection, upVector ) );
|
||||
float3 objectVerticalVector = cross( objectHorizontalVector, objectCameraDirection );
|
||||
|
||||
// Create vertical radial angle
|
||||
float verticalAngle = frac( atan2( -objectCameraDirection.z, -objectCameraDirection.x ) / UNITY_TWO_PI ) * sizeX + 0.5;
|
||||
|
||||
// Create horizontal radial angle
|
||||
float verticalDot = dot( objectCameraDirection, upVector );
|
||||
float upAngle = ( acos( -verticalDot ) / UNITY_PI ) + axisSizeFraction * 0.5f;
|
||||
float yRot = sizeFraction.x * UNITY_PI * verticalDot * ( 2 * frac( verticalAngle ) - 1 );
|
||||
|
||||
// Billboard rotation
|
||||
float2 uvExpansion = v.texcoord.xy - 0.5;
|
||||
float cosY = cos( yRot );
|
||||
float sinY = sin( yRot );
|
||||
float2 uvRotator = mul( uvExpansion, float2x2( cosY , -sinY , sinY , cosY ) ) * _ImpostorSize;
|
||||
|
||||
// Billboard
|
||||
float3 billboard = objectHorizontalVector * uvRotator.x + objectVerticalVector * uvRotator.y + _Offset.xyz;
|
||||
|
||||
// Frame coords
|
||||
float2 relativeCoords = float2( floor( verticalAngle ), min( floor( upAngle * sizeY ), sizeY ) );
|
||||
float2 frameUV = ( v.texcoord.xy + relativeCoords ) * sizeFraction;
|
||||
|
||||
frameUVs.xy = frameUV;
|
||||
viewPos.xyz = UnityObjectToViewPos( billboard );
|
||||
|
||||
#ifdef EFFECT_HUE_VARIATION
|
||||
float hueVariationAmount = frac(unity_ObjectToWorld[0].w + unity_ObjectToWorld[1].w + unity_ObjectToWorld[2].w);
|
||||
viewPos.w = saturate(hueVariationAmount * _HueVariation.a);
|
||||
#endif
|
||||
|
||||
v.vertex.xyz = billboard;
|
||||
v.normal.xyz = objectCameraDirection;
|
||||
}
|
||||
|
||||
inline void SphereImpostorFragment( inout SurfaceOutputStandardSpecular o, out float4 clipPos, out float3 worldPos, float2 frameUV, float4 viewPos )
|
||||
{
|
||||
float4 albedoSample = tex2Dbias( _Albedo, float4( frameUV, 0, _TextureBias) );
|
||||
float4 normalSample = tex2Dbias( _Normals, float4( frameUV, 0, _TextureBias) );
|
||||
float4 specularSample = tex2Dbias( _Specular, float4( frameUV, 0, _TextureBias) );
|
||||
float4 emissionSample = tex2Dbias( _Emission, float4( frameUV, 0, _TextureBias) );
|
||||
|
||||
// Simple outputs
|
||||
float3 albedo = albedoSample.rgb;
|
||||
float3 emission = emissionSample.rgb;
|
||||
float3 specular = specularSample.rgb;
|
||||
float smoothness = specularSample.a;
|
||||
float occlusion = emissionSample.a;
|
||||
float alphaMask = albedoSample.a;
|
||||
|
||||
// Normal
|
||||
float4 remapNormal = normalSample * 2 - 1; // object normal is remapNormal.rgb
|
||||
float3 worldNormal = normalize( mul( (float3x3)unity_ObjectToWorld, remapNormal.xyz ) );
|
||||
|
||||
// Depth
|
||||
float depth = remapNormal.a * _DepthSize * 0.5;
|
||||
#if defined(UNITY_PASS_SHADOWCASTER)
|
||||
if( _WorldSpaceLightPos0.w == 0 ){
|
||||
depth = depth * 0.95 - 0.05 - _ShadowBias * unity_LightShadowBias.y;
|
||||
} else {
|
||||
depth = depth * 0.95 - 0.05 - _ShadowBias;
|
||||
}
|
||||
#endif
|
||||
viewPos.z += depth;
|
||||
|
||||
// Modified clip position and world position
|
||||
worldPos = mul( UNITY_MATRIX_I_V, float4( viewPos.xyz, 1 ) ).xyz;
|
||||
|
||||
clipPos = mul( UNITY_MATRIX_P, float4( viewPos.xyz, 1 ) );
|
||||
#ifdef UNITY_PASS_SHADOWCASTER
|
||||
clipPos = UnityApplyLinearShadowBias( clipPos );
|
||||
#endif
|
||||
clipPos.xyz /= clipPos.w;
|
||||
if( UNITY_NEAR_CLIP_VALUE < 0 )
|
||||
clipPos = clipPos * 0.5 + 0.5;
|
||||
|
||||
#ifdef EFFECT_HUE_VARIATION
|
||||
half3 shiftedColor = lerp(albedo.rgb, _HueVariation.rgb, viewPos.w);
|
||||
half maxBase = max(albedo.r, max(albedo.g, albedo.b));
|
||||
half newMaxBase = max(shiftedColor.r, max(shiftedColor.g, shiftedColor.b));
|
||||
maxBase /= newMaxBase;
|
||||
maxBase = maxBase * 0.5f + 0.5f;
|
||||
shiftedColor.rgb *= maxBase;
|
||||
albedo.rgb = saturate(shiftedColor);
|
||||
#endif
|
||||
|
||||
o.Albedo = albedo;
|
||||
o.Normal = worldNormal;
|
||||
o.Emission = emission;
|
||||
o.Specular = specular;
|
||||
o.Smoothness = smoothness;
|
||||
o.Occlusion = occlusion;
|
||||
o.Alpha = ( alphaMask - _ClipMask );
|
||||
clip( o.Alpha );
|
||||
}
|
||||
#endif
|
10
Assets/RaceTracksPack/Shaders/Billboards.cginc.meta
Normal file
10
Assets/RaceTracksPack/Shaders/Billboards.cginc.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9c90e81f6c03545e789ccdc2e6a6ee35
|
||||
timeCreated: 1541765963
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
49
Assets/RaceTracksPack/Shaders/DoubleSided.shader
Normal file
49
Assets/RaceTracksPack/Shaders/DoubleSided.shader
Normal file
@ -0,0 +1,49 @@
|
||||
Shader "DoubleSided" {
|
||||
Properties {
|
||||
_Color ("Main Color", Color) = (1,1,1,1)
|
||||
_MainTex ("Base (RGB)", 2D) = "white" {}
|
||||
//_BumpMap ("Bump (RGB) Illumin (A)", 2D) = "bump" {}
|
||||
}
|
||||
SubShader {
|
||||
//UsePass "Self-Illumin/VertexLit/BASE"
|
||||
//UsePass "Bumped Diffuse/PPL"
|
||||
|
||||
// Ambient pass
|
||||
Pass {
|
||||
Name "BASE"
|
||||
Tags {"LightMode" = "Always" /* Upgrade NOTE: changed from PixelOrNone to Always */}
|
||||
Color [_PPLAmbient]
|
||||
SetTexture [_BumpMap] {
|
||||
constantColor (.5,.5,.5)
|
||||
combine constant lerp (texture) previous
|
||||
}
|
||||
SetTexture [_MainTex] {
|
||||
constantColor [_Color]
|
||||
Combine texture * previous DOUBLE, texture*constant
|
||||
}
|
||||
}
|
||||
|
||||
// Vertex lights
|
||||
Pass {
|
||||
Name "BASE"
|
||||
Tags {"LightMode" = "Vertex"}
|
||||
Material {
|
||||
Diffuse [_Color]
|
||||
Emission [_PPLAmbient]
|
||||
Shininess [_Shininess]
|
||||
Specular [_SpecColor]
|
||||
}
|
||||
SeparateSpecular On
|
||||
Lighting On
|
||||
Cull Off
|
||||
SetTexture [_BumpMap] {
|
||||
constantColor (.5,.5,.5)
|
||||
combine constant lerp (texture) previous
|
||||
}
|
||||
SetTexture [_MainTex] {
|
||||
Combine texture * previous DOUBLE, texture*primary
|
||||
}
|
||||
}
|
||||
}
|
||||
FallBack "Diffuse", 1
|
||||
}
|
9
Assets/RaceTracksPack/Shaders/DoubleSided.shader.meta
Normal file
9
Assets/RaceTracksPack/Shaders/DoubleSided.shader.meta
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 638ef0acfb185b4488bde6f984ea4f2f
|
||||
timeCreated: 1529589235
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
66
Assets/RaceTracksPack/Shaders/Standard.shader
Normal file
66
Assets/RaceTracksPack/Shaders/Standard.shader
Normal file
@ -0,0 +1,66 @@
|
||||
Shader "TOZ/Object/Splat/VertexColors/Standard" {
|
||||
Properties {
|
||||
_Splat0("Layer 0 (R)", 2D) = "red" {}
|
||||
_Splat1("Layer 1 (G)", 2D) = "green" {}
|
||||
_Splat2("Layer 2 (B)", 2D) = "blue" {}
|
||||
_Splat3("Layer 3 (A)", 2D) = "black" {}
|
||||
_Normal0("Normal 0 (R)", 2D) = "bump" {}
|
||||
_Normal1("Normal 1 (G)", 2D) = "bump" {}
|
||||
_Normal2("Normal 2 (B)", 2D) = "bump" {}
|
||||
_Normal3("Normal 3 (A)", 2D) = "bump" {}
|
||||
[Gamma]_Metallic0("Metallic 0", Range(0.0, 1.0)) = 0.0
|
||||
[Gamma]_Metallic1("Metallic 1", Range(0.0, 1.0)) = 0.0
|
||||
[Gamma]_Metallic2("Metallic 2", Range(0.0, 1.0)) = 0.0
|
||||
[Gamma]_Metallic3("Metallic 3", Range(0.0, 1.0)) = 0.0
|
||||
_Glossiness("Smoothness", Range(0,1)) = 0.5
|
||||
}
|
||||
SubShader {
|
||||
Tags { "RenderType"="Opaque" "Queue" = "Geometry" }
|
||||
LOD 200
|
||||
|
||||
CGPROGRAM
|
||||
#pragma surface surf Standard vertex:vert fullforwardshadows
|
||||
#pragma target 3.0
|
||||
|
||||
sampler2D _Splat0, _Splat1, _Splat2, _Splat3;
|
||||
sampler2D _Normal0, _Normal1, _Normal2, _Normal3;
|
||||
float4 _Splat0_ST, _Splat1_ST, _Splat2_ST, _Splat3_ST;
|
||||
half _Metallic0, _Metallic1, _Metallic2, _Metallic3;
|
||||
half _Glossiness;
|
||||
|
||||
struct Input {
|
||||
fixed4 color : COLOR0;
|
||||
float4 coord0 : TEXCOORD0;
|
||||
float4 coord1 : TEXCOORD1;
|
||||
};
|
||||
|
||||
void vert(inout appdata_full v, out Input o) {
|
||||
UNITY_INITIALIZE_OUTPUT(Input, o);
|
||||
o.color = v.color;
|
||||
o.coord0.xy = v.texcoord.xy * _Splat0_ST.xy + _Splat0_ST.zw;
|
||||
o.coord0.zw = v.texcoord.xy * _Splat1_ST.xy + _Splat1_ST.zw;
|
||||
o.coord1.xy = v.texcoord.xy * _Splat2_ST.xy + _Splat2_ST.zw;
|
||||
o.coord1.zw = v.texcoord.xy * _Splat3_ST.xy + _Splat3_ST.zw;
|
||||
}
|
||||
|
||||
void surf(Input IN, inout SurfaceOutputStandard o) {
|
||||
fixed4 col, nrm;
|
||||
col = IN.color.r * tex2D(_Splat0, IN.coord0.xy);
|
||||
col += IN.color.g * tex2D(_Splat1, IN.coord0.zw);
|
||||
col += IN.color.b * tex2D(_Splat2, IN.coord1.xy);
|
||||
col += IN.color.a * tex2D(_Splat3, IN.coord1.zw);
|
||||
nrm = IN.color.r * tex2D(_Normal0, IN.coord0.xy);
|
||||
nrm += IN.color.g * tex2D(_Normal1, IN.coord0.zw);
|
||||
nrm += IN.color.b * tex2D(_Normal2, IN.coord1.xy);
|
||||
nrm += IN.color.a * tex2D(_Normal3, IN.coord1.zw);
|
||||
o.Albedo = col.rgb;
|
||||
o.Alpha = col.a;
|
||||
o.Normal = UnpackNormal(nrm);
|
||||
o.Smoothness = _Glossiness;
|
||||
o.Metallic = dot(IN.color, half4(_Metallic0, _Metallic1, _Metallic2, _Metallic3));
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
FallBack "Diffuse"
|
||||
}
|
9
Assets/RaceTracksPack/Shaders/Standard.shader.meta
Normal file
9
Assets/RaceTracksPack/Shaders/Standard.shader.meta
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7bd39ee5c4a21734394f03955314eae1
|
||||
timeCreated: 1431347401
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
66
Assets/RaceTracksPack/Shaders/Unlit-Alpha - DS.shader
Normal file
66
Assets/RaceTracksPack/Shaders/Unlit-Alpha - DS.shader
Normal file
@ -0,0 +1,66 @@
|
||||
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
|
||||
|
||||
// Unlit alpha-blended shader.
|
||||
// - no lighting
|
||||
// - no lightmap support
|
||||
// - no per-material color
|
||||
|
||||
Shader "Unlit/Transparent_DS" {
|
||||
Properties {
|
||||
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
|
||||
}
|
||||
|
||||
SubShader {Cull Off
|
||||
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
|
||||
LOD 100
|
||||
|
||||
ZWrite Off
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
|
||||
Pass {
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 2.0
|
||||
#pragma multi_compile_fog
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata_t {
|
||||
float4 vertex : POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f {
|
||||
float4 vertex : SV_POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
UNITY_FOG_COORDS(1)
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
|
||||
v2f vert (appdata_t v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
|
||||
UNITY_TRANSFER_FOG(o,o.vertex);
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
fixed4 col = tex2D(_MainTex, i.texcoord);
|
||||
UNITY_APPLY_FOG(i.fogCoord, col);
|
||||
return col;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 127fb0765f5020d4c9c46aee3c696d14
|
||||
timeCreated: 1531407870
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user