Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: Overlord on January 23, 2005, 09:04:04 am

Title: Dot3 directional bumpmapping
Post by: Overlord on January 23, 2005, 09:04:04 am
I found this in the Armada 2 directory, maybe the codemonkeys can use this.

Code: [Select]

; This shader does the per-vertex dot3 work.
; It transforms the light vector by the basis vectors
; passed into the shader.
; The basis vectors only need to change if the model's
; shape changes.
; The output vector is stored in the diffuse channel
; (use the menu to look at the generated light vector)
;
;#define v0 v0
;#define V_NORMAL v1
;#define V_TEXTURE v2
;#define V_S v3
;#define V_T v4
;#define V_SxT v5
;#define r3 r3
;
vs.1.0

; Transform position to clip space and output it
dp4 oPos.x, v0, c[2]
dp4 oPos.y, v0, c[3]
dp4 oPos.z, v0, c[4]
dp4 oPos.w, v0, c[5]

; transform light by basis vectors to put it
; into texture space
dp3 r3.x, v3.xyz, c[6]
dp3 r3.y, v4.xyz, c[6]
dp3 r3.z, v5.xyz, c[6]

; Normalize the light vector
dp3 r3.w, r3, r3
rsq r3.w, r3.w
mul r3, r3, r3.w

; Scale to 0-1
add r3, r3, c[0]
mul oD0, r3, c[1]

; Set alpha to 1
mov oD0.w, c[0].w

; output tex coords
mov oT0, v2
Title: Dot3 directional bumpmapping
Post by: Bobboau on January 23, 2005, 12:03:59 pm
wow great a vertex shader, if only we had a place in the code to put that...
Title: Dot3 directional bumpmapping
Post by: Taristin on January 23, 2005, 12:23:45 pm
It's up to you to change that. *hint-hint*