This commit is contained in:
Alex38Lyon
2025-06-03 09:04:29 +02:00
parent 1d52befa0d
commit 1a3232e9ea
30 changed files with 12607 additions and 0 deletions
+114
View File
@@ -0,0 +1,114 @@
Shader "Shader Graphs/VertexColorLitShader"
{
Properties
{
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 200
Pass
{
Name "ForwardLit"
Tags { "LightMode" = "UniversalForward" }
HLSLPROGRAM
// Pipeline directives
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS
#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
#pragma multi_compile _ _SHADOWS_SOFT
#pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ LIGHTMAP_ON
// Includes
#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/ShaderLibrary/ShaderVariablesFunctions.hlsl"
struct Attributes
{
float4 positionOS : POSITION;
float3 normalOS : NORMAL;
float4 tangentOS : TANGENT;
float4 color : COLOR;
};
struct Varyings
{
float4 positionHCS : SV_POSITION;
float3 normalWS : TEXCOORD0;
float3 tangentWS : TEXCOORD1;
float3 bitangentWS : TEXCOORD2;
float4 color : COLOR;
float3 posWS : TEXCOORD3;
float4 shadowCoord : TEXCOORD4;
};
Varyings vert(Attributes input)
{
Varyings output;
// World space positions & normals
float3 posWS = TransformObjectToWorld(input.positionOS.xyz);
float3 normalWS = TransformObjectToWorldNormal(input.normalOS);
float3 tangentWS = TransformObjectToWorldDir(input.tangentOS.xyz);
float3 bitangentWS = cross(normalWS, tangentWS) * input.tangentOS.w;
output.positionHCS = TransformWorldToHClip(posWS);
output.normalWS = normalWS;
output.tangentWS = tangentWS;
output.bitangentWS = bitangentWS;
output.color = input.color;
output.posWS = posWS;
output.shadowCoord = TransformWorldToShadowCoord(posWS);
return output;
}
half4 frag(Varyings input) : SV_Target
{
float3 viewDirWS = normalize(_WorldSpaceCameraPos - input.posWS);
float3 normalWS = normalize(input.normalWS);
// Required for URP lighting
InputData inputData = (InputData)0;
inputData.positionWS = input.posWS;
inputData.normalWS = normalWS;
inputData.viewDirectionWS = viewDirWS;
inputData.shadowCoord = input.shadowCoord;
// Compute tangent space normal (not using a normal map, so fake Z)
float3x3 tangentSpace = float3x3(
normalize(input.tangentWS),
normalize(input.bitangentWS),
normalize(input.normalWS)
);
float3 normalTS = mul(tangentSpace, float3(0, 0, 1));
// Fill SurfaceData with vertex color
SurfaceData surfaceData;
surfaceData.albedo = input.color.rgb;
surfaceData.alpha = 1.0;
surfaceData.metallic = 0.0;
surfaceData.specular = 0.0;
surfaceData.smoothness = 0.3;
surfaceData.normalTS = normalTS;
surfaceData.emission = float3(0, 0, 0);
surfaceData.occlusion = 1.0;
surfaceData.clearCoatMask = 0.0;
surfaceData.clearCoatSmoothness = 0.0;
return UniversalFragmentPBR(inputData, surfaceData);
}
ENDHLSL
}
}
FallBack "Hidden/Universal Render Pipeline/FallbackError"
}