Skip to Main Content
3D Game Engine Design, 2nd Edition
book

3D Game Engine Design, 2nd Edition

by David Eberly
November 2006
Intermediate to advanced content levelIntermediate to advanced
1040 pages
26h 31m
English
CRC Press
Content preview from 3D Game Engine Design, 2nd Edition
902 Chapter 20 Special Effects Using Shaders
20.2.2 Directional Lights
The vertex program for a single directional light is
void v_L1d
(
in float4 kModelPosition : POSITION,
in float3 kModelNormal : NORMAL,
out float4 kClipPosition : POSITION,
out float4 kVertexColor : COLOR,
uniform float4x4 WVPMatrix,
uniform float3 CameraModelPosition,
uniform float3 MaterialEmissive,
uniform float3 MaterialAmbient,
uniform float4 MaterialDiffuse,
uniform float4 MaterialSpecular,
uniform float3 Light0ModelDirection,
uniform float3 Light0Ambient,
uniform float3 Light0Diffuse,
uniform float3 Light0Specular,
uniform float4 Light0Attenuation)
{
// Transform the position from model space to clip space.
kClipPosition = mul(kModelPosition,WVPMatrix);
float fDiff, fSpec;
GetDirectionalLightFactors((float3)kModelPosition,kModelNormal, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

3D Game Engine Architecture

3D Game Engine Architecture

David Eberly
Blender 3D By Example - Second Edition

Blender 3D By Example - Second Edition

Oscar Baechler, Xury Greer
Computer Graphics

Computer Graphics

Alexey Boreskov, Evgeniy Shikin

Publisher Resources

ISBN: 9781482267303