summaryrefslogtreecommitdiff
path: root/materialsystem/stdshaders/vortwarp_vs11.vsh
blob: e5bb7ca8313fde3e972f836bb8f10fb2a6622715 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# STATIC: "UNLIT"					"0..1"
# STATIC:  "HALF_LAMBERT"			"0..1"
# DYNAMIC: "LIGHT_COMBO"			"0..21"
# DYNAMIC: "SKINNING"				"0..1"

vs.1.1
#include "macros.vsh"

$WARPPARAM = $SHADER_SPECIFIC_CONST_2;
$ENTITY_ORIGIN = $SHADER_SPECIFIC_CONST_3;

;------------------------------------------------------------------------------
; Vertex blending 
;------------------------------------------------------------------------------
&AllocateRegister( \$worldPos );
&AllocateRegister( \$worldNormal );
&AllocateRegister( \$projPos );

&SkinPositionAndNormal( $worldPos, $worldNormal );

alloc $tmp
sub $tmp.xyz, $worldPos, $ENTITY_ORIGIN
mul $tmp.xy, $tmp, $WARPPARAM
add $worldPos.xyz, $tmp, $ENTITY_ORIGIN
free $tmp

if( $SKINNING == 1 )
{
	&Normalize( $worldNormal );
}

;------------------------------------------------------------------------------
; Transform the position from world to view space
;------------------------------------------------------------------------------
dp4 $projPos.x, $worldPos, $cViewProj0
dp4 $projPos.y, $worldPos, $cViewProj1
dp4 $projPos.z, $worldPos, $cViewProj2
dp4 $projPos.w, $worldPos, $cViewProj3

mov oPos, $projPos

;------------------------------------------------------------------------------
; Fog - don't bother with water fog for intro effects
;------------------------------------------------------------------------------
&DepthFog( $projPos, "oFog" );
&FreeRegister( \$projPos );

;------------------------------------------------------------------------------
; Lighting
;------------------------------------------------------------------------------
if( $UNLIT )
{
	mov oD0, $cHalf
}
else
{
	&DoLighting( $worldPos, $worldNormal );
}

if( !$envmap )
{
	&FreeRegister( \$worldNormal );
}

;------------------------------------------------------------------------------
; Texture coordinates
;------------------------------------------------------------------------------

dp4 oT0.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_0
dp4 oT0.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_1

alloc $tmp2

dp4 $tmp2.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_0
dp4 $tmp2.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_1

add oT1.xy, $tmp2, $SHADER_SPECIFIC_CONST_4

free $tmp2

; YUCK!  This is to make texcoords continuous for mat_softwaretl
mov oT2, $cZero

&FreeRegister( \$worldPos );