1 | /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
---|
2 | /* |
---|
3 | * ====================================================================== |
---|
4 | * AUTHOR: Wei Qiao <qiaow@purdue.edu> |
---|
5 | * Purdue Rendering and Perceptualization Lab (PURPL) |
---|
6 | * |
---|
7 | * Copyright (c) 2004-2012 HUBzero Foundation, LLC |
---|
8 | * |
---|
9 | * See the file "license.terms" for information on usage and |
---|
10 | * redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
11 | * ====================================================================== |
---|
12 | */ |
---|
13 | |
---|
14 | #include "common.cg" |
---|
15 | |
---|
16 | v2f main(a2v IN, |
---|
17 | uniform float4x4 modelViewProjMatrix, |
---|
18 | uniform float4x4 modelViewInv) |
---|
19 | { |
---|
20 | v2f OUT; |
---|
21 | |
---|
22 | // IN.Position is in eye coords |
---|
23 | float4 objPos = mul(modelViewInv, IN.Position); |
---|
24 | float4 eyePosObjSpace = mul(modelViewInv, float4(0,0,0,1)); |
---|
25 | |
---|
26 | //clip space vertex position |
---|
27 | //OUT.HPosition = mul(modelViewProjMatrix, mul(modelViewInv, IN.Position)); |
---|
28 | OUT.HPosition = mul(modelViewProjMatrix, objPos); |
---|
29 | |
---|
30 | //eye space texture coordinates |
---|
31 | OUT.TexCoord = IN.TexCoord; |
---|
32 | |
---|
33 | //world space eye position |
---|
34 | //OUT.EyeVector = normalize(-IN.Position.xyz); |
---|
35 | OUT.EyeVector = normalize(eyePosObjSpace - objPos); |
---|
36 | |
---|
37 | //world space light postion |
---|
38 | //OUT.Light = normalize(float3(1,1,1)-IN.Position.xyz); |
---|
39 | OUT.Light = normalize(mul(modelViewInv, float4(1,1,1,1))-objPos); |
---|
40 | |
---|
41 | return OUT; |
---|
42 | } |
---|