블로그 이미지
Every unexpected event is a path to learning for you.

카테고리

분류 전체보기 (2731)
Unity3D (814)
Script (91)
Extensions (14)
Effect (3)
NGUI (77)
UGUI (8)
Physics (2)
Shader (36)
Math (1)
Design Pattern (2)
Xml (1)
Tips (200)
Link (22)
World (1)
AssetBundle (25)
Mecanim (2)
Plugins (68)
Trouble Shooting (68)
Encrypt (7)
LightMap (4)
Shadow (4)
Editor (8)
Crash Report (3)
Utility (9)
UnityVS (2)
Facebook SDK (2)
iTween (3)
Font (10)
Ad (14)
Photon (2)
IAP (1)
Google (8)
Android (45)
iOS (41)
Programming (474)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (228)
협업 (57)
3DS Max (3)
Game (12)
Utility (136)
Etc (96)
Link (32)
Portfolio (19)
Subject (90)
iOS,OSX (51)
Android (14)
Linux (5)
잉여 프로젝트 (2)
게임이야기 (3)
Memories (20)
Interest (38)
Thinking (38)
한글 (30)
PaperCraft (5)
Animation (408)
Wallpaper (2)
재테크 (18)
Exercise (3)
나만의 맛집 (3)
냥이 (10)
육아 (16)
Total
Today
Yesterday
03-29 00:00

[파일]


$NShader.zip



위 파일 설치하면 됨..



[참조]

Ok. Here's small update:
http://www.jostavo.net/NShader.rar (it's a new fork for 2013 by SilentSouls that uses embedded coloring, the one Nims mentioned before)

I've added support of .shader.compute.cginc (sorry just handling not native support, see attach)

*optional* - in VisualStudio go Tools > Extensions and Updates find NShader and uninstall it, reboot studio (it need to be restarted to remove files)
Make sure Visual Studio is closed

Who afraid to download my file, install one from jostavo.net and then create and add .reg:
For future updates:
{af99cc5c-2a8a-3547-b255-896525bc39d1} - is UUID for current build only!

To find one You needed - open NShader.pkgdef and look for:
Or after install go
There will be yours.
 

Attached Files:




[출처] http://forum.unity3d.com/threads/tutorial-how-to-use-nshader-with-unity-shaders.108995/

반응형
Posted by blueasa
, |

NGUI의 이미지를 밝게(Additive) 만들 필요가 있어서 간단하게 아틀라스가 사용할 쉐이더의 블랜딩만 수정했다.

 

[파일]

Unlit - Transparent Colored Additive.shader
0.00MB

수정하고 보니 수정된 쉐이더(Unlit - Transparent Colored Additive)가 다른 곳은 정상적으로 적용되는 데, 스크롤뷰(Grid) 사용부분은 적용이 되지 않았다.

 

