TA/Unity2017. 2. 23. 20:16


float3 emissive = tex2D(_MainTexture,TRANSFORM_TEX(node_21.rg, _MainTexture)).rgb;



This line belongs to the fragment shader portion of the shader-combo, which means that this line is run for every pixel. Shader Forge currently has a tendency to do most of its calculations in the fragment shader, keeping only computations which regard the vertices themselves in the vertex shader. This doesn't have to be the case! Considering you often have more pixels to draw for rendering the object than the vertices which make up the model, you can save a lot of calculations by moving them over to the vertex shader. "But of course you need to do texture-lookups for every pixel" you might think for yourself (or out loud). This is of course true, but we certainly don't need to run the TRANSFORM_TEX function every pixel. It handles the Tiling & Offset inputs in the Material inspector. Best of all would be to get rid of it entirely, so if you're not using those inputs (which is often the case) you can just change that line to:



구글 번역


이 선은 셰이더 콤보의 조각 셰이더 부분에 속합니다. 즉이 선은 모든 픽셀에 대해 실행됩니다. 

Shader Forge는 현재 프래그먼트 셰이더에서 대부분의 계산을 수행하는 경향이 있으며 정점 셰이더에서 정점 자체를 고려한 계산 만 유지합니다. 

이것은 사실 일 필요는 없습니다! 


모델을 구성하는 정점보다 오브젝트 렌더링을 위해 더 많은 픽셀을 그리는 경우가 많으므로 정점 셰이더 위로 이동하여 많은 계산을 저장할 수 있습니다. 


"물론 모든 픽셀에 대해 텍스처 조회를 수행해야합니다."라고 생각할 수도 있습니다. 이것은 물론 사실이지만 TRANSFORM_TEX 함수를 모든 픽셀마다 실행할 필요는 없습니다. 


머티리얼 속성에서 타일링 및 오프셋 입력을 처리합니다. 


무엇보다도 가장 좋은 점은 완전히 없애 버리는 것입니다. 입력을 사용하지 않을 경우 (그 경우가 많음) 해당 행을 다음과 같이 변경할 수 있습니다.



수정 UV 코드(픽셀 -> 버텍스)

o.uv0 = v.texcoord0;   =>  o.uv0 = TRANSFORM_TEX(v.texcoord0, _NormalMap_A);

'TA > Unity' 카테고리의 다른 글

유니티 에셋 폴더의 예약된 이름들  (0) 2017.03.14
쉐이더 LOD(Shader Level of Detail)  (0) 2017.03.14
ngui - 계속 누르기 버튼 스크립트  (0) 2017.01.22
Unity 해상도 설정  (0) 2016.12.29
Unity Editer 단축키  (0) 2016.03.22
Posted by 프리랜서 디자이너