Unity Shader Sequence frame animation code, and by the way the Unity shader system

Source: Internet
Author: User
Tags line editor

Http://www.cnblogs.com/hellohuan/archive/2014/01/10/3512784.html One,
See Unity Forum Some people ask unity shader sequence frame animation, write shader I am good at Ah, on the homeopathic write a CG shader.
The code is simple, is to transform the UV sampling sequence frame map, fine art configuration line number and transformation speed.
 Shader "Hellohuan/hello_sequence" {Properties {_color ("Main Color", color) = (1,1,1,1) _maintex ("Base (RGB) Trans (A) ", 2D) =" White "{} _sizex (" Number of columns ", float) = 4 _sizey (" Number of rows ", float) = 4 _speed (" Playback speed ", float) = 200}subsh Ader {Tags {"rendertype" = "Opaque"} LOD 200cgprogram#pragma surface surf Lambert alphasampler2d _maintex;fixed4 _co Lor;uniform fixed _sizex;uniform fixed _sizey;uniform fixed _speed;struct Input {float2 uv_maintex;};    void Surf (Input in, InOut surfaceoutput o) {int index = floor (_time. x * _speed);    int indexy = Index/_sizex;    int Indexx = Index-indexy*_sizex;        Float2 Testuv = FLOAT2 (in.uv_maintex.x/_sizex, in.uv_maintex.y/_sizey);    testuv.x + = Indexx/_sizex;        Testuv.y + = Indexy/_sizey;    Fixed4 C = tex2d (_maintex, TESTUV) * _COLOR;        O.albedo = C.rgb;    O.alpha = C.A; O.albedo = FLOAT3 (Floor (_time. x * _speed), 1.0, 1.0);} Endcg}fallback "Transparent/vertexlit"} 

Shader,ui as follows:


Two
In the afternoon to see the art scene in a transparent sort of question, then asked them why the ground a big piece to use transparent material, using hollow more readily, a while the art ran to ask me, unity did not provide the skeleton of the shader, I opened the editor worried a look, and really basic is transparent material, QQ on the secret experts replied, In some mobile platforms, the skeleton will be more than transparent, a few years of rendering, this world view collapse, the expert's words are unfounded, its in a variety of real machine has been tested, given the reason is: OPENGLES2 standard does not support alphatest, are in the shader inside with Discare Engage, Mobile hardware implementation of all sorts of strange, at least IPHONE4 such a baseline machine cutout efficiency is very bleak.                                  Experts also gave a benchmark icon for the card. In some platforms, the number of blend frames is high I naturally believe it. Or to the art of writing a corresponding hollow shader, and give advice, transparent skeleton efficiency is very exaggerated, the best is the art through the hole to achieve the skeleton. (This company's art is still not so sentimental, the editor day dump more than 10 times what words do not say, we all bitter force, why embarrassed).

Write shader process My feeling, why does the rendering state not burst in the outside to the fine arts adjustment, must write in the shader? Unity rendering also supports transparent sort tweens, but the code for "Transparence + 1" must be written in shader. I'm going to write n shader to achieve the same shader calculation, but what are the effects of different rendering states? Increase the number of file resources do not say, this shader switching consumption can be larger than the consumption of rendering state switching, is it mobile graphics architecture? Does OGL differ so much from DirectX drawing? Unity is a cross-platform engine at least.

Have to marvel at the previous company involved in the written shader system, miss that although it is plagiarism unreal, let the art see the resulting write program-like pleasure through the pull knot connection attached to write shader shader template editor, There is also a shader instance editor, which can be configured separately for specific instance resources, to regulate some shader variables and render states, and to sort the rendering by shader type when rendering. or write your own engine is high efficiency ah.

But then the shader editor, also appeared in the production of the problem, one is: The art of creative ability is too strong, the color map RGB can be a matrix transformation, and finally even the algorithm can not understand but it is considered "cool" effect. Second, shader created too much bad management, change the impact on existing resources, increase the work of the audit template and add a new template work and the glorious fall in my graphics programmer's shoulder, after the tool or bitter force. Front-end time research Gb,gamebryo's shadertree design is very good, with the previous shader editor thought, each node contains its own input,shaderconst,vscode,pscode, each node through the input and output connection. There are a lot of problems: 1, too bad to expand, I have tried to add a hook-and-shadertree in the light of the calculation node, a great effort. 2, the arrangement is too many combinations, the last generation of shader through a variety of switch mappings called GUIDs to local, compiled into 2 files, this mechanism I have used. Is that the number of permutations is not controllable (shader must be pre-generated). GB's entire shader system is well-expanded, with the ability to use Shadertree by default, and to customize shader to support very many languages. Maintenance of the Gamebryo project, the whole project down to use more than 20 shader (not using GB comes with the Shadertree), commonly used more than 10, the art is here to pick, you can use it, can not complete the effect is also used, management is also good, but the expansion of the inconvenience. Unity also provides some built-in shader that can be used by art to choose from, as well as to add CG or shader code, but follow its shaderlib format. Before once despised the former shader assembly line editor, feel convenient art, but attracted more engineering problems, but unity of the way is too irresponsible, what kind of solution is more suitable for products, only the product itself know.

Unity shader Sequence frame animation code, and by the way, the unity shader system

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.