Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get full list of Unity shader properties

I am quite new to shaders and have been searching for a full list of Unity shader properties. I haven't found any such documentation. What I found was SL-Properties. Where can I find a full list of properties and their functions?

UPDATE

An example was given in SL-Properties showing the list of properties for a water shader namely, _WaveScale, _Fresnel, _BumpMap and so on. Knowing these specific properties make it easier to arrive at a solution. I recently tried coding something similar to a stroke before I found out about the following properties.

fixed _Stroke;
half4 _StrokeColor;  
like image 352
Nullititiousness Avatar asked Jun 10 '16 11:06

Nullititiousness


People also ask

What is Transform_tex?

TRANSFORM_TEX(texture coordinate/uvs, Texture variable) is used to transform texture by uvs and scale/bias property of Texture Map.

What is Unity shader cache?

The Shader Cache is a collection of parsed and pre-compiled shaders. During the play of a level, at runtime, necessary shaders will be requested with all the variables defined, such as lighting configuration and the usage of techniques like fog or transparency.

What is Texel size Unity?

The Texel Size node outputs size information for a selected texture. The reference Texture can be either selected via the Reference option on the Node Properties or connecting it to Tex input port. Note: Using Tex input port or Reference dropdown on Node Properties generate identical results.

What is the difference between a shader and a material Unity?

A material specifies one specific shader to use, and the shader used determines which options are available in the material. A shader specifies one or more textures variables that it expects to use, and the Material Inspector in Unity allows you to assign your own texture assets to these these texture variables.


2 Answers

Unity has it's own shader syntax called ShaderLab.

All the necessary information about it can be found on this website.
As for the properties, check out this link.

As nvidia is not supporting CG anymore, latest unity versions actually compile shaders using HLSL compiler and transform the resulting bytecode to GLSL. The CG shader code continues to work mostly unchanged. Nowadays you can take advantage of modern shader features, like compute shaders and tessellation, that weren't supported by CG, using HLSL syntax.

For example these shader properties:

_MyColor ("Some Color", Color) = (1,1,1,1) 
_MyVector ("Some Vector", Vector) = (0,0,0,0)
_MyRange ("My Range", Range (0, 1)) = 1
_MyFloat ("My float", Float) = 0.5 
_MyInt ("My Int", int) = 1 
_MyTexture2D ("Texture2D", 2D) = "white" {} 
_MyTexture3D ("Texture3D", 3D) = "white" {}
_MyCubemap ("Cubemap", CUBE) = "" {}

would be declared for access in Cg/HLSL code as:

fixed4 _MyColor;
float4 _MyVector;
float _MyRange;
float _MyFloat; 
int _MyInt;
sampler2D _MyTexture2D;
sampler3D _MyTexture3D;
samplerCUBE _MyCubemap;


Property types in ShaderLab map to Cg/HLSL variable types this way:

• Color and Vector properties map to float4, half4 or fixed4 variables.
• Range and Float properties map to float, half or fixed variables.
• Texture properties map to sampler2D variables for regular (2D) textures.
• Cubemaps map to samplerCUBE.
• 3D textures map to sampler3D.

like image 96
Hamid Avatar answered Sep 24 '22 21:09

Hamid


The properties of a shader in Unity are just a public variables visible to the engine, because Cg shader is wrapped into ShaderLab program.

You can see the structure of a shader in Unity at this presentation of Andy Touch: https://www.youtube.com/watch?v=zr1zQpdYG1Q&t=7m36s

So, when you see fixed _Stroke; half4 _StrokeColor; later in your code it's just an actual variables that are used by Cg program and binded to these properties.

Check adjacent Unity docs section to get to know how these properties are mapped to shader variables.

like image 39
Skyblade Avatar answered Sep 24 '22 21:09

Skyblade