HLSL pragma require command reference
Color and High Dynamic Range (HDR)
Built-in shader variables referenceUnityâs built-in include files contain global variables for your shadersA program that runs on the GPU. More info
See in Glossary: things like current objectâs transformation matrices, light parameters, current time and so on. You use them in shader programs like any other variable, but if you include the relevant include file, you donât have to declare them.
For more information on include files, see Built-in include files.
TransformationsAll these matrices are float4x4
type, and are column major.
These variables will correspond to the CameraA component which creates an image of a particular viewpoint in your scene. The output is either drawn to the screen or captured as a texture. More info
See in Glossary that is rendering. For example during shadowmap rendering, they will still refer to the Camera component values, and not the âvirtual cameraâ that is used for the shadowmap projection.
x
is 1.0 (or â1.0 if currently rendering with a flipped projection matrix), y
is the cameraâs near plane, z
is the cameraâs far plane and w
is 1/FarPlane. _ScreenParams float4 x
is the width of the cameraâs target texture in pixelsThe smallest unit in a computer image. Pixel size depends on your screen resolution. Pixel lighting is calculated at every screen pixel. More infoy
is the height of the cameraâs target texture in pixels, z
is 1.0 + 1.0/width and w
is 1.0 + 1.0/height. _ZBufferParams float4 Used to linearize Z buffer values.
x
: 1 - far/near
, or â1 + far/near
if UNITY_REVERSED_Z
is set to 1. UNITY_REVERSED_Z
, refer to Branch based on platform features.y
: far/near
, or 1
if UNITY_REVERSED_Z
is set to 1. UNITY_REVERSED_Z
, refer to Branch based on platform features.z
: x / far
w
: y / far
x
is orthographic cameraâs width, y
is orthographic cameraâs height, z
is unused and w
is 1.0 when camera is orthographic, 0.0 when perspective. unity_CameraProjection float4x4 Cameraâs projection matrix. unity_CameraInvProjection float4x4 Inverse of cameraâs projection matrix. unity_CameraWorldClipPlanes[6] float4 Camera frustum plane world space equations, in this order: left, right, bottom, top, near, far. Time
Time is measured in seconds, and is scaled by the Time multiplier in your Projectâs Time settings. There is no built-in variable that provides access to unscaled time.
Name Type Value _Time float4 Time since level load (t/20, t, t*2, t*3), use to animate things inside the shaders. _SinTime float4 Sine of time: (t/8, t/4, t/2, t). _CosTime float4 Cosine of time: (t/8, t/4, t/2, t). unity_DeltaTime float4 Delta time: (dt, 1/dt, smoothDt, 1/smoothDt). LightingLight parameters are passed to shaders in different ways depending on which Rendering PathThe technique that a render pipeline uses to render graphics. Choosing a different rendering path affects how lighting and shading are calculated. Some rendering paths are more suited to different platforms and hardware than others. More info
See in Glossary is used, and which LightMode Pass Tag is used in the shader.
Forward renderingA rendering path that renders each object in one or more passes, depending on lights that affect the object. Lights themselves are also treated differently by Forward Rendering, depending on their settings and intensity. More info
See in Glossary (ForwardBase
and ForwardAdd
pass types):
Deferred shading, used in the lighting pass shader (all declared in UnityDeferredLibrary.cginc):
Name Type Value _LightColor float4 Light color. unity_WorldToLight float4x4 World-to-light matrix. Used to sample cookie & attenuation textures. unity_WorldToShadow float4x4[4] World-to-shadow matrices. One matrix for Spot Lights, up to four for directional light cascades.Spherical harmonics coefficients (used by ambient and light probes) are set up for ForwardBase
and Deferred
pass types. They contain 3rd order SH to be evaluated by world space normal (see ShadeSH9
from UnityCG.cginc). The variables are all half4 type, unity_SHAr
and similar names.
Vertex-lit rendering (Vertex
pass type):
Up to 8 lights are set up for a Vertex
pass type; always sorted starting from the brightest one. So if you want to render objects affected by two lights at once, you can just take first two entries in the arrays. If there are fewer than eight lights affecting the object, the rest will have their color set to black.
DC
component of the spherical harmonics data in the ambient probe. Otherwise this is black. UNITY_LIGHTMODEL_AMBIENT fixed4 Ambient lighting color (sky color in gradient ambient case). Legacy variable. unity_FogColor fixed4 Fog color. unity_FogParams float4 Parameters for fog calculation: (density / sqrt(ln(2)), density / ln(2), â1/(end-start), end/(end-start)). x is useful for Exp2 fog mode, y for Exp mode, z and w for Linear mode. Various Name Type Value unity_LODFade float4 Level-of-detail fade when using LODGroup. x is fade (0..1), y is fade quantized to 16 levels, z and w unused. _TextureSampleAdd float4 Set automatically by Unity for UI only based on whether the texture being used is in Alpha8 format (the value is set to (1,1,1,0)) or not (the value is set to (0,0,0,0)).
HLSL pragma require command reference
Color and High Dynamic Range (HDR)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4