The following simple blinnphong shader works as expected in a fresh Unity 2022.3.52f1 URP project. But in a fresh Unity 6000.0.26f1 URP Project it just outputs black. Why doesn’t it work in Unity 6? How do I get it to work in Unity 6?
Shader "Unlit/Test"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Tags{"LightMode" = "UniversalForward"}
Pass
{
HLSLPROGRAM
#pragma vertex Vertex
#pragma fragment Fragment
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
struct Attributes {
float3 positionOS : POSITION;
float3 normalOS : NORMAL;
float2 uv : TEXCOORD0;
};
struct Interpolators {
float4 positionCS : SV_POSITION;
float2 uv : TEXCOORD0;
float3 normalWS : TEXCOORD1;
};
sampler2D _MainTex;
Interpolators Vertex(Attributes input) {
Interpolators output;
VertexPositionInputs posnInputs = GetVertexPositionInputs(input.positionOS);
VertexNormalInputs normInputs = GetVertexNormalInputs(input.normalOS);
output.positionCS = posnInputs.positionCS;
output.uv = input.uv;
output.normalWS = normInputs.normalWS;
return output;
}
float4 Fragment(Interpolators input) : SV_TARGET {
float2 uv = input.uv;
float4 colorSample = tex2D(_MainTex, input.uv);
InputData lightingInput = (InputData)0;
lightingInput.normalWS = normalize(input.normalWS);
SurfaceData surfaceInput = (SurfaceData)0;
surfaceInput.albedo = float3(1, 1, 0).rgb;
surfaceInput.alpha = 1;
return UniversalFragmentBlinnPhong(lightingInput, surfaceInput);
}
ENDHLSL
}
}
}