⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 predator.vsh

📁 hl2 source code. Do not use it illegal.
💻 VSH
字号:
vs.1.1
;------------------------------------------------------------------------------
; Constants specified by the app
;    c0      = (0, 1, 2, 0.5)
;	 c1		 = (1/2.2, 0, 0, 0)
;    c2      = camera position *in world space*
;    c4-c7   = modelViewProj matrix	(transpose)
;    c8-c11  = ViewProj matrix (transpose)
;    c12-c15 = model->view matrix (transpose)
;	 c16	 = [fogStart, fogEnd, fogRange, undefined]
;
; Vertex components (as specified in the vertex DECL)
;    $vPos    = Position
;	 $vTexCoord0.xy = TexCoord0
;------------------------------------------------------------------------------

#include "macros.vsh"

;------------------------------------------------------------------------------
; Vertex blending 
;------------------------------------------------------------------------------
&AllocateRegister( \$worldPos );
&AllocateRegister( \$worldNormal );
&SkinPositionAndNormal( $g_numBones, $worldPos, $worldNormal );

;------------------------------------------------------------------------------
; Transform the position from world to proj space
;------------------------------------------------------------------------------

&AllocateRegister( \$projPos );

dp4 $projPos.x, $worldPos, $cViewProj0
dp4 $projPos.y, $worldPos, $cViewProj1
dp4 $projPos.z, $worldPos, $cViewProj2
dp4 $projPos.w, $worldPos, $cViewProj3
mov oPos, $projPos


;------------------------------------------------------------------------------
; Fog
;------------------------------------------------------------------------------

&CalcFog( $worldPos, $projPos );

&FreeRegister( \$worldPos );

;------------------------------------------------------------------------------
; Transform the normal from world to proj space
;------------------------------------------------------------------------------

&AllocateRegister( \$projNormal );

; only do X and Y since that's all we care about
dp3 $projNormal.x, $worldNormal, $cViewProj0
dp3 $projNormal.y, $worldNormal, $cViewProj1

&FreeRegister( \$worldNormal );

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

; NOTE: projPos isn't projPos after this point. :)

; divide by z
rcp $projPos.w, $projPos.w
mul $projPos.xy, $projPos.w, $projPos.xy

; map from -1..1 to 0..1
mad $projPos.xy, $projPos.xy, $cHalf, $cHalf

; tweak with the texcoords based on the normal and $refractionamount
mad $projPos.xy, $projNormal.xy, -c94.xy, $projPos.xy		; FIXME

; invert y
add $projPos.y, $cOne, -$projPos.y

; hack scale for nvidia (Power of two texcoords are screwed.)
mul oT0.xy, $projPos.xy, c95.xy

&FreeRegister( \$projPos );
&FreeRegister( \$projNormal );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -