Initial commit

This commit is contained in:
2026-03-03 00:39:30 +05:00
commit fc01f07d9b
29933 changed files with 5353098 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
namespace UnityEditor.Rendering.Universal
{
internal static class ScriptTemplates
{
internal const string ScriptTemplatePath = "Packages/com.unity.render-pipelines.universal/Editor/ScriptTemplates/";
[MenuItem("Assets/Create/Shader/URP Unlit Shader", priority = 0)]
static void CreateUnlitURPShader()
{
ProjectWindowUtil.CreateScriptAssetFromTemplateFile($"{ScriptTemplatePath}UnlitURP.txt", "NewUnlitUniversalRenderPipelineShader.shader");
}
[MenuItem("Assets/Create/Scripting/URP Renderer Feature Script", priority = UnityEngine.Rendering.CoreUtils.Priorities.scriptingPriority)]
internal static void CreateNewRendererFeature()
{
ProjectWindowUtil.CreateScriptAssetFromTemplateFile($"{ScriptTemplatePath}ScriptableRendererFeature.txt", "NewURPRenderFeature.cs");
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: be08ea2d1e97b4edfb6c3b9eb27db748

View File

@@ -0,0 +1,98 @@
using System;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
using UnityEngine.Rendering.RenderGraphModule;
public class #SCRIPTNAME# : ScriptableRendererFeature
{
[SerializeField] #SCRIPTNAME#Settings settings;
#SCRIPTNAME#Pass m_ScriptablePass;
/// <inheritdoc/>
public override void Create()
{
m_ScriptablePass = new #SCRIPTNAME#Pass(settings);
// Configures where the render pass should be injected.
m_ScriptablePass.renderPassEvent = RenderPassEvent.AfterRenderingOpaques;
// You can request URP color texture and depth buffer as inputs by uncommenting the line below,
// URP will ensure copies of these resources are available for sampling before executing the render pass.
// Only uncomment it if necessary, it will have a performance impact, especially on mobiles and other TBDR GPUs where it will break render passes.
//m_ScriptablePass.ConfigureInput(ScriptableRenderPassInput.Color | ScriptableRenderPassInput.Depth);
// You can request URP to render to an intermediate texture by uncommenting the line below.
// Use this option for passes that do not support rendering directly to the backbuffer.
// Only uncomment it if necessary, it will have a performance impact, especially on mobiles and other TBDR GPUs where it will break render passes.
//m_ScriptablePass.requiresIntermediateTexture = true;
}
// Here you can inject one or multiple render passes in the renderer.
// This method is called when setting up the renderer once per-camera.
public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
{
renderer.EnqueuePass(m_ScriptablePass);
}
// Use this class to pass around settings from the feature to the pass
[Serializable]
public class #SCRIPTNAME#Settings
{
#NOTRIM#
}
class #SCRIPTNAME#Pass : ScriptableRenderPass
{
readonly #SCRIPTNAME#Settings settings;
public #SCRIPTNAME#Pass(#SCRIPTNAME#Settings settings)
{
this.settings = settings;
}
// This class stores the data needed by the RenderGraph pass.
// It is passed as a parameter to the delegate function that executes the RenderGraph pass.
private class PassData
{
#NOTRIM#
}
// This static method is passed as the RenderFunc delegate to the RenderGraph render pass.
// It is used to execute draw commands.
static void ExecutePass(PassData data, RasterGraphContext context)
{
#NOTRIM#
}
// RecordRenderGraph is where the RenderGraph handle can be accessed, through which render passes can be added to the graph.
// FrameData is a context container through which URP resources can be accessed and managed.
public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData)
{
const string passName = "Render Custom Pass";
// This adds a raster render pass to the graph, specifying the name and the data type that will be passed to the ExecutePass function.
using (var builder = renderGraph.AddRasterRenderPass<PassData>(passName, out var passData))
{
// Use this scope to set the required inputs and outputs of the pass and to
// setup the passData with the required properties needed at pass execution time.
// Make use of frameData to access resources and camera data through the dedicated containers.
// Eg:
// UniversalCameraData cameraData = frameData.Get<UniversalCameraData>();
UniversalResourceData resourceData = frameData.Get<UniversalResourceData>();
// Setup pass inputs and outputs through the builder interface.
// Eg:
// builder.UseTexture(sourceTexture);
// TextureHandle destination = UniversalRenderer.CreateRenderGraphTexture(renderGraph, cameraData.cameraTargetDescriptor, "Destination Texture", false);
// This sets the render target of the pass to the active color texture. Change it to your own render target as needed.
builder.SetRenderAttachment(resourceData.activeColorTexture, 0);
// Assigns the ExecutePass function to the render pass delegate. This will be called by the render graph when executing the pass.
builder.SetRenderFunc((PassData data, RasterGraphContext context) => ExecutePass(data, context));
}
}
}
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 51493ed8d97d3c24b94c6cffe834630b
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,58 @@
Shader "Custom/#SCRIPTNAME#"
{
Properties
{
[MainColor] _BaseColor("Base Color", Color) = (1, 1, 1, 1)
[MainTexture] _BaseMap("Base Map", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" }
Pass
{
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
struct Attributes
{
float4 positionOS : POSITION;
float2 uv : TEXCOORD0;
};
struct Varyings
{
float4 positionHCS : SV_POSITION;
float2 uv : TEXCOORD0;
};
TEXTURE2D(_BaseMap);
SAMPLER(sampler_BaseMap);
CBUFFER_START(UnityPerMaterial)
half4 _BaseColor;
float4 _BaseMap_ST;
CBUFFER_END
Varyings vert(Attributes IN)
{
Varyings OUT;
OUT.positionHCS = TransformObjectToHClip(IN.positionOS.xyz);
OUT.uv = TRANSFORM_TEX(IN.uv, _BaseMap);
return OUT;
}
half4 frag(Varyings IN) : SV_Target
{
half4 color = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, IN.uv) * _BaseColor;
return color;
}
ENDHLSL
}
}
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 4796721ff66d641078403679f98f5dbb
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: