Files
Client/GameTools/Zallad3D SceneClass/Shaders/1_BumpDiffSpec.vsh
LGram16 dd97ddec92 Restructure repository to include all source folders
Move git root from Client/ to src/ to track all source code:
- Client: Game client source (moved to Client/Client/)
- Server: Game server source
- GameTools: Development tools
- CryptoSource: Encryption utilities
- database: Database scripts
- Script: Game scripts
- rylCoder_16.02.2008_src: Legacy coder tools
- GMFont, Game: Additional resources

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 20:17:20 +09:00

220 lines
3.9 KiB
GLSL

;#define CV_ZERO 0
;#define CV_ONE 1
;#define CV_WORLDVIEWPROJ_0 2
;#define CV_WORLDVIEWPROJ_1 3
;#define CV_WORLDVIEWPROJ_2 4
;#define CV_WORLDVIEWPROJ_3 5
;#define CV_WORLDVIEW_0 6
;#define CV_WORLDVIEW_1 7
;#define CV_WORLDVIEW_2 8
;#define CV_WORLDVIEW_3 9
;#define CV_WORLDVIEWIT_0 10
;#define CV_WORLDVIEWIT_1 11
;#define CV_WORLDVIEWIT_2 12
;#define CV_WORLD_0 13
;#define CV_WORLD_1 14
;#define CV_WORLD_2 15
;#define CV_WORLD_3 16
;#define CV_HALF 18
;#define CV_LIGHT_COLOR 19
;#define CV_ONE_OVER_LIGHT_RANGE 20
;#define CV_LIGHT_DIRECTION 21
;#define CV_LIGHT_POSITION 22
;#define CV_BUMP_SCALE 23
;#define CV_EYE_POS_WORLD 24
;#define V_POSITION v0
;#define V_NORMAL v1
;#define V_DIFFUSE v2
;#define V_TEXTURE v3
;#define V_SxT v4
;#define V_S v5
;#define V_T v6
;#define S_WORLD r0
;#define T_WORLD r1
;#define SxT_WORLD r2
;#define LIGHT_LOCAL r3
;#define VERTEX_WORLD r4
;#define EYE_VECTOR r5
;#define HALF_ANGLE r7
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]
; Get V
;mul r8.xyz, v5.yzx,v1.zxy
;mad r8.xyz, -v1.yzx, v5.zxy, r8.xyz
;dp3 r8.w, r8, r8
;rsq r8.w, r8.w
;mul r8, r8, r8.w
; Transform basis vectors to world space
dp3 r0.x, v5, c[13]
dp3 r0.y, v5, c[14]
dp3 r0.z, v5, c[15]
dp3 r1.x, v6, c[13]
dp3 r1.y, v6, c[14]
dp3 r1.z, v6, c[15]
dp3 r2.x, v1, c[13]
dp3 r2.y, v1, c[14]
dp3 r2.z, v1, c[15]
mul r0.xyz, r0.xyz, c[23].w
mul r1.xyz, r1.xyz, c[23].w
; transform light by basis vectors to put it
; into texture space
dp3 r3.x, r0.xyz, c[21]
dp3 r3.y, r1.xyz, c[21]
dp3 r3.z, r2.xyz, c[21]
; Normalize the light vector
dp3 r3.w, r3, r3
rsq r3.w, r3.w
mul r3, r3, r3.w
/////////////////////////////////////
// Calculate half angle vector
// transform vertex position to world space
// to calculate V, vector to viewer in world
// space.
dp4 r4.x, v0, c[13]
dp4 r4.y, v0, c[14]
dp4 r4.z, v0, c[15]
; Half angle vector is (L+V)/||L+V|| or Normalize( L+V )
; ||a|| is magnitude of a
; L = vec to light from vertex point
; V = vec to viewer from vertex point
// vertex position - eye position
// eye position - vertex position
add r5, c[ 24 ], -r4.xyz
; Normalize eye vec
dp3 r5.w, r5, r5
rsq r5.w, r5.w
mul r5, r5, r5.w
// Add them to average & create half angle vector
add r7, c[21], r5
; Normalize it
dp3 r7.w, r7, r7
rsq r7.w, r7.w
mul r7, r7, r7.w
/////////////////////////////////////////////////
; Transform half angle vector to local space and
; output to tex coord set 3 for specular calc
// Write result to a temporary r2 and use 1 extra
// instruction for the mov so that we can output
// it to diffuse color also. Normaly, you should
// write the result directly to oTn and save yourself
// the mov instruction
;dp3 r2.x, r7, r0
;dp3 r2.y, r7, r1
;dp3 r2.z, r7, r2
;mov r2.w, c[ 1 ]
;mov oT3.x, r2.x
;mov oT3.y, r2.y
;mov oT3.z, r2.z
;mov oT3.w, r2.w
//@@@@@@@@@
;mov oT3.xyz, r2.xyz
;mov oT3.w, c[ 1 ]
;dp3 r2.x, r7, r0
;dp3 r2.y, r7, r1
;dp3 r2.z, r7, r2
;mov r2.w, c[ 1 ]
;mov oT3.xyzw, r2.xyzw
;dp3 r2.x, r7, r0
;dp3 r2.y, r7, r1
;dp3 r2.z, r7, r2
;mov r2.w, c[ 1 ]
;mov oT3.xyzw, r2.xyzw
dp3 oT3.x, r7, r0
dp3 oT3.y, r7, r1
dp3 oT3.z, r7, r2
mov oT3.w, c[ 1 ]
/////////////////////////////////////
// move light vector to TC 2
mov oT2, r3
mov oT2.w, c[1].w // w to 0
; output tex coords
mov oT0, v3
mov oT1, v3
//////////////////////////////////////////////
// Additional output of light vector to
// diffuse color for visualization in the
// demo
;mul r1, r3, c[18]
;add oD0, r1, c[18]
//////////////////////////////////////////////
// move half angle vector to unsigned diffuse
// color for visualization in the demo
// Bias from [-1,1] to the range [0,1]
//@@@@@@@@@ turn this off - debug only!
dp3 r2.x, r7, r0
dp3 r2.y, r7, r1
dp3 r2.z, r7, r2
mov r2.w, c[ 1 ]
mul r2, r2, c[18]
add oD0, r2, c[18]
//////////////////////////////////////////////