Skip to main content

Posts

Showing posts with the label SHADERS

[Shader] Transparent single color shader

This shader can give the object a solid color. And the alpha value can be adjusted by adjusting transparency. In Unity4.0 test without any problems. . . Shader "Custom / TransparentSingleColorShader" {  Properties {  _Color ("Color", Color) = (1.0, 1.0, 1.0, 1.0)  }  SubShader {  Tags {"RenderType" = "Transparent" "Queue" = "Transparent"}  Blend SrcAlpha OneMinusSrcAlpha  cull Off  LOD 200 CGPROGRAM  # pragma Surface Surf Lambert fixed4 _Color; / / Note: pointless Texture coordinate. I Could not GET Unity (or Cg)  / / to accept an empty or omit the Inputs Input Structure.  struct Input {  float2 uv_MainTex;  }; void Surf (Input IN, inout SurfaceOutput O) {  o.Albedo = _Color.rgb;  o.Emission = _Color.rgb; / / * _Color.a;  o.Alpha = _Color.a;  }  ENDCG  }  FallBack "Diffuse"  }

Shader Programmes

A shader programme is dedicated computer programme that runs in the graphics processing unit (GPU). Whenever we draw an object within our scene, we have to possess a shader programme allowed that defines how to modify the object into the proper location on our drawing surface, and how to color the area. In WebGL, shader programmes are made from 2 separate parts, which we create.    1 vertex shader, which describes how to transform the vertex positions of an object in 3d space, and ultimately onto the 2d canvas area.    1 fragment shader, which describes how to colour each pixel-sized fragment of the final 2d geometry. Because objects can overlap, we will often draw several fragments on top of each other before deciding the colour of the pixel. source [ antongerdelan.net ]