Book Image

Three.js Cookbook

By : Jos Dirksen
Book Image

Three.js Cookbook

By: Jos Dirksen

Overview of this book

Table of Contents (15 chapters)
Three.js Cookbook
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Creating a custom vertex shader


When you want to create advanced 3D effects with great performance, you can choose to write your own shaders. Shaders are programs that directly affect what your results look like and which colors are used to represent them. A shader always comes as a pair. A vertex shader determines what a geometry will look like, and a fragment shader will determine the resulting color. In this recipe, we'll show you how you can use your own custom vertex shader in Three.js.

Getting ready

WebGL and GLSL, which is the language in which you write shaders, are supported by most modern browsers. So, for this recipe, there aren't any additional steps you need to take before you can walk through this recipe. A good resource on GLSL is always the khronos website (http://www.khronos.org); they have a great tutorial (http://www.khronos.org/webgl/wiki/Tutorial) on WebGL that can help you better understand what we're doing in this recipe. For this specific recipe, we've provided two...