Posts

Showing posts with the label screenspace

fragment vertex/vertex fragment shaders in unity

Fragment Vertex shaders are a different beast to surface shaders. We are able to access vertex data and control pixels in much finer detail. Below is a simple frag/vert shader. The framework is similar to the surface shaders we've been looking at, only the usual CGPROGRAM block now sits within a Pass block, that lives in the SubShader. I haven't included a Properties block, but that remains unchanged. The first thing is we now have #pragmas for the frag and vert functions and also #include the UnityCG.cginc file, that contains lots of handy shader functions There are other files we can include when we are working with lighting and shadows. Next up in the framework is the "appdata" struct - it essentially has all the vertex data that our 3d model holds. Here we've go the vertex variable as a float4 type, and we use the POSITION attribute. The "vertex" name can be arbitrary. You can also list other data, such as normals, color (multiple) and UVs & they...