Unity URP多光源支持,多光源阴影投射,多光源阴影接收(优化版)

目录

前言:

一、属性

二、SubShader

三、ForwardLitPass

定义Tags

声明变体

声明变量

定义结构体

顶点Shader

片元Shader

四、全代码

四、添加官方的LitShader代码

五、全代码

六、效果图

七、结语


前言:

哈喽啊,我又来啦。这次呢给大家带来了UnityURP渲染管线的优化自定义多光源Shader模板,之前呢我也写过Unity URPShader支持多光源处理_urp 多光源-CSDN博客和多光源的阴影接收Unity URP支持多光源阴影_urp 多光源 阴影-CSDN博客。

前面的文章确实解决了很多,但是呢,其中硬要抠细节,说实话并不好,这次呢,我会给大家带来参考Unity官方的模板,重写URP管线里的Lit光照Shader,这个Shader在主要的光照部分能完美的处理,并且能够自定义我们想要的其它额外效果(主要是跟大家完美解决URP的阴影问题啦。)

其实呢,要改的东西不多,大多数都是Copy官方的Lit代码,其中我们核心修改“ForwardLit”部分。

(支持Sprite精灵图的阴影)

一、属性

 Properties{[MainTexture] _BaseMap ("Albedo", 2D) = "white" { }[MainColor] _BaseColor ("Color", Color) = (1, 1, 1, 1)[Toggle] _ReceiveShadows ("Receive Shadows", Float) = 1.0[Enum(UnityEngine.Rendering.CullMode)]_Cull ("CullMode", Float) = 2.0[Toggle] _AlphaTest ("AlphaClip", Float) = 1.0// ObsoleteProperties[HideInInspector] _MainTex ("BaseMap", 2D) = "white" { }[HideInInspector]_Smoothness ("Smoothness", Range(0.0, 1.0)) = 0.5[HideInInspector]_Metallic ("Metallic", Range(0.0, 1.0)) = 0.0[HideInInspector]_Cutoff ("Alpha Cutoff", Range(0.0, 1.0)) = 0.5}

属性呢就可以直接采用我写好的属性,这些都迎合了SRPBactcher,可以保留的最少的属性(奇迹上也不是真的最少啦,我的这种是最有用但最少的哈哈。)

二、SubShader

 Tags { "RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" "UniversalMaterialType" = "Lit" }LOD 300

我们声明好Tags,当然可以根据你的项目需求,自定义这部分。

三、ForwardLitPass

定义Tags

这一块是我们的核心功能,我会给出多光源光照、多光源阴影接收的模板代码并解释,你可以根据需求任意修改它们。

 SubShader{Tags { "RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" "UniversalMaterialType" = "Lit" }LOD 300Pass{Name "ForwardLit"Tags { "LightMode" = "UniversalForward" }Blend One Zero, One ZeroZWrite OnCull[_Cull]AlphaToMask On}}

声明变体

首先呢,Pass里的Name也不是固定的,可以随意修改它,这里我就默认了。

其次,这个Pass采用前向渲染的光照Tag,我们需要定义好。

然后是Blend部分,其实这里呢不加也可以,如果你操作的是透明物体,那么需要加上。

#pragma vertex vert
#pragma fragment frag
#pragma shader_feature_local  _RECEIVESHADOWS_ON  //是否开启接收阴影的开关
#pragma shader_feature_local  _ALPHATEST_ON //其否其余AlphaClip的开关【适合Png图片剔除】
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE  _MAIN_LIGHT_SHADOWS_SCREEN  //主光的阴影变体
#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS  //额外光变体
#pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS      //额外光的阴影变体
#pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH      //阴影的质量变体#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/ShaderGraphFunctions.hlsl" //主要用于后面的函数调用

声明变量

 TEXTURE2D(_BaseMap);SAMPLER(sampler_BaseMap);//CBuffer里的变量必须包含以下的变量,不然不会适配SRP,定义这些不会影响性能CBUFFER_START(UnityPerMaterial)float4 _BaseMap_ST;float4 _DetailAlbedoMap_ST;half4 _BaseColor;half4 _SpecColor;half4 _EmissionColor;half _Cutoff;half _Smoothness;half _Metallic;half _BumpScale;half _Parallax;half _OcclusionStrength;half _ClearCoatMask;half _ClearCoatSmoothness;half _DetailAlbedoMapScale;half _DetailNormalMapScale;half _Surface;
CBUFFER_END//实例化参数,看需求定义
#ifdef UNITY_DOTS_INSTANCING_ENABLEDUNITY_DOTS_INSTANCING_START(MaterialPropertyMetadata)UNITY_DOTS_INSTANCED_PROP(float4, _BaseColor)UNITY_DOTS_INSTANCING_END(MaterialPropertyMetadata)
#endif

定义结构体

    struct Attributes{float4 positionOS : POSITION;float2 texcoord : TEXCOORD0;float3 normalOS : NORMAL;UNITY_VERTEX_INPUT_INSTANCE_ID};struct Varyings{float4 positionHS : SV_POSITION;float2 uv : TEXCOORD0;float3 positionWS : TEXCOORD1;float3 normalWS : TEXCOORD2;half3 lightColor : COLOR;   //额外光照的颜色,需要进行记录顶点光照的#ifdef _RECEIVESHADOWS_ON   //开启接收光照开关需要的变量float4 shadowCoord : TEXCOORD3;  //主光的阴影#ifdef  _ADDITIONAL_LIGHTSfloat4 shadowMask : TEXCOORD4; //如果是逐像素光源,需要一个shadowMask#endif#endifUNITY_VERTEX_INPUT_INSTANCE_ID};

顶点Shader

   Varyings vert(Attributes v){Varyings o;UNITY_SETUP_INSTANCE_ID(v);UNITY_TRANSFER_INSTANCE_ID(v, o);o.positionHS = TransformObjectToHClip(v.positionOS.xyz);o.positionWS = TransformObjectToWorld(v.positionOS.xyz);o.normalWS = TransformObjectToWorldNormal(v.normalOS);o.uv = v.texcoord;//光照o.lightColor = 0.0;#ifdef _RECEIVESHADOWS_ON  //如果开启接收阴影//主光阴影坐标o.shadowCoord = TransformWorldToShadowCoord(o.positionWS);//多光源的阴影,需要定义shadowMask#if defined(SHADOWS_SHADOWMASK) && defined(LIGHTMAP_ON)half4 shadowMask = inputData.shadowMask;#elif !defined(LIGHTMAP_ON)half4 shadowMask = unity_ProbesOcclusion;#elsehalf4 shadowMask = 1.0;#endif//如果是逐顶点灯光#if _ADDITIONAL_LIGHTS_VERTEXuint pixelLightCount = GetAdditionalLightsCount();for (uint lightIndex = 0u; lightIndex < pixelLightCount; ++lightIndex){Light light = GetAdditionalLight(lightIndex, positionWS, shadowMask);half3 attenuatedLightColor = light.color * light.distanceAttenuation * light.shadowAttenuation;o.lightColor += LightingLambert(attenuatedLightColor, light.direction, o.normalWS);}//如果是逐像素灯光#elif _ADDITIONAL_LIGHTSo.shadowMask = shadowMask;#endif//不开启接收阴影#else#ifdef _ADDITIONAL_LIGHTS_VERTEXfor (uint lightIndex = 0u; lightIndex < pixelLightCount; ++lightIndex){Light light = GetAdditionalLight(lightIndex, positionWS);half3 attenuatedLightColor = light.color * light.distanceAttenuation * light.shadowAttenuation;o.lightColor += LightingLambert(attenuatedLightColor, light.direction, o.normalWS);}#endif#endifreturn o;}

片元Shader

         half4 frag(Varyings i) : SV_Target{UNITY_SETUP_INSTANCE_ID(i);//光照half3 lightColor = i.lightColor;  //如果是逐顶点光照,lightColor需要保存逐顶点的光照//开启接受阴影#ifdef _RECEIVESHADOWS_ON//主光颜色和阴影Light main_light = GetMainLight(i.shadowCoord);half3 main_attenuatedLightColor = main_light.color * main_light.distanceAttenuation * main_light.shadowAttenuation;lightColor += LightingLambert(main_attenuatedLightColor, main_light.direction, i.normalWS);//如果是逐像素光源#ifdef _ADDITIONAL_LIGHTSuint pixelLightCount = GetAdditionalLightsCount();for (uint lightIndex = 0u; lightIndex < pixelLightCount; ++lightIndex){Light light = GetAdditionalLight(lightIndex, i.positionWS.xyz, i.shadowMask);half3 attenuatedLightColor = light.color * light.distanceAttenuation * light.shadowAttenuation;//继续累加颜色lightColor += LightingLambert(attenuatedLightColor, light.direction, i.normalWS);}#endif//不接受阴影#elseLight main_light = GetMainLight();half3 main_attenuatedLightColor = main_light.color * main_light.distanceAttenuation * main_light.shadowAttenuation;lightColor += LightingLambert(main_attenuatedLightColor, main_light.direction, i.normalWS);#ifdef _ADDITIONAL_LIGHTSuint pixelLightCount = GetAdditionalLightsCount();for (uint lightIndex = 0u; lightIndex < pixelLightCount; ++lightIndex){Light light = GetAdditionalLight(lightIndex, i.positionWS.xyz);half3 attenuatedLightColor = light.color * light.distanceAttenuation * light.shadowAttenuation;lightColor += LightingLambert(attenuatedLightColor, light.direction, i.normalWS);}#endif#endif//环境光half3 ambient = half3(unity_SHAr.w, unity_SHAg.w, unity_SHAb.w);//贴图基础颜色half4 col = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, i.uv);col.rgb *= _BaseColor.rgb * lightColor + ambient;//alpha剔除,适配png图片#ifdef _ALPHATEST_ONcol.a = AlphaDiscard(col.a, _Cutoff);#elsecol.a = 1.0;#endifreturn col;}

四、全代码

   Pass{Name "ForwardLit"Tags { "LightMode" = "UniversalForward" }Blend One Zero, One ZeroZWrite OnCull[_Cull]AlphaToMask OnHLSLPROGRAM#pragma vertex vert#pragma fragment frag#pragma shader_feature_local  _RECEIVESHADOWS_ON#pragma shader_feature_local  _ALPHATEST_ON#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS#pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS#pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH#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/ShaderGraphFunctions.hlsl"TEXTURE2D(_BaseMap);SAMPLER(sampler_BaseMap);CBUFFER_START(UnityPerMaterial)float4 _BaseMap_ST;float4 _DetailAlbedoMap_ST;half4 _BaseColor;half4 _SpecColor;half4 _EmissionColor;half _Cutoff;half _Smoothness;half _Metallic;half _BumpScale;half _Parallax;half _OcclusionStrength;half _ClearCoatMask;half _ClearCoatSmoothness;half _DetailAlbedoMapScale;half _DetailNormalMapScale;half _Surface;CBUFFER_END#ifdef UNITY_DOTS_INSTANCING_ENABLEDUNITY_DOTS_INSTANCING_START(MaterialPropertyMetadata)UNITY_DOTS_INSTANCED_PROP(float4, _BaseColor)UNITY_DOTS_INSTANCING_END(MaterialPropertyMetadata)#endifstruct Attributes{float4 positionOS : POSITION;float2 texcoord : TEXCOORD0;float3 normalOS : NORMAL;UNITY_VERTEX_INPUT_INSTANCE_ID};struct Varyings{float4 positionHS : SV_POSITION;float2 uv : TEXCOORD0;float3 positionWS : TEXCOORD1;float3 normalWS : TEXCOORD2;half3 lightColor : COLOR;#ifdef _RECEIVESHADOWS_ONfloat4 shadowCoord : TEXCOORD3;#ifdef  _ADDITIONAL_LIGHTSfloat4 shadowMask : TEXCOORD4;#endif#endifUNITY_VERTEX_INPUT_INSTANCE_ID};Varyings vert(Attributes v){Varyings o;UNITY_SETUP_INSTANCE_ID(v);UNITY_TRANSFER_INSTANCE_ID(v, o);o.positionHS = TransformObjectToHClip(v.positionOS.xyz);o.positionWS = TransformObjectToWorld(v.positionOS.xyz);o.normalWS = TransformObjectToWorldNormal(v.normalOS);o.uv = v.texcoord;//光照o.lightColor = 0.0;#ifdef _RECEIVESHADOWS_ONo.shadowCoord = TransformWorldToShadowCoord(o.positionWS);//多光源的阴影#if defined(SHADOWS_SHADOWMASK) && defined(LIGHTMAP_ON)half4 shadowMask = inputData.shadowMask;#elif !defined(LIGHTMAP_ON)half4 shadowMask = unity_ProbesOcclusion;#elsehalf4 shadowMask = 1.0;#endif#if _ADDITIONAL_LIGHTS_VERTEXuint pixelLightCount = GetAdditionalLightsCount();for (uint lightIndex = 0u; lightIndex < pixelLightCount; ++lightIndex){Light light = GetAdditionalLight(lightIndex, positionWS, shadowMask);half3 attenuatedLightColor = light.color * light.distanceAttenuation * light.shadowAttenuation;o.lightColor += LightingLambert(attenuatedLightColor, light.direction, o.normalWS);}#elif _ADDITIONAL_LIGHTSo.shadowMask = shadowMask;#endif#else#ifdef _ADDITIONAL_LIGHTS_VERTEXfor (uint lightIndex = 0u; lightIndex < pixelLightCount; ++lightIndex){Light light = GetAdditionalLight(lightIndex, positionWS);half3 attenuatedLightColor = light.color * light.distanceAttenuation * light.shadowAttenuation;o.lightColor += LightingLambert(attenuatedLightColor, light.direction, o.normalWS);}#endif#endifreturn o;}half4 frag(Varyings i) : SV_Target{UNITY_SETUP_INSTANCE_ID(i);//光照half3 lightColor = i.lightColor;#ifdef _RECEIVESHADOWS_ONLight main_light = GetMainLight(i.shadowCoord);half3 main_attenuatedLightColor = main_light.color * main_light.distanceAttenuation * main_light.shadowAttenuation;lightColor += LightingLambert(main_attenuatedLightColor, main_light.direction, i.normalWS);#ifdef _ADDITIONAL_LIGHTSuint pixelLightCount = GetAdditionalLightsCount();for (uint lightIndex = 0u; lightIndex < pixelLightCount; ++lightIndex){Light light = GetAdditionalLight(lightIndex, i.positionWS.xyz, i.shadowMask);half3 attenuatedLightColor = light.color * light.distanceAttenuation * light.shadowAttenuation;lightColor += LightingLambert(attenuatedLightColor, light.direction, i.normalWS);}#endif#elseLight main_light = GetMainLight();half3 main_attenuatedLightColor = main_light.color * main_light.distanceAttenuation * main_light.shadowAttenuation;lightColor += LightingLambert(main_attenuatedLightColor, main_light.direction, i.normalWS);#ifdef _ADDITIONAL_LIGHTSuint pixelLightCount = GetAdditionalLightsCount();for (uint lightIndex = 0u; lightIndex < pixelLightCount; ++lightIndex){Light light = GetAdditionalLight(lightIndex, i.positionWS.xyz);half3 attenuatedLightColor = light.color * light.distanceAttenuation * light.shadowAttenuation;lightColor += LightingLambert(attenuatedLightColor, light.direction, i.normalWS);}#endif#endif//环境光half3 ambient = half3(unity_SHAr.w, unity_SHAg.w, unity_SHAb.w);half4 col = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, i.uv);col.rgb *= _BaseColor.rgb * lightColor + ambient;#ifdef _ALPHATEST_ONcol.a = AlphaDiscard(col.a, _Cutoff);#elsecol.a = 1.0;#endifreturn col;}ENDHLSL}

四、添加官方的LitShader代码

如果需要自定义阴影,可以看我之前的阴影部分文章的ShadowCast部分

Unity URP支持多光源阴影_urp 多光源 阴影-CSDN博客

    Pass{Name "ShadowCaster"Tags { "LightMode" = "ShadowCaster" }// -------------------------------------// Render State CommandsZWrite OnZTest LEqualColorMask 0Cull[_Cull]HLSLPROGRAM#pragma target 2.0// -------------------------------------// Shader Stages#pragma vertex ShadowPassVertex#pragma fragment ShadowPassFragment// -------------------------------------// Material Keywords#pragma shader_feature_local _ALPHATEST_ON#pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A//--------------------------------------// GPU Instancing#pragma multi_compile_instancing#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"// -------------------------------------// Universal Pipeline keywords// -------------------------------------// Unity defined keywords#pragma multi_compile_fragment _ LOD_FADE_CROSSFADE// This is used during shadow map generation to differentiate between directional and punctual light shadows, as they use different formulas to apply Normal Bias#pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW// -------------------------------------// Includes#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"#include "Packages/com.unity.render-pipelines.universal/Shaders/ShadowCasterPass.hlsl"ENDHLSL}Pass{// Lightmode matches the ShaderPassName set in UniversalRenderPipeline.cs. SRPDefaultUnlit and passes with// no LightMode tag are also rendered by Universal Render PipelineName "GBuffer"Tags { "LightMode" = "UniversalGBuffer" }// -------------------------------------// Render State CommandsZWrite[_ZWrite]ZTest LEqualCull[_Cull]HLSLPROGRAM#pragma target 4.5// Deferred Rendering Path does not support the OpenGL-based graphics API:// Desktop OpenGL, OpenGL ES 3.0, WebGL 2.0.#pragma exclude_renderers gles3 glcore// -------------------------------------// Shader Stages#pragma vertex LitGBufferPassVertex#pragma fragment LitGBufferPassFragment// -------------------------------------// Material Keywords#pragma shader_feature_local _NORMALMAP#pragma shader_feature_local_fragment _ALPHATEST_ON//#pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON#pragma shader_feature_local_fragment _EMISSION#pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP#pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A#pragma shader_feature_local_fragment _OCCLUSIONMAP#pragma shader_feature_local _PARALLAXMAP#pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED#pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF#pragma shader_feature_local_fragment _ENVIRONMENTREFLECTIONS_OFF#pragma shader_feature_local_fragment _SPECULAR_SETUP#pragma shader_feature_local _RECEIVE_SHADOWS_OFF// -------------------------------------// Universal Pipeline keywords#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN//#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS//#pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS#pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING#pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION#pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH#pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3#pragma multi_compile_fragment _ _RENDER_PASS_ENABLED#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl"// -------------------------------------// Unity defined keywords#pragma multi_compile _ LIGHTMAP_SHADOW_MIXING#pragma multi_compile _ SHADOWS_SHADOWMASK#pragma multi_compile _ DIRLIGHTMAP_COMBINED#pragma multi_compile _ LIGHTMAP_ON#pragma multi_compile _ DYNAMICLIGHTMAP_ON#pragma multi_compile_fragment _ LOD_FADE_CROSSFADE#pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT//--------------------------------------// GPU Instancing#pragma multi_compile_instancing#pragma instancing_options renderinglayer#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"// -------------------------------------// Includes#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"#include "Packages/com.unity.render-pipelines.universal/Shaders/LitGBufferPass.hlsl"ENDHLSL}Pass{Name "DepthOnly"Tags { "LightMode" = "DepthOnly" }// -------------------------------------// Render State CommandsZWrite OnColorMask RCull[_Cull]HLSLPROGRAM#pragma target 2.0// -------------------------------------// Shader Stages#pragma vertex DepthOnlyVertex#pragma fragment DepthOnlyFragment// -------------------------------------// Material Keywords#pragma shader_feature_local _ALPHATEST_ON#pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A// -------------------------------------// Unity defined keywords#pragma multi_compile_fragment _ LOD_FADE_CROSSFADE//--------------------------------------// GPU Instancing#pragma multi_compile_instancing#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"// -------------------------------------// Includes#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"#include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl"ENDHLSL}// This pass is used when drawing to a _CameraNormalsTexture texturePass{Name "DepthNormals"Tags { "LightMode" = "DepthNormals" }// -------------------------------------// Render State CommandsZWrite OnCull[_Cull]HLSLPROGRAM#pragma target 2.0// -------------------------------------// Shader Stages#pragma vertex DepthNormalsVertex#pragma fragment DepthNormalsFragment// -------------------------------------// Material Keywords#pragma shader_feature_local _NORMALMAP#pragma shader_feature_local _PARALLAXMAP#pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED#pragma shader_feature_local_fragment _ALPHATEST_ON#pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A// -------------------------------------// Unity defined keywords#pragma multi_compile_fragment _ LOD_FADE_CROSSFADE// -------------------------------------// Universal Pipeline keywords#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl"//--------------------------------------// GPU Instancing#pragma multi_compile_instancing#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"// -------------------------------------// Includes#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"#include "Packages/com.unity.render-pipelines.universal/Shaders/LitDepthNormalsPass.hlsl"ENDHLSL}// This pass it not used during regular rendering, only for lightmap baking.Pass{Name "Meta"Tags { "LightMode" = "Meta" }// -------------------------------------// Render State CommandsCull OffHLSLPROGRAM#pragma target 2.0// -------------------------------------// Shader Stages#pragma vertex UniversalVertexMeta#pragma fragment UniversalFragmentMetaLit// -------------------------------------// Material Keywords#pragma shader_feature_local_fragment _SPECULAR_SETUP#pragma shader_feature_local_fragment _EMISSION#pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP#pragma shader_feature_local_fragment _ALPHATEST_ON#pragma shader_feature_local_fragment _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A#pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED#pragma shader_feature_local_fragment _SPECGLOSSMAP#pragma shader_feature EDITOR_VISUALIZATION// -------------------------------------// Includes#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"#include "Packages/com.unity.render-pipelines.universal/Shaders/LitMetaPass.hlsl"ENDHLSL}Pass{Name "Universal2D"Tags { "LightMode" = "Universal2D" }// -------------------------------------// Render State CommandsBlend[_SrcBlend][_DstBlend]ZWrite[_ZWrite]Cull[_Cull]HLSLPROGRAM#pragma target 2.0// -------------------------------------// Shader Stages#pragma vertex vert#pragma fragment frag// -------------------------------------// Material Keywords#pragma shader_feature_local_fragment _ALPHATEST_ON#pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"// -------------------------------------// Includes#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"#include "Packages/com.unity.render-pipelines.universal/Shaders/Utils/Universal2D.hlsl"ENDHLSL}

五、全代码

Shader "Custom_Lit"
{Properties{[MainTexture] _BaseMap ("Albedo", 2D) = "white" { }[MainColor] _BaseColor ("Color", Color) = (1, 1, 1, 1)[Toggle] _ReceiveShadows ("Receive Shadows", Float) = 1.0[Enum(UnityEngine.Rendering.CullMode)]_Cull ("CullMode", Float) = 2.0[Toggle] _AlphaTest ("AlphaClip", Float) = 1.0// ObsoleteProperties[HideInInspector] _MainTex ("BaseMap", 2D) = "white" { }[HideInInspector]_Smoothness ("Smoothness", Range(0.0, 1.0)) = 0.5[HideInInspector]_Metallic ("Metallic", Range(0.0, 1.0)) = 0.0[HideInInspector]_Cutoff ("Alpha Cutoff", Range(0.0, 1.0)) = 0.5}SubShader{Tags { "RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" "UniversalMaterialType" = "Lit" }LOD 300Pass{Name "ForwardLit"Tags { "LightMode" = "UniversalForward" }Blend One Zero, One ZeroZWrite OnCull[_Cull]AlphaToMask OnHLSLPROGRAM#pragma vertex vert#pragma fragment frag#pragma shader_feature_local  _RECEIVESHADOWS_ON#pragma shader_feature_local  _ALPHATEST_ON#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS#pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS#pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH#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/ShaderGraphFunctions.hlsl"TEXTURE2D(_BaseMap);SAMPLER(sampler_BaseMap);CBUFFER_START(UnityPerMaterial)float4 _BaseMap_ST;float4 _DetailAlbedoMap_ST;half4 _BaseColor;half4 _SpecColor;half4 _EmissionColor;half _Cutoff;half _Smoothness;half _Metallic;half _BumpScale;half _Parallax;half _OcclusionStrength;half _ClearCoatMask;half _ClearCoatSmoothness;half _DetailAlbedoMapScale;half _DetailNormalMapScale;half _Surface;CBUFFER_END#ifdef UNITY_DOTS_INSTANCING_ENABLEDUNITY_DOTS_INSTANCING_START(MaterialPropertyMetadata)UNITY_DOTS_INSTANCED_PROP(float4, _BaseColor)UNITY_DOTS_INSTANCING_END(MaterialPropertyMetadata)#endifstruct Attributes{float4 positionOS : POSITION;float2 texcoord : TEXCOORD0;float3 normalOS : NORMAL;UNITY_VERTEX_INPUT_INSTANCE_ID};struct Varyings{float4 positionHS : SV_POSITION;float2 uv : TEXCOORD0;float3 positionWS : TEXCOORD1;float3 normalWS : TEXCOORD2;half3 lightColor : COLOR;#ifdef _RECEIVESHADOWS_ONfloat4 shadowCoord : TEXCOORD3;#ifdef  _ADDITIONAL_LIGHTSfloat4 shadowMask : TEXCOORD4;#endif#endifUNITY_VERTEX_INPUT_INSTANCE_ID};Varyings vert(Attributes v){Varyings o;UNITY_SETUP_INSTANCE_ID(v);UNITY_TRANSFER_INSTANCE_ID(v, o);o.positionHS = TransformObjectToHClip(v.positionOS.xyz);o.positionWS = TransformObjectToWorld(v.positionOS.xyz);o.normalWS = TransformObjectToWorldNormal(v.normalOS);o.uv = v.texcoord;//光照o.lightColor = 0.0;#ifdef _RECEIVESHADOWS_ONo.shadowCoord = TransformWorldToShadowCoord(o.positionWS);//多光源的阴影#if defined(SHADOWS_SHADOWMASK) && defined(LIGHTMAP_ON)half4 shadowMask = inputData.shadowMask;#elif !defined(LIGHTMAP_ON)half4 shadowMask = unity_ProbesOcclusion;#elsehalf4 shadowMask = 1.0;#endif#if _ADDITIONAL_LIGHTS_VERTEXuint pixelLightCount = GetAdditionalLightsCount();for (uint lightIndex = 0u; lightIndex < pixelLightCount; ++lightIndex){Light light = GetAdditionalLight(lightIndex, positionWS, shadowMask);half3 attenuatedLightColor = light.color * light.distanceAttenuation * light.shadowAttenuation;o.lightColor += LightingLambert(attenuatedLightColor, light.direction, o.normalWS);}#elif _ADDITIONAL_LIGHTSo.shadowMask = shadowMask;#endif#else#ifdef _ADDITIONAL_LIGHTS_VERTEXfor (uint lightIndex = 0u; lightIndex < pixelLightCount; ++lightIndex){Light light = GetAdditionalLight(lightIndex, positionWS);half3 attenuatedLightColor = light.color * light.distanceAttenuation * light.shadowAttenuation;o.lightColor += LightingLambert(attenuatedLightColor, light.direction, o.normalWS);}#endif#endifreturn o;}half4 frag(Varyings i) : SV_Target{UNITY_SETUP_INSTANCE_ID(i);//光照half3 lightColor = i.lightColor;#ifdef _RECEIVESHADOWS_ONLight main_light = GetMainLight(i.shadowCoord);half3 main_attenuatedLightColor = main_light.color * main_light.distanceAttenuation * main_light.shadowAttenuation;lightColor += LightingLambert(main_attenuatedLightColor, main_light.direction, i.normalWS);#ifdef _ADDITIONAL_LIGHTSuint pixelLightCount = GetAdditionalLightsCount();for (uint lightIndex = 0u; lightIndex < pixelLightCount; ++lightIndex){Light light = GetAdditionalLight(lightIndex, i.positionWS.xyz, i.shadowMask);half3 attenuatedLightColor = light.color * light.distanceAttenuation * light.shadowAttenuation;lightColor += LightingLambert(attenuatedLightColor, light.direction, i.normalWS);}#endif#elseLight main_light = GetMainLight();half3 main_attenuatedLightColor = main_light.color * main_light.distanceAttenuation * main_light.shadowAttenuation;lightColor += LightingLambert(main_attenuatedLightColor, main_light.direction, i.normalWS);#ifdef _ADDITIONAL_LIGHTSuint pixelLightCount = GetAdditionalLightsCount();for (uint lightIndex = 0u; lightIndex < pixelLightCount; ++lightIndex){Light light = GetAdditionalLight(lightIndex, i.positionWS.xyz);half3 attenuatedLightColor = light.color * light.distanceAttenuation * light.shadowAttenuation;lightColor += LightingLambert(attenuatedLightColor, light.direction, i.normalWS);}#endif#endif//环境光half3 ambient = half3(unity_SHAr.w, unity_SHAg.w, unity_SHAb.w);half4 col = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, i.uv);col.rgb *= _BaseColor.rgb * lightColor + ambient;#ifdef _ALPHATEST_ONcol.a = AlphaDiscard(col.a, _Cutoff);#elsecol.a = 1.0;#endifreturn col;}ENDHLSL}Pass{Name "ShadowCaster"Tags { "LightMode" = "ShadowCaster" }// -------------------------------------// Render State CommandsZWrite OnZTest LEqualColorMask 0Cull[_Cull]HLSLPROGRAM#pragma target 2.0// -------------------------------------// Shader Stages#pragma vertex ShadowPassVertex#pragma fragment ShadowPassFragment// -------------------------------------// Material Keywords#pragma shader_feature_local _ALPHATEST_ON#pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A//--------------------------------------// GPU Instancing#pragma multi_compile_instancing#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"// -------------------------------------// Universal Pipeline keywords// -------------------------------------// Unity defined keywords#pragma multi_compile_fragment _ LOD_FADE_CROSSFADE// This is used during shadow map generation to differentiate between directional and punctual light shadows, as they use different formulas to apply Normal Bias#pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW// -------------------------------------// Includes#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"#include "Packages/com.unity.render-pipelines.universal/Shaders/ShadowCasterPass.hlsl"ENDHLSL}Pass{// Lightmode matches the ShaderPassName set in UniversalRenderPipeline.cs. SRPDefaultUnlit and passes with// no LightMode tag are also rendered by Universal Render PipelineName "GBuffer"Tags { "LightMode" = "UniversalGBuffer" }// -------------------------------------// Render State CommandsZWrite[_ZWrite]ZTest LEqualCull[_Cull]HLSLPROGRAM#pragma target 4.5// Deferred Rendering Path does not support the OpenGL-based graphics API:// Desktop OpenGL, OpenGL ES 3.0, WebGL 2.0.#pragma exclude_renderers gles3 glcore// -------------------------------------// Shader Stages#pragma vertex LitGBufferPassVertex#pragma fragment LitGBufferPassFragment// -------------------------------------// Material Keywords#pragma shader_feature_local _NORMALMAP#pragma shader_feature_local_fragment _ALPHATEST_ON//#pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON#pragma shader_feature_local_fragment _EMISSION#pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP#pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A#pragma shader_feature_local_fragment _OCCLUSIONMAP#pragma shader_feature_local _PARALLAXMAP#pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED#pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF#pragma shader_feature_local_fragment _ENVIRONMENTREFLECTIONS_OFF#pragma shader_feature_local_fragment _SPECULAR_SETUP#pragma shader_feature_local _RECEIVE_SHADOWS_OFF// -------------------------------------// Universal Pipeline keywords#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN//#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS//#pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS#pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING#pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION#pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH#pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3#pragma multi_compile_fragment _ _RENDER_PASS_ENABLED#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl"// -------------------------------------// Unity defined keywords#pragma multi_compile _ LIGHTMAP_SHADOW_MIXING#pragma multi_compile _ SHADOWS_SHADOWMASK#pragma multi_compile _ DIRLIGHTMAP_COMBINED#pragma multi_compile _ LIGHTMAP_ON#pragma multi_compile _ DYNAMICLIGHTMAP_ON#pragma multi_compile_fragment _ LOD_FADE_CROSSFADE#pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT//--------------------------------------// GPU Instancing#pragma multi_compile_instancing#pragma instancing_options renderinglayer#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"// -------------------------------------// Includes#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"#include "Packages/com.unity.render-pipelines.universal/Shaders/LitGBufferPass.hlsl"ENDHLSL}Pass{Name "DepthOnly"Tags { "LightMode" = "DepthOnly" }// -------------------------------------// Render State CommandsZWrite OnColorMask RCull[_Cull]HLSLPROGRAM#pragma target 2.0// -------------------------------------// Shader Stages#pragma vertex DepthOnlyVertex#pragma fragment DepthOnlyFragment// -------------------------------------// Material Keywords#pragma shader_feature_local _ALPHATEST_ON#pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A// -------------------------------------// Unity defined keywords#pragma multi_compile_fragment _ LOD_FADE_CROSSFADE//--------------------------------------// GPU Instancing#pragma multi_compile_instancing#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"// -------------------------------------// Includes#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"#include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl"ENDHLSL}// This pass is used when drawing to a _CameraNormalsTexture texturePass{Name "DepthNormals"Tags { "LightMode" = "DepthNormals" }// -------------------------------------// Render State CommandsZWrite OnCull[_Cull]HLSLPROGRAM#pragma target 2.0// -------------------------------------// Shader Stages#pragma vertex DepthNormalsVertex#pragma fragment DepthNormalsFragment// -------------------------------------// Material Keywords#pragma shader_feature_local _NORMALMAP#pragma shader_feature_local _PARALLAXMAP#pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED#pragma shader_feature_local_fragment _ALPHATEST_ON#pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A// -------------------------------------// Unity defined keywords#pragma multi_compile_fragment _ LOD_FADE_CROSSFADE// -------------------------------------// Universal Pipeline keywords#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl"//--------------------------------------// GPU Instancing#pragma multi_compile_instancing#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"// -------------------------------------// Includes#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"#include "Packages/com.unity.render-pipelines.universal/Shaders/LitDepthNormalsPass.hlsl"ENDHLSL}// This pass it not used during regular rendering, only for lightmap baking.Pass{Name "Meta"Tags { "LightMode" = "Meta" }// -------------------------------------// Render State CommandsCull OffHLSLPROGRAM#pragma target 2.0// -------------------------------------// Shader Stages#pragma vertex UniversalVertexMeta#pragma fragment UniversalFragmentMetaLit// -------------------------------------// Material Keywords#pragma shader_feature_local_fragment _SPECULAR_SETUP#pragma shader_feature_local_fragment _EMISSION#pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP#pragma shader_feature_local_fragment _ALPHATEST_ON#pragma shader_feature_local_fragment _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A#pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED#pragma shader_feature_local_fragment _SPECGLOSSMAP#pragma shader_feature EDITOR_VISUALIZATION// -------------------------------------// Includes#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"#include "Packages/com.unity.render-pipelines.universal/Shaders/LitMetaPass.hlsl"ENDHLSL}Pass{Name "Universal2D"Tags { "LightMode" = "Universal2D" }// -------------------------------------// Render State CommandsBlend[_SrcBlend][_DstBlend]ZWrite[_ZWrite]Cull[_Cull]HLSLPROGRAM#pragma target 2.0// -------------------------------------// Shader Stages#pragma vertex vert#pragma fragment frag// -------------------------------------// Material Keywords#pragma shader_feature_local_fragment _ALPHATEST_ON#pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"// -------------------------------------// Includes#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"#include "Packages/com.unity.render-pipelines.universal/Shaders/Utils/Universal2D.hlsl"ENDHLSL}}FallBack "Hidden/Universal Render Pipeline/FallbackError"
}

六、效果图

七、结语

有了以上的模板Shader,这样就可以在第一个Pass里随意自定义自己想要的效果,例如给Shader加一个外描边功能,给Shader加一个溶解功能等等

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/890760.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

如何使用React,透传各类组件能力/属性?

在23年的时候&#xff0c;我主要使用的框架还是Vue&#xff0c;当时写了一篇“如何二次封装一个Vue3组件库&#xff1f;”的文章&#xff0c;里面涉及了一些如何使用Vue透传组件能力的方法。在我24年接触React之后&#xff0c;我发现这种扩展组件能力的方式有一个专门的术语&am…

109.【C语言】数据结构之求二叉树的高度

目录 1.知识回顾&#xff1a;高度&#xff08;也称深度&#xff09; 2.分析 设计代码框架 返回左右子树高度较大的那个的写法一:if语句 返回左右子树高度较大的那个的写法二:三目操作符 3.代码 4.反思 问题 出问题的代码 改进后的代码 执行结果 1.知识回顾&#xf…

分析排名靠前的一些自媒体平台,如何运用这些平台?

众所周知&#xff0c;现在做网站越来越难了&#xff0c;主要的原因还是因为流量红利时代过去了。并且搜索引擎都在给自己的平台做闭环改造。搜索引擎的流量扶持太低了。如百度投资知乎&#xff0c;给知乎带来很多流量扶持&#xff0c;也为自身内容不足做一个填补。 而我们站长…

2024大模型在软件开发中的具体应用有哪些?(附实践资料合集)

大模型在软件开发中的具体应用非常广泛&#xff0c;以下是一些主要的应用领域&#xff1a; 自动化代码生成与智能编程助手&#xff1a; AI大模型能够根据开发者的自然语言描述自动生成代码&#xff0c;减少手动编写代码的工作量。例如&#xff0c;GitHub Copilot工具就是利用AI…

Ubuntu网络配置(桥接模式, nat模式, host主机模式)

windows上安装了vmware虚拟机&#xff0c; vmware虚拟机上运行着ubuntu系统。windows与虚拟机可以通过三种方式进行通信。分别是桥接模式&#xff1b;nat模式&#xff1b;host模式 一、桥接模式 所谓桥接模式&#xff0c;也就是虚拟机与宿主机处于同一个网段&#xff0c; 宿主机…

3.系统学习-熵与决策树

熵与决策树 前言1.从数学开始信息量(Information Content / Shannon information)信息熵(Information Entropy)条件熵信息增益 决策树认识2.基于信息增益的ID3决策树3.C4.5决策树算法C4.5决策树算法的介绍决策树C4.5算法的不足与思考 4. CART 树基尼指数&#xff08;基尼不纯度…

SpringBoot + HttpSession 自定义生成sessionId

SpringBoot HttpSession 自定义生成sessionId 业务场景实现方案 业务场景 最近在做用户登录过程中&#xff0c;由于默认ID是通过UUID创建的&#xff0c;缺乏足够的安全性&#xff0c;决定要自定义生成 sessionId。 实现方案 正常的获取session方法如下&#xff1a; HttpSe…

破解海外业务困局:新加坡服务器托管与跨境组网策略

在当今全球化商业蓬勃发展的浪潮之下&#xff0c;众多企业将目光投向海外市场&#xff0c;力求拓展业务版图、抢占发展先机。而新加坡&#xff0c;凭借其卓越的地理位置、强劲的经济发展态势以及高度国际化的营商环境&#xff0c;已然成为企业海外布局的热门之选。此时&#xf…

数学课程评价系统:客户服务与教学支持

2.1 SSM框架介绍 本课题程序开发使用到的框架技术&#xff0c;英文名称缩写是SSM&#xff0c;在JavaWeb开发中使用的流行框架有SSH、SSM、SpringMVC等&#xff0c;作为一个课题程序采用SSH框架也可以&#xff0c;SSM框架也可以&#xff0c;SpringMVC也可以。SSH框架是属于重量级…

攻防世界web第三题file_include

<?php highlight_file(__FILE__);include("./check.php");if(isset($_GET[filename])){$filename $_GET[filename];include($filename);} ?>惯例&#xff1a; 代码审查&#xff1a; 1.可以看到include(“./check.php”);猜测是同级目录下有一个check.php文…

【深度学习环境】NVIDIA Driver、Cuda和Pytorch(centos9机器,要用到显示器)

文章目录 一 、Anaconda install二、 NIVIDIA driver install三、 Cuda install四、Pytorch install 一 、Anaconda install Step 1 Go to the official website: https://www.anaconda.com/download Input your email and submit. Step 2 Select your version, and click i…

寻找适合小户型的开源知识库open source knowledge base之路

寻找一个开源的知识库&#xff0c;为了把以前花很多时间收集的信息或是项目/课程资料放到一个容易归类和管理的私有自主系统中&#xff0c;以便更容易查阅&#xff0c;花更少时间收集、对比版本及分享等一系列管理工作&#xff0c;同时确保在需要时可以相对快速找到有用的资料&…

C语言勘破之路-最终篇 —— 预处理(上)

人无完人&#xff0c;持之以恒&#xff0c;方能见真我&#xff01;&#xff01;&#xff01; 共同进步&#xff01;&#xff01; 文章目录 一、预定义符号二、#define定义常量三.、#define定义宏四、带有副作用的宏参数五、宏替换的规则六、宏和函数的对比1.宏的优势2.函数的优…

学习threejs,THREE.RingGeometry 二维平面圆环几何体

&#x1f468;‍⚕️ 主页&#xff1a; gis分享者 &#x1f468;‍⚕️ 感谢各位大佬 点赞&#x1f44d; 收藏⭐ 留言&#x1f4dd; 加关注✅! &#x1f468;‍⚕️ 收录于专栏&#xff1a;threejs gis工程师 文章目录 一、&#x1f340;前言1.1 ☘️THREE.RingGeometry 圆环几…

Win11系统下Oracle11g数据库下载与安装使用教程

文章目录 一、Oracle下载与安装1.1 解压安装包1.2 开始安装Oracle11g1.2.1 用户 1.3 测试数据库是否配置成功1.4 了解一下 Oracle相关服务1.5 了解Oracle体系结构 二、使用工具连接数据库2.1 PL/ SQL 连接本地oracle 三、PL/ SQL远程访问数据库3.1 可能踩坑问题&#xff08;TNS…

数据结构(Java版)第六期:LinkedList与链表(一)

目录 一、链表 1.1. 链表的概念及结构 1.2. 链表的实现 专栏&#xff1a;数据结构(Java版) 个人主页&#xff1a;手握风云 一、链表 1.1. 链表的概念及结构 链表是⼀种物理存储结构上⾮连续存储结构&#xff0c;数据元素的逻辑顺序是通过链表中的引⽤链接次序实现的。与火车…

从零开始C++棋牌游戏开发之第三篇:游戏的界面布局设计

在游戏开发的旅途中&#xff0c;界面布局设计是一个充满创意和挑战的环节。对于棋牌类游戏而言&#xff0c;界面不仅仅是功能的载体&#xff0c;更是玩家与游戏互动的桥梁。一个清晰、直观且美观的界面可以显著提升游戏的用户体验。 在这篇文章中&#xff0c;我们将从功能需求…

计算机基础知识——数据结构与算法(五)(山东省大数据职称考试)

大数据分析应用-初级 第一部分 基础知识 一、大数据法律法规、政策文件、相关标准 二、计算机基础知识 三、信息化基础知识 四、密码学 五、大数据安全 六、数据库系统 七、数据仓库. 第二部分 专业知识 一、大数据技术与应用 二、大数据分析模型 三、数据科学 数据结构与算法…

数据库管理-第275期 Oracle 23ai:画了两张架构图(20241225)

数据库管理275期 2024-12-25 数据库管理-第275期 Oracle 23ai&#xff1a;画了两张架构图&#xff08;20241225&#xff09;1 系统管理分片2 用户定义分片总结 数据库管理-第275期 Oracle 23ai&#xff1a;画了两张架构图&#xff08;20241225&#xff09; 作者&#xff1a;胖…

增强路由器 路由器升级宽带速度

由器中DNS设置 DNS&#xff08;域名系统&#xff09;是什么&#xff1f; DNS将域名和IP地址相互映射的一个分布式数据库&#xff0c;能够使人更方便地访问互联网。DNS使用UDP端口53。 上网前提是&#xff1a;配置 IPv4地址、子网掩码 、网关、DNS 正确才能够上网 DNS填写规…