-
-
Save EIZENHORN91/bc6c5be8958b9209b54d1c70d2c8c309 to your computer and use it in GitHub Desktop.
URP Unlit Texture example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shader "Universal Render Pipeline/Custom/UnlitTexture" | |
{ | |
Properties | |
{ | |
[MainColor] _BaseColor("BaseColor", Color) = (1,1,1,1) | |
[MainTexture] _BaseMap("BaseMap", 2D) = "white" {} | |
} | |
SubShader | |
{ | |
Tags { "RenderType"="Opaque" "RenderPipeline"="UniversalRenderPipeline"} | |
Pass | |
{ | |
Tags { "LightMode"="UniversalForward" } | |
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 | |
{ | |
float2 uv : TEXCOORD0; | |
float4 positionHCS : SV_POSITION; | |
}; | |
TEXTURE2D(_BaseMap); | |
SAMPLER(sampler_BaseMap); | |
CBUFFER_START(UnityPerMaterial) | |
float4 _BaseMap_ST; | |
half4 _BaseColor; | |
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 | |
{ | |
return SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, IN.uv) * _BaseColor; | |
} | |
ENDHLSL | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment