升级obi
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
#ifndef OBILIGHTINGBUILTURP_INCLUDED
|
||||
#define OBILIGHTINGBUILTURP_INCLUDED
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
|
||||
half3 SampleSphereAmbient(float3 eyeNormal)
|
||||
{
|
||||
half3 worldNormal = mul(UNITY_MATRIX_I_V,half4(eyeNormal,0.0));
|
||||
return SampleSH(worldNormal);
|
||||
}
|
||||
|
||||
float3 ObjSpaceLightDir(in float4 modelPos)
|
||||
{
|
||||
float3 lightPos = mul(unity_WorldToObject,_MainLightPosition).xyz;
|
||||
float3 lightVector = lightPos.xyz - modelPos * _MainLightPosition.w;
|
||||
return lightVector;
|
||||
}
|
||||
|
||||
float3 WorldSpaceLightDir(in float4 modelPos)
|
||||
{
|
||||
float3 vertexPos = mul(unity_ObjectToWorld, modelPos).xyz;
|
||||
float3 lightVector = _MainLightPosition.xyz - vertexPos * _MainLightPosition.w;
|
||||
return lightVector;
|
||||
}
|
||||
|
||||
half Attenuation(float3 eyePos)
|
||||
{
|
||||
half3 worldPos = mul(UNITY_MATRIX_I_V,half4(eyePos,1.0));
|
||||
float4 shadowCoord = TransformWorldToShadowCoord(worldPos);
|
||||
Light mainLight = GetMainLight(shadowCoord);
|
||||
return mainLight.shadowAttenuation * mainLight.distanceAttenuation;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2231c15aefcd6484e9857cbb64ad8cd7
|
||||
timeCreated: 1445285630
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,236 +0,0 @@
|
||||
Shader "Obi/URP/Particles" {
|
||||
|
||||
Properties {
|
||||
_Color ("Particle color", Color) = (1,1,1,1)
|
||||
_RadiusScale("Radius scale",float) = 1
|
||||
}
|
||||
|
||||
SubShader {
|
||||
|
||||
Tags{"RenderPipeline" = "UniversalRenderPipeline"}
|
||||
|
||||
Pass {
|
||||
|
||||
Name "ParticleFwdBase"
|
||||
Tags {"Queue"="Geometry" "IgnoreProjector"="True" "RenderType"="Opaque" "LightMode" = "UniversalForward"}
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
|
||||
HLSLPROGRAM
|
||||
|
||||
#pragma prefer_hlslcc gles
|
||||
#pragma exclude_renderers d3d11_9x
|
||||
#pragma target 2.0
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
|
||||
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS
|
||||
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE
|
||||
#pragma multi_compile _ _SHADOWS_SOFT
|
||||
|
||||
#include "../ObiUtils.cginc"
|
||||
#include "ObiLightingURP.cginc"
|
||||
#include "../ObiEllipsoids.cginc"
|
||||
|
||||
float4 _Color;
|
||||
float4 _LightColor0;
|
||||
|
||||
struct vin{
|
||||
float4 vertex : POSITION;
|
||||
float3 corner : NORMAL;
|
||||
float4 color : COLOR;
|
||||
float4 t0 : TEXCOORD0; // ellipsoid t1 vector
|
||||
float4 t1 : TEXCOORD1; // ellipsoid t2 vector
|
||||
float4 t2 : TEXCOORD2; // ellipsoid t3 vector
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float4 color : COLOR;
|
||||
float4 mapping : TEXCOORD0;
|
||||
float3 viewRay : TEXCOORD1;
|
||||
float3 lightDir : TEXCOORD2;
|
||||
float3 a2 : TEXCOORD3;
|
||||
float3 a3 : TEXCOORD4;
|
||||
};
|
||||
|
||||
struct fout
|
||||
{
|
||||
half4 color : SV_Target;
|
||||
float depth : SV_Depth;
|
||||
};
|
||||
|
||||
v2f vert(vin v)
|
||||
{
|
||||
float3x3 P, IP;
|
||||
BuildParameterSpaceMatrices(v.t0,v.t1,v.t2,P,IP);
|
||||
|
||||
float3 worldPos;
|
||||
float3 view;
|
||||
float3 eye;
|
||||
float radius = BuildEllipsoidBillboard(v.vertex,v.corner,P,IP,worldPos,view,eye);
|
||||
|
||||
v2f o;
|
||||
o.pos = mul(UNITY_MATRIX_VP, float4(worldPos,v.vertex.w));
|
||||
o.mapping = float4(v.corner.xy,1/length(eye),radius); // A[1]
|
||||
o.viewRay = mul((float3x3)UNITY_MATRIX_V,view); // A[0]
|
||||
o.color = v.color * _Color;
|
||||
|
||||
BuildAuxiliaryNormalVectors(v.vertex,worldPos,view,P,IP,o.a2,o.a3);
|
||||
|
||||
o.lightDir = mul((float3x3)UNITY_MATRIX_MV, ObjSpaceLightDir(v.vertex));
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
fout frag(v2f i)
|
||||
{
|
||||
fout fo;
|
||||
|
||||
fo.color = half4(0,0,0,i.color.a);
|
||||
|
||||
// generate sphere normals:
|
||||
float3 p,n;
|
||||
IntersectEllipsoid(i.viewRay,i.mapping, i.a2,i.a3, p, n);
|
||||
|
||||
// clip space position:
|
||||
float4 pos = mul(UNITY_MATRIX_P,float4(p,1.0));
|
||||
|
||||
// simple lighting: ambient
|
||||
half3 amb = SampleSphereAmbient(n);
|
||||
|
||||
// simple lighting: diffuse
|
||||
float ndotl = saturate( dot( n, normalize(i.lightDir) ) );
|
||||
float atten = Attenuation(p);
|
||||
|
||||
// final lit color:
|
||||
fo.color.rgb = i.color * (_LightColor0 * ndotl * atten + amb);
|
||||
|
||||
// normalized device coordinates:
|
||||
fo.depth = pos.z/pos.w;
|
||||
|
||||
// in openGL calculated depth range is <-1,1> map it to <0,1>
|
||||
#if SHADER_API_OPENGL || SHADER_API_GLCORE || SHADER_API_GLES || SHADER_API_GLES3
|
||||
fo.depth = 0.5 * fo.depth + 0.5;
|
||||
#endif
|
||||
|
||||
return fo;
|
||||
}
|
||||
|
||||
ENDHLSL
|
||||
|
||||
}
|
||||
|
||||
Pass {
|
||||
|
||||
Name "ShadowCaster"
|
||||
Tags { "LightMode" = "ShadowCaster" }
|
||||
Offset 1, 1
|
||||
|
||||
Fog {Mode Off}
|
||||
ZWrite On ZTest LEqual
|
||||
|
||||
HLSLPROGRAM
|
||||
|
||||
#pragma prefer_hlslcc gles
|
||||
#pragma exclude_renderers d3d11_9x
|
||||
#pragma target 2.0
|
||||
|
||||
#pragma vertex ellipsoidShadowVS
|
||||
#pragma fragment frag
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
|
||||
#pragma multi_compile_shadowcaster
|
||||
|
||||
#include "../ObiUtils.cginc"
|
||||
#include "ObiLightingURP.cginc"
|
||||
#include "../ObiEllipsoids.cginc"
|
||||
|
||||
sampler3D _DitherMaskLOD;
|
||||
float4 _Color;
|
||||
|
||||
struct vin{
|
||||
float4 vertex : POSITION;
|
||||
float3 corner : NORMAL;
|
||||
float4 color : COLOR;
|
||||
float4 t0 : TEXCOORD0; // ellipsoid t1 vector
|
||||
float4 t1 : TEXCOORD1; // ellipsoid t2 vector
|
||||
float4 t2 : TEXCOORD2; // ellipsoid t3 vector
|
||||
};
|
||||
|
||||
struct v2f {
|
||||
float4 color : COLOR;
|
||||
float4 mapping : TEXCOORD0;
|
||||
float3 viewRay : TEXCOORD1;
|
||||
float3 lightDir : TEXCOORD2;
|
||||
float3 a2 : TEXCOORD3;
|
||||
float3 a3 : TEXCOORD4;
|
||||
};
|
||||
|
||||
struct fout
|
||||
{
|
||||
half4 color : SV_Target;
|
||||
float depth : SV_Depth;
|
||||
};
|
||||
|
||||
v2f ellipsoidShadowVS( vin v , out float4 outpos : SV_POSITION )// clip space position output
|
||||
{
|
||||
float3x3 P, IP;
|
||||
BuildParameterSpaceMatrices(v.t0,v.t1,v.t2,P,IP);
|
||||
|
||||
float3 worldPos;
|
||||
float3 view;
|
||||
float3 eye;
|
||||
float radius = BuildEllipsoidBillboard(v.vertex,v.corner,P,IP,worldPos,view,eye);
|
||||
|
||||
v2f o;
|
||||
outpos = mul(UNITY_MATRIX_VP, float4(worldPos,v.vertex.w));
|
||||
o.mapping = float4(v.corner.xy,1/length(eye),radius); // A[1]
|
||||
o.viewRay = mul((float3x3)UNITY_MATRIX_V,view); // A[0]
|
||||
o.color = v.color * _Color;
|
||||
|
||||
BuildAuxiliaryNormalVectors(v.vertex,worldPos,view,P,IP,o.a2,o.a3);
|
||||
|
||||
o.lightDir = WorldSpaceLightDir(v.vertex);
|
||||
return o;
|
||||
}
|
||||
|
||||
fout frag( v2f i )
|
||||
{
|
||||
fout fo;
|
||||
|
||||
float3 p,n;
|
||||
IntersectEllipsoid(i.viewRay,i.mapping,i.a2,i.a3,p, n);
|
||||
|
||||
// calculate world space position and normal:
|
||||
float4 wnormal = mul(UNITY_MATRIX_I_V,float4(n,0));
|
||||
float4 wpos = mul(UNITY_MATRIX_I_V,float4(p,1));
|
||||
|
||||
// calculate clip space position.
|
||||
float4 clipPos = TransformWorldToHClip(ApplyShadowBias(wpos, wnormal, normalize(i.lightDir)));
|
||||
|
||||
#if UNITY_REVERSED_Z
|
||||
clipPos.z = min(clipPos.z, clipPos.w * UNITY_NEAR_CLIP_VALUE);
|
||||
#else
|
||||
clipPos.z = max(clipPos.z, clipPos.w * UNITY_NEAR_CLIP_VALUE);
|
||||
#endif
|
||||
|
||||
fo.color = clipPos.z/clipPos.w; //similar to what SHADOW_CASTER_FRAGMENT does in case there's no depth buffer.
|
||||
fo.depth = clipPos.z/clipPos.w;
|
||||
|
||||
// in openGL calculated depth range is <-1,1> map it to <0,1>
|
||||
#if SHADER_API_OPENGL || SHADER_API_GLCORE || SHADER_API_GLES || SHADER_API_GLES3
|
||||
fo.depth = fo.depth*0.5+0.5;
|
||||
#endif
|
||||
|
||||
return fo;
|
||||
}
|
||||
ENDHLSL
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 28641a0edd6e047c6af7e3c6b342c81a
|
||||
timeCreated: 1438934781
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,145 +0,0 @@
|
||||
Shader "Obi/URP/Simple Particles" {
|
||||
|
||||
Properties {
|
||||
_Color ("Particle color", Color) = (1,1,1,1)
|
||||
}
|
||||
|
||||
SubShader {
|
||||
|
||||
Tags{"RenderPipeline" = "UniversalRenderPipeline"}
|
||||
|
||||
Pass {
|
||||
|
||||
Name "ParticleFwdBase"
|
||||
Tags {"Queue"="Geometry" "IgnoreProjector"="True" "RenderType"="Opaque" "LightMode" = "UniversalForward"}
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
|
||||
HLSLPROGRAM
|
||||
|
||||
#pragma prefer_hlslcc gles
|
||||
#pragma exclude_renderers d3d11_9x
|
||||
#pragma target 2.0
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
|
||||
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS
|
||||
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE
|
||||
#pragma multi_compile _ _SHADOWS_SOFT
|
||||
|
||||
#include "../ObiUtils.cginc"
|
||||
#include "ObiLightingURP.cginc"
|
||||
#include "../ObiParticles.cginc"
|
||||
|
||||
float4 _Color;
|
||||
float4 _LightColor0;
|
||||
|
||||
struct vin{
|
||||
float4 vertex : POSITION;
|
||||
float3 corner : NORMAL;
|
||||
float4 color : COLOR;
|
||||
float4 t0 : TEXCOORD0; // ellipsoid t1 vector
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 pos : POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float3 lightDir : TEXCOORD1;
|
||||
};
|
||||
|
||||
v2f vert(vin v)
|
||||
{
|
||||
v2f o;
|
||||
|
||||
// particle positions are passed in world space, no need to use modelview matrix, just view.
|
||||
float radius = v.t0.w * _RadiusScale;
|
||||
float4 viewpos = mul(UNITY_MATRIX_V, v.vertex) + float4(v.corner.x, v.corner.y, 0, 0) * radius; // multiply by size.
|
||||
o.pos = mul(UNITY_MATRIX_P, viewpos);
|
||||
o.texcoord = float3(v.corner.x*0.5+0.5, v.corner.y*0.5+0.5, radius);
|
||||
o.color = v.color * _Color;
|
||||
|
||||
o.lightDir = mul ((float3x3)UNITY_MATRIX_MV, ObjSpaceLightDir(v.vertex));
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 frag(v2f i) : SV_Target
|
||||
{
|
||||
// generate sphere normals:
|
||||
float3 n = BillboardSphereNormals(i.texcoord);
|
||||
|
||||
// simple lighting: ambient
|
||||
half3 amb = SampleSphereAmbient(n);
|
||||
|
||||
// simple lighting: diffuse
|
||||
float ndotl = saturate( dot( n, normalize(i.lightDir) ) );
|
||||
|
||||
// final lit color:
|
||||
return float4(i.color.rgb * (_LightColor0 * ndotl + amb),i.color.a);
|
||||
}
|
||||
|
||||
ENDHLSL
|
||||
|
||||
}
|
||||
|
||||
Pass {
|
||||
Name "ShadowCaster"
|
||||
Tags { "LightMode" = "ShadowCaster" }
|
||||
Offset 1, 1
|
||||
|
||||
Fog {Mode Off}
|
||||
ZWrite On ZTest LEqual
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma prefer_hlslcc gles
|
||||
#pragma exclude_renderers d3d11_9x
|
||||
#pragma target 2.0
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
|
||||
#pragma multi_compile_shadowcaster
|
||||
|
||||
#include "../ObiUtils.cginc"
|
||||
#include "ObiLightingURP.cginc"
|
||||
#include "../ObiParticles.cginc"
|
||||
|
||||
struct vin{
|
||||
float4 vertex : POSITION;
|
||||
float3 corner : NORMAL;
|
||||
float4 t0 : TEXCOORD0; // ellipsoid t1 vector
|
||||
};
|
||||
|
||||
struct v2f {
|
||||
float4 pos : POSITION;
|
||||
float3 texcoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
v2f vert( vin v )
|
||||
{
|
||||
v2f o;
|
||||
|
||||
float radius = v.t0.w * _RadiusScale;
|
||||
float4 viewpos = mul(UNITY_MATRIX_V, v.vertex) + float4(v.corner.x, v.corner.y, 0, 0) * radius;
|
||||
o.pos = mul(UNITY_MATRIX_P, viewpos);
|
||||
o.texcoord = float3(v.corner.x*0.5+0.5, v.corner.y*0.5+0.5, radius);
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 frag( v2f i ) : SV_Target
|
||||
{
|
||||
float3 n = BillboardSphereNormals(i.texcoord);
|
||||
|
||||
return float4(0,0,0,0);
|
||||
}
|
||||
ENDHLSL
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a8c46db5ccc10489cba075e7a9172ca6
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user