Cg Programming/Unity

< Cg Programming

Cg programming in the game engine Unity is considerably easier than Cg programming for an OpenGL or Direct3D application. Import of meshes and images (i.e. textures) is supported by a graphical user interface; mipmaps and normal maps can be computed automatically; the most common vertex attributes and uniforms are predefined; OpenGL and Direct3D states can be set by very simple commands; etc.

Preliminaries

A free version of Unity can be downloaded for Windows and MacOS at Unity's download page. All of the included tutorials work with the free version. A few points should be noted:

Tutorials

Note that the tutorials assume that you read them in the order in which they are presented here, i.e. each tutorial will assume that you are familiar with the concepts and techniques introduced by previous tutorials. If you are new to Cg or Unity you should at least read through the tutorials in the “Basics” section. (Now you are warned!)

Basics

Transparent Surfaces

Basic Lighting

Basic Texturing

Textures in 3D

Environment Mapping

Variations on Lighting

Non-Standard Vertex Transformations

Miscellaneous

Missing Tutorials

Basic Features of Unity

Optimizing Shaders

Other Topics

< Cg Programming

Unless stated otherwise, all example source code on this page is granted to the public domain.
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.