Shader "Unlit URP Shader/sampbur" { Properties { _BaseColor("Base Color",color) = (1,1,1,1) _BaseMap("BaseMap", 2D) = "white" {} } SubShader { Tags { "Queue"="Geometry" "RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" } LOD 100 Pass { Tags {"LightMode" = "UniversalForward"} HLSLPROGRAM // Required to compile gles 2.0 with standard srp library #pragma prefer_hlslcc gles #pragma exclude_renderers d3d11_9x #pragma multi_compile _ LIGHTMAP_ON #pragma multi_compile _ _MAIN_LIGHT_SHADOWS //接受主光源阴影 #pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE //投射主光源的阴影 #pragma multi_compile _ _SHADOWS_SOFT //软阴影 #pragma multi_compile _ _ADDITIONAL_LIGHTS //附加光源 #pragma vertex vert #pragma fragment frag #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" struct Attributes { float4 positionOS : POSITION; float2 uv : TEXCOORD0; float3 normal:NORMAL; }; struct Varyings { float4 positionCS : SV_POSITION; float2 uv : TEXCOORD0; float3 Wnormal : TEXCOORD1; float3 Wpos:TEXCOORD2; }; CBUFFER_START(UnityPerMaterial) half4 _BaseColor; float4 _BaseMap_ST; CBUFFER_END TEXTURE2D (_BurTexture);SAMPLER(sampler_BurTexture); Varyings vert(Attributes v) { Varyings o = (Varyings)0; o.positionCS = TransformObjectToHClip(v.positionOS.xyz); o.uv = TRANSFORM_TEX(v.uv, _BaseMap); o.Wpos = TransformObjectToWorld(v.positionOS); o.Wnormal=TransformObjectToWorldNormal(v.normal); return o; } half4 frag(Varyings i) : SV_Target { float3 N=normalize(i.Wnormal); float3 V=normalize(_WorldSpaceCameraPos.xyz-i.Wpos.xyz); float2 uv=i.positionCS.xy/_ScreenParams.xy; half4 c; half4 baseMap = SAMPLE_TEXTURE2D(_BurTexture, sampler_BurTexture, uv); c = baseMap * _BaseColor; //c.rgb = MixFog(c.rgb, i.fogCoord); //float _Me=0.6;//干净的透明玻璃漫反射少,所以金属度直接拉满 //间接高光和漫反射 // float aa=1; // BRDFData brdfData; // InitializeBRDFData(c,_Me,1,1,aa, brdfData); // half3 ambient_contrib = SampleSH(float4(N, 1)); // float3 ambient = 0.3 * c;// 随便乘个暗的系数 // float3 iblDiffuse = max(half3(0, 0, 0), ambient.rgb + ambient_contrib); // float3 inssp= GlobalIllumination(brdfData,iblDiffuse,1,i.Wpos,N,V); // c.rgb+=inssp*0.5; return c; } ENDHLSL } } }