그래서 검색하다보니 아래와 같은 내용이 있다.(링크 : http://www.tasharen.com/forum/index.php?topic=5180.0 )

NGUI's clipping is done by choosing a different shader with a similar name. Look at the existing shaders, for exmaple:

Unlit - Transparent Colored < -- used if no clipping is needed
Unlit - Transparent Colored 1 <-- used if there is 1 panel clipping the content
Unlit - Transparent Colored 2 <-- used if there are 2 panels clipping the content
Unlit - Transparent Colored 3 <-- used if there are 3 panels clipping the content

When making custom shaders, you would need to follow the same naming convention. The easiest thing to do is to just make a copy of at least two shaders (the first two) and modify them to suit your needs. In case of additive blending, all you would do is change the blend line from:

Code: [Select]
Blend SrcAlpha OneMinusSrcAlpha

to:

Code: [Select]
Blend One One

Source: https://docs.unity3d.com/Documentation/Components/SL-Blend.html

 

 

이름은 같고 뒤에 숫자가 달린 얘들은 Hidden이라 메뉴에 보이지 않는데 왜 있는지 궁금했었는데..

위 설명을 보니 뒤 숫자는 Panel Clipping의 개수였다.

NGUI에서 Panel을 체크해서 자동으로 Hidden인 애들 중에서 패널개수에 맞는 쉐이더를 찾아 쓰고 있다.

 

결론적으로 Clipping을 하는 스크롤뷰는 패널로 보기 때문에 숫자가 달린 애들 중 하나(1인가?)를 쓰는 것 같다.

그래서 숫자달린 파일들도 다 만들어 줬다.

 

[파일]

Unlit - Transparent Colored Additive 1.shader
0.00MB
Unlit - Transparent Colored Additive 2.shader
0.00MB
Unlit - Transparent Colored Additive 3.shader
0.00MB
Unlit - Transparent Colored Additive (TextureClip).shader
0.00MB
Unlit - Transparent Colored Additive (Packed) (TextureClip).shader
0.00MB

 

[결론]

NGUI에 쉐이더 추가할 때는 패널을 감안해서 뒤에 숫자(1~3)달린 애들도 같은 이름으로 함께 만들어 주자.

 

 

 

 

[기타참조]

 

[Unlit - Additive Colored]

Unlit - Additive Colored.shader
다운로드

 

http://sourceforge.net/p/merkabaos/git/ci/dbd2a9bddaba5e4580f4a93dc279255accecf19c/tree/Assets/NGUI/Resources/Shaders/Unlit%20-%20Additive%20Colored.shader

 
 
[Unlit Transparent Vertex Colored Additive]

 

 

반응형
Posted by blueasa
, |

Visual Studio 10 또는 12에서 Shader Syntax Highlighting하기


1. http://nshader.codeplex.com/ 에서 가서 nShader를 다운을 받고 플러그인 설치.


2. NShader.pkgdef 파일 메모장 또는 기타 에디터로 열기. (2012의 경우)

C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\(NShader 폴더 : 컴퓨터마다 폴더명이 다르다. )


3. Unity3d .shader 확장자를 위해 "CodeBase"="$PackageFolder$\NShader.dll" 코드 아래에 다음을 추가한다.

[$RootKey$\Languages\File Extensions\.shader]

@="{4c554917-0eb7-3742-9f6b-f2f529fc6729}"

[$RootKey$\Languages\File Extensions\.cginc]

@="{4c554917-0eb7-3742-9f6b-f2f529fc6729}"


4. 레지스트리에서 아래 경로 삭제

- HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\FontAndColors\Cache 

- HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0_Config 



출처 : http://workspage.net/37

반응형

'Unity3D > Shader' 카테고리의 다른 글

Unity3d Shader Syntax Highlighting(Visual Studio 2010/2012/2013)  (0) 2015.03.24
[NGUI] Unlit - Transparent Colored Additive  (4) 2015.01.27
Unity Shader 공부  (0) 2014.07.16
Shader Code  (0) 2014.07.16
유니티 셰이더의 기초  (0) 2014.06.28
Posted by blueasa
, |

Unity Shader 공부

Unity3D/Shader / 2014. 7. 16. 13:54

Link : Unity Shader 공부

반응형

'Unity3D > Shader' 카테고리의 다른 글

[NGUI] Unlit - Transparent Colored Additive  (4) 2015.01.27
Unity3d Shader Syntax Highlighting(Visual Studio 2010 또는 2012)  (0) 2014.07.21
Shader Code  (0) 2014.07.16
유니티 셰이더의 기초  (0) 2014.06.28
Unity Shader Reference  (0) 2014.06.24
Posted by blueasa
, |

Shader Code

Unity3D/Shader / 2014. 7. 16. 10:21

출처 : http://wiki.unity3d.com/index.php/Shader_Code#Built-In


Shader Code

DISCLAIMER: This page is written by Unity users and is built around their knowledge. Some users may be more knowledgeable than others, so the information contained within may not be entirely complete or accurate.

Contents

 [hide

Structures

Unity's shaders use structures to pass information down the rendering pipeline.

Application to Vertex Shader Structure (appdata)

The first structure passes raw information about the geometry being rendered to the vertex shader. To create your own appdata structure, they must conform to the formatting and limitations outlined below. See the built-in appdata structures below for an example.

Format

 Structure:
 struct [Name]
 {
     [One or more Fields]
 };
 
 Field:
 [Type] [Name] : [Tag];

Acceptable Fields

The following fields can be written in the structure in any order.

Type(s)NameTagNotes
float4vertexPOSITIONThe position of the vertex in local space (model space)
float3normalNORMALThe normal of the vertex
float4texcoordTEXCOORD0The UV coordinate for that vertex. Mesh being rendered must have at least one texture coordinate. The third and fourth floats in the vector represent a 3rd UV dimension and a scale factor, and are rarely if ever used.
float4texcoord1TEXCOORD1A second set of UV coordinates for the vertex. (Only two are supported.) Always present, but often not used.
float4tangentTANGENTAll meshes have either calculated or imported tangents.
float4colorCOLORThe color value of this vertex specifically. Mesh must have colors defined, otherwise they default to <TODO>.

<TODO: Complete this list>

Built-In

Base structure, contains the least amount of data that most shaders will use.

 struct appdata_base
 {
     float4 vertex   : POSITION;  // The vertex position in model space.
     float3 normal   : NORMAL;    // The vertex normal in model space.
     float4 texcoord : TEXCOORD0; // The first UV coordinate.
 };

Tangents included - tangents are used to rotate the normals of normal maps when the normal maps are also rotated. Use this structure if you wish to intervene in their calculation process and manipulate them. If you do not want to manipulate tangents you may use the base structure instead since they will be calculated anyway. <TODO: Determine if the tangents need to be transformed if they are manipulated here, or if they can be left in model space.>

 struct appdata_tan
 {
     float4 vertex   : POSITION;  // The vertex position in model space.
     float3 normal   : NORMAL;    // The vertex normal in model space.
     float4 texcoord : TEXCOORD0; // The first UV coordinate.
     float4 tangent  : TANGENT;   // The tangent vector in model space (used for normal mapping).
 };

All the possible fields you can derive from a mesh about to be rendered are in this structure.

 struct appdata_full
 {
     float4 vertex    : POSITION;  // The vertex position in model space.
     float3 normal    : NORMAL;    // The vertex normal in model space.
     float4 texcoord  : TEXCOORD0; // The first UV coordinate.
     float4 texcoord1 : TEXCOORD1; // The second UV coordinate.
     float4 tangent   : TANGENT;   // The tangent vector in Model Space (used for normal mapping).
     float4 color     : COLOR;     // Per-vertex color
 };

Vertex Shader to Fragment Shader Structure (v2f)

The second structure contains information generated by the vertex shader which is passed to the fragment shader. The vertex shader calculates and returns these values on a per-vertex basis. An interpolator then then calculates these same values on a per-pixel basis when the connected polygons are rasterized. The interpolated values are then used by the fragment shader. To create your own v2f structure, they must conform to the formatting and limitations outlined below. See the built-in v2f structures below for an example.

Format

 Structure:
 struct [Name]
 {
     [One or more Fields]
 };
 
 Field:
 [Type] [Name] : [Tag];
 or
 [Type] [Name];

Acceptable Fields

The following fields can be written in the structure in any order.

Type(s)NameTagDescriptionNotes
float4posSV_POSITIONThe position of the vertex after being transformed into projection space.Structure must contain exactly one field tagged SV_POSITION.
float3NORMALThe normal of the vertex after being transformed into view space.Structure must contain exactly one field tagged with NORMAL if the subsequent surface or fragment shader uses normals. <TODO: Verify>
float4uvTEXCOORD0First texture coordinate, or UV.
float4TEXCOORD1Second texture coordinate, or UV.Currently only two UV coordinates are supported per vertex, but you may bypass this by defining custom fields which act as additional UV coordinates.
float4TANGENTTangents are used to correct normal maps when they are viewed from different angles. Normal maps have incorrect values when they are rotated without processing from tangents.
float4, fixed4diffCOLOR0Vertex color, interpolated across the triangle. This value could correspond to anything depending on how the fragment shader interprets it.
float4, fixed4specCOLOR1Vertex color, interpolated across the triangle. This value could correspond to anything depending on how the fragment shader interprets it.
AnyAnyUser-defined fields which can be assigned any value.Custom fields can have any type and any name, but may not have a tag. The upper limit on the number of custom fields is not known. <TODO: Research>

<TODO: Complete this list>

Built-In

This structure is designed specifically for implementing image effects. See also vert_img.

 struct v2f_img 
 {
    float4 pos : SV_POSITION;
    half2 uv   : TEXCOORD0;
 };
 struct v2f_vertex_lit 
 {
   float2 uv	: TEXCOORD0;
   fixed4 diff	: COLOR0;
   fixed4 spec	: COLOR1;
 };  

<TODO: Complete list.>

Surface/Fragment Shader to Lighting Shader Structure (SurfaceOutput)

The third and final structure contains pixel values returned by either a surface or fragment shader. They are read as input to a lighting shader (such as Lambert, BlinnPhong or a custom lighting model) which then returns a single RGBA color value.

Format

 Structure:
 struct [Name]
 {
     [One or more Fields]
 };
 
 Field:
 [Type] [Name];

Note that tags are not used in SurfaceOutput structures.

Acceptable Fields

The following fields can be written in the structure in any order.

Type(s)NameDescriptionNotes
float3, fixed3, half3AlbedoThe reflectance color and intensity of diffuse lighting. Diffuse lighting approximates the appearance of rough surfaces. Diffuse lighting calculations are multiplied with this value.
float3, fixed3, half3NormalA vector representing the direction the surface is facing in screen space.
float3, fixed3, half3EmissionThe color and intensity of emissive lighting. The emissive color will appear even in a completely black scene with no lights. Emissive lighting appears as though light is being created from the surface itself and is generally the most apparent in the absence of light. Glow-in-the-dark objects and computer instruments are examples of surfaces which might use emissive lighting.
float, fixed, halfSpecularThe reflectance color and intensity of specular lighting. Specular lighting approximates the appearance of shiny surfaces. Specular lighting calculations are multiplied with this value.
float, fixed, halfGlossThe sharpness of specular lighting. The higher this value is, the smaller the specular highlights will be. The range is 0-1, where 1 creates a pin-point highlight, and 0 is broad/flat. <TODO: Determine the exponent values this range uses.>
float, fixed, halfAlphaUsed for transparency, if render states are set up for alpha blending and the lighting shader interprets it as transparency (and it does by default).
AnyAnyUser-defined fields which can be assigned any value.Custom fields can have any type and any name, but may not have a tag. The upper limit on the number of custom fields is not known. <TODO: Research>

<TODO: Can different types be used other than the ones listed? Example, Albedo using float4 instead of float3.>

Built-In

Default structure; must be used unless you have implemented your own custom lighting shader.

 struct SurfaceOutput
 {
     half3 Albedo;
     half3 Normal;
     half3 Emission;
     half Specular;
     half Gloss;
     half Alpha;
 };


Surface Shader input structure (Input)

The input structure Input generally has any texture coordinates needed by the shader. Texture coordinates must be named "uv" followed by texture name (or start it with "uv2" to use second texture coordinate set).

Additional values that can be put into Input structure:

  • float3 viewDir - will contain view direction, for computing Parallax effects, rim lighting etc.
  • float4 with COLOR semantic - will contain interpolated per-vertex color.
  • float4 screenPos - will contain screen space position for reflection effects. Used by WetStreet shader in Dark Unity for example.
  • float3 worldPos - will contain world space position.
  • float3 worldRefl - will contain world reflection vector if surface shader does not write to o.Normal. See Reflect-Diffuse shader for example.
  • float3 worldNormal - will contain world normal vector if surface shader does not write to o.Normal.
  • float3 worldRefl; INTERNAL_DATA - will contain world reflection vector if surface shader writes to o.Normal. To get the reflection vector based on per-pixel normal map, use WorldReflectionVector (IN, o.Normal). See Reflect-Bumped shader for example.
  • float3 worldNormal; INTERNAL_DATA - will contain world normal vector if surface shader writes to o.Normal. To get the normal vector based on per-pixel normal map, use WorldNormalVector (IN, o.Normal).

Functions

ShaderLab comes packaged with built-in, or "intrinsic" functions. Many of them are based on the intrinsic functions provided by shader languages like CG, GLSL and HLSL, while others are unique to ShaderLab.

<TODO: Complete this section.>

See Also

Preprocessor Directives

Preprocessor directives are special statements which tell the compiler specifically how to handle the code. They are similar to tags and render states. Below is a list of different directives:

Preprocessor DirectiveOptionArgumentDescriptionNotes
#include(Path of filename in quotations)Includes code written in another file with the extension .cginc. For example,#include "UnityCG.cginc"is commonly used and contains several helper functions. You may write your own CGINC files as well. SeeBuilt-In CGINC files for a list of include files already provided by Unity.
#pragmatarget2.0 or defaultCompiles the shader under shader model 2. Model 2 has more limitations than 3 but is more compatible. Uses shader model 1.1 for vertex shaders.Vertex: 128 instruction limit. Fragment: 96 instruction limit (32 texture + 64 arithmetic), 16 temporary registers and 4 texture indirections.
3.0Compiles the shader under shader model 3. Model 3 is more powerful and flexible than 2 but is less compatible.Vertex: no instruction limit. Fragment: 1024 instruction limit (512 texture + 512 arithmetic), 32 temporary registers and 4 texture indirections. It is possible to override these limits using#pragma profileoptiondirective. For example, #pragma profileoption MaxTexIndirections=256raises texture indirections limit to 256. See #pragma profileoption for more information. Note that some shader model 3.0 features, like derivative instructions, aren't supported by vertex or fragment shaders. You can use #pragma glsl to translate to GLSL instead which has fewer restrictions. See#pragma glsl for more information.
surface(Name of surface shader)Tells the compiler which function is meant to be used as a surface shader.When writing custom surface shaders, this option MUST be written, and it MUST be written first.
(Name of lighting shader, minus the "Lighting" prefix. For example "LightingCookTorrence()" would be supplied here as "CookTorrence".)Tells the compiler which function is meant to be used as a lighting model. See Built-In lighting modelsfor a list of lighting models already provided by Unity. You may write your own lighting models as well.When writing custom surface shaders, this option MUST be written, and it MUST be written second.
alphaTest:(Property Name)Similar to therender stateAlphaTest, except it only culls alpha values less than or equal to the provided value.Both the alpha test render state and preprocessor directive can be used together although their interaction is unclear. Unlike AphaTest, you may only use properties (like _Cutoff) and not constants (like 0.5).
vertex(Name of vertex shader)Tells the compiler which function is meant to be used as a vertex shader.When writing custom vertex or fragment shaders with #pragma target 3.0 the compiler MUST know which vertex shader to use. You may provide your own vertex shader but if not you may use one of Unity's built in vertex shaders.
fragment(Name of fragment shader)Tells the compiler which function is meant to be used as a fragment shader.When writing custom vertex or fragment shaders with #pragma target 3.0 this directive MUST be written. This option MUST be written first with any shader model. You may provide your own fragment shader but if not you may use one of Unity's built in fragment shaders.
vertex:(Name of vertex shader)Tells the compiler which function is meant to be used as a vertex shader.When writing custom vertex or fragment shaders with #pragma target 3.0 the compiler MUST know which vertex shader to use. You may provide your own vertex shader but if not you may use one of Unity's built in vertex shaders.
fragmentoption<TODO: Add option here.><TODO: Add description here.><TODO: Add option notes here.>This directive has no effect on vertex programs or programs that are compiled to non-OpenGL targets.
<TODO: Add option here.><TODO: Add description here.><TODO: Add option notes here.>
only_renderers
exclude_renderers
glsl
profileoption

See Also


반응형

'Unity3D > Shader' 카테고리의 다른 글

Unity3d Shader Syntax Highlighting(Visual Studio 2010 또는 2012)  (0) 2014.07.21
Unity Shader 공부  (0) 2014.07.16
유니티 셰이더의 기초  (0) 2014.06.28
Unity Shader Reference  (0) 2014.06.24
Rendering Order - Queue tag  (0) 2014.06.24
Posted by blueasa
, |


[링크]

 http://jinhomang.tistory.com/category/%28%EC%97%B0%EC%9E%AC%29%20%EC%9C%A0%EB%8B%88%ED%8B%B0%20%EC%85%B0%EC%9D%B4%EB%8D%94%EC%9D%98%20%EA%B8%B0%EC%B4%88

반응형

'Unity3D > Shader' 카테고리의 다른 글

Unity Shader 공부  (0) 2014.07.16
Shader Code  (0) 2014.07.16
Unity Shader Reference  (0) 2014.06.24
Rendering Order - Queue tag  (0) 2014.06.24
UnityDiffuseLightmap.shader by jimfleming  (0) 2014.06.23
Posted by blueasa
, |

Unity Shader Reference

Unity3D/Shader / 2014. 6. 24. 22:32

Link : http://docs.unity3d.com/Manual/SL-Reference.html

반응형

'Unity3D > Shader' 카테고리의 다른 글

Shader Code  (0) 2014.07.16
유니티 셰이더의 기초  (0) 2014.06.28
Rendering Order - Queue tag  (0) 2014.06.24
UnityDiffuseLightmap.shader by jimfleming  (0) 2014.06.23
쉐이더 자료 많은 사이트..  (0) 2014.04.03
Posted by blueasa
, |

Rendering Order - Queue tag

You can determine in which order your objects are drawn using the Queue tag. A Shader decides which render queue its objects belong to, this way any Transparent shaders make sure they are drawn after all opaque objects and so on.

There are four pre-defined render queues, but there can be more queues in between the predefined ones. The predefined queues are:

  • Background - this render queue is rendered before any others. It is used for skyboxes and the like.
  • Geometry (default) - this is used for most objects. Opaque geometry uses this queue.
  • AlphaTest - alpha tested geometry uses this queue. It’s a separate queue from Geometry one since it’s more efficient to render alpha-tested objects after all solid ones are drawn.
  • Transparent - this render queue is rendered after Geometry and AlphaTest, in back-to-front order. Anything alpha-blended (i.e. shaders that don’t write to depth buffer) should go here (glass, particle effects).
  • Overlay - this render queue is meant for overlay effects. Anything rendered last should go here (e.g. lens flares).
Shader "Transparent Queue Example" {
     SubShader {
        Tags {"Queue" = "Transparent" }
        Pass {
            // rest of the shader body...
        }
    }
}

An example illustrating how to render something in the transparent queue

Geometry render queue optimizes the drawing order of the objects for best performance. All other render queues sort objects by distance, starting rendering from the furthest ones and ending with the closest ones.

For special uses in-between queues can be used. Internally each queue is represented by integer index;Background is 1000, Geometry is 2000, AlphaTest is 2450, Transparent is 3000 and Overlay is 4000. If a shader uses a queue like this:

Tags { "Queue" = "Geometry+1" }

This will make the object be rendered after all opaque objects, but before transparent objects, as render queue index will be 2001 (geometry plus one). This is useful in situations where you want some objects be always drawn between other sets of objects. For example, in most cases transparent water should be drawn after opaque objects but before transparent objects.

RenderType tag

RenderType tag categorizes shaders into several predefined groups, e.g. is is an opaque shader, or an alpha-tested shader etc. This is used by Shader Replacement and in some cases used to produce camera’s depth texture.

ForceNoShadowCasting tag

If ForceNoShadowCasting tag is given and has a value of “True”, then an object that is rendered using this subshader will never cast shadows. This is mostly useful when you are using shader replacement on transparent objects and you do not wont to inherit a shadow pass from another subshader.

IgnoreProjector tag

If IgnoreProjector tag is given and has a value of “True”, then an object that uses this shader will not be affected byProjectors. This is mostly useful on semitransparent objects, because there is no good way for Projectors to affect them.

See Also

Passes can be given Tags as well, see Pass Tags.



출처 : http://docs.unity3d.com/Manual/SL-SubshaderTags.html


========================================================================================================


ShaderLab syntax: SubShader Tags

서브 쉐이더는 그들이 렌더링 엔젠으로 렌더되어질 것이 어떻게 그리고 언제 기대될지를 말하는 태그를 사용합니다.

Syntax

Tags { "TagName1" = "Value1" "TagName2" = "Value2}
Value1를 가지는 TagName1 그리고Value2를 가지는 TagName2 를 지정합니다. 사용자는 사용자가 좋아하는 만큼 많은 태그를 가질 수 있습니다.

Details

태그는 기본적으로 키-값 쌍입니다. SubShader 안에서 태그는 렌더링 순서와 서브 쉐이더의 다른 파라미터를 결정하기 위해서 사용됩니다.

Rendering Order - Queue tag

사용자는 사용자의 물체가 Queue 태그를 사용해서 그려지는 순서를 결정할 수 있습니다. 쉐이더는 어떠한 투명한 쉐이더라도 그들이 모든 불투명한 물체들 이후에 그려지는 것을 확실시하는 방법으로 어떤 렌더 큐로 물체가 속하는지를 결정합니다.

4개의 미리 정의된 렌더 큐가 있으나 미리 정의된 것들 사이에는 더 많은 큐가 있을 수 있습니다. 미리 정의된 큐는 다음과 같습니다:

  • Background - 이 렌더 큐는 다른 것들 전에 렌더됩니다. 스카이 박스와 비슷한 것들의 위해 사용됩니다.
  • Geometry (default) - 대부분의 물체를 위해서 사용됩니다. 불투명한 기하가 이 큐를 사용합니다.
  • Transparent - 이 렌더 큐는 기하 이후에 뒤에서 앞으로의 순서대로 그려집니다. 알파 블렌딩되는 어떠한 것(즉. 깊이 버퍼에 쓰여지지 않는 쉐이더)이라도 여기도 가야만 합니다 (유리, 입자 효과).
  • Overlay - 이 렌더 큐는 기하 이후에 뒤에서 앞으로의 순서대로 그려집니다. 알파 블렌딩되는 어떠한 것(즉. 깊이 버퍼에 쓰여지지 않는 쉐이더)이라도 여기도 가야만 합니다 (유리, 입자 효과).
Shader "Transparent Queue Example" {
     SubShader {
        Tags {"Queue" = "Transparent" }
        Pass {
            // rest of the shader body...
        }
    }
} 

투명한 큐에서 렌더하는 법을 설명하는 예

Geometry 렌더 큐는 최고의 성능을 위해서 물체의 그려지는 순서를 최적화 합니다. 모든 다른 렌더 큐는 물체를 거리에 따라 정렬합니다. 먼 것부터 시작해서 가까운 순으로 그려집니다.

특별한 사용을 위해서 큐들 사이에서 사용될 수 있습니다. 내부적으로 각각의 큐는 정수 인덱스에 의해 표현됩니다; Background 은 1000, Geometry 는 2000, Transparent 도는 3000 그리고 오버레이는 4000. 쉐이더가 이것과 같은 큐를 사용한다면:

Tags { "Queue" = "Geometry+1" }

이것은 물체를 모든 불투명 물체 이후에 그러나 투명한 물체를 이전에 렌더 큐 인덱스가 2001일 것처럼 그려지도록 만들 것입니다. 이것은 사용자가 어떠한 물체들을 항상 물체들의 다른 세트들 사이에서 그려지도록 원하는 상황에 유용합니다. 예를 들어, 대부분의 경우에 투명한 물은 불투명한 물체 이후에 그러나 투명한 물체 이전에 그려져야 합니다.

IgnoreProjector tag

IgnoreProjector 태그가 주어지고 "True" 값을 가진다면 그 때 이런 쉐이더를 사용하는 물체는 Projectors에 의해 영향을 받지 않을 것입니다. Projectors가 그들에게 영향을 주는 좋은 방법이 없기 때문에 이것은 주로 반투명한 물체들 위에서 유용합니다.

See Also

패스에 태그 역시 주어질 수 있습니다. Pass Tags를 살펴보시기 바랍니다.


출처 : http://unitykoreawiki.com/index.php?n=KrMain.SL-SubshaderTags

반응형

'Unity3D > Shader' 카테고리의 다른 글

유니티 셰이더의 기초  (0) 2014.06.28
Unity Shader Reference  (0) 2014.06.24
UnityDiffuseLightmap.shader by jimfleming  (0) 2014.06.23
쉐이더 자료 많은 사이트..  (0) 2014.04.03
Toon/Tf2Shader  (0) 2013.07.19
Posted by blueasa
, |

Link : https://gist.github.com/jimfleming/5937437#file-unitydiffuselightmap-shader



Shader "Diffuse Lightmap" {
 
Properties {
_MainTex ("Texture 1", 2D) = "white" {}
}
 
SubShader {
Tags { "RenderType" = "Opaque" }
 
Pass {
// Disable lighting, we're only using the lightmap
Lighting Off
 
CGPROGRAM
// Must be a vert/frag shader, not a surface shader: the necessary variables
// won't be defined yet for surface shaders.
#pragma vertex vert
#pragma fragment frag
 
#include "UnityCG.cginc"
 
struct v2f {
float4 pos : SV_POSITION;
float2 uv0 : TEXCOORD0;
float2 uv1 : TEXCOORD1;
};
 
struct appdata_lightmap {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
float2 texcoord1 : TEXCOORD1;
};
 
// These are prepopulated by Unity
sampler2D unity_Lightmap;
float4 unity_LightmapST;
 
sampler2D _MainTex;
float4 _MainTex_ST; // Define this since its expected by TRANSFORM_TEX; it is also pre-populated by Unity.
 
v2f vert(appdata_lightmap i) {
v2f o;
o.pos = mul(UNITY_MATRIX_MVP, i.vertex);
 
// UnityCG.cginc - Transforms 2D UV by scale/bias property
// #define TRANSFORM_TEX(tex,name) (tex.xy * name##_ST.xy + name##_ST.zw)
o.uv0 = TRANSFORM_TEX(i.texcoord, _MainTex);
 
// Use `unity_LightmapST` NOT `unity_Lightmap_ST`
o.uv1 = i.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
return o;
}
 
half4 frag(v2f i) : COLOR {
half4 main_color = tex2D(_MainTex, i.uv0);
 
// Decodes lightmaps:
// - doubleLDR encoded on GLES
// - RGBM encoded with range [0;8] on other platforms using surface shaders
// inline fixed3 DecodeLightmap(fixed4 color) {
// #if defined(SHADER_API_GLES) && defined(SHADER_API_MOBILE)
// return 2.0 * color.rgb;
// #else
// return (8.0 * color.a) * color.rgb;
// #endif
// }
 
main_color.rgb *= DecodeLightmap(tex2D(unity_Lightmap, i.uv1));
return main_color;
}
ENDCG
}
}
}



반응형

'Unity3D > Shader' 카테고리의 다른 글

Unity Shader Reference  (0) 2014.06.24
Rendering Order - Queue tag  (0) 2014.06.24
쉐이더 자료 많은 사이트..  (0) 2014.04.03
Toon/Tf2Shader  (0) 2013.07.19
Toon/Basic with Alpha  (0) 2013.07.19
Posted by blueasa
, |

링크 : http://usroom.tistory.com/

반응형

'Unity3D > Shader' 카테고리의 다른 글

Rendering Order - Queue tag  (0) 2014.06.24
UnityDiffuseLightmap.shader by jimfleming  (0) 2014.06.23
Toon/Tf2Shader  (0) 2013.07.19
Toon/Basic with Alpha  (0) 2013.07.19
Toon/Lighted with Alpha  (0) 2013.07.19
Posted by blueasa
, |