matrix_cubesphere_specular: incomplete
This commit is contained in:
parent
8e6e6e9750
commit
30c018a748
1293
drm/matrix_cubesphere_specular.cpp
Normal file
1293
drm/matrix_cubesphere_specular.cpp
Normal file
File diff suppressed because it is too large
Load Diff
102
drm/matrix_cubesphere_specular.fs.asm
Normal file
102
drm/matrix_cubesphere_specular.fs.asm
Normal file
@ -0,0 +1,102 @@
|
||||
-- temp[0] -- position (world space)
|
||||
-- temp[1] -- normal
|
||||
-- temp[2] -- light pos (world space)
|
||||
-- temp[3] -- view pos (world space)
|
||||
-- temp[4] -- texture
|
||||
|
||||
-- PIXSIZE 4
|
||||
|
||||
TEX TEX_SEM_WAIT TEX_SEM_ACQUIRE
|
||||
temp[4].rgba = LD tex[0].rgba temp[4].rgaa ;
|
||||
|
||||
-- normal = normalize(normal)
|
||||
-- normal = (1.0 / sqrt(dot(normal, normal))) * normal
|
||||
src0.rgb = temp[1] :
|
||||
DP3 src0.rgb src0.rgb ,
|
||||
temp[1].a = DP ;
|
||||
src0.a = temp[1] :
|
||||
temp[1].a = RSQ |src0.a| ;
|
||||
src0.a = temp[1], src0.rgb = temp[1] :
|
||||
temp[1].rgb = MAD src0.rgb src0.aaa src0.000 ;
|
||||
|
||||
-- light_dir = normalize((f_light_pos - f_world_pos))
|
||||
src1.rgb = temp[2] , -- f_light_pos
|
||||
src0.rgb = temp[0] , -- f_world_pos
|
||||
srcp.rgb = neg : -- (f_light_pos - f_world_pos)
|
||||
DP3 srcp.rgb srcp.rgb ,
|
||||
temp[2].a = DP ;
|
||||
src0.a = temp[2] :
|
||||
temp[2].a = RSQ |src0.a| ;
|
||||
src0.a = temp[2], src0.rgb = temp[2] :
|
||||
temp[2].rgb = MAD src0.rgb src0.aaa src0.000 ;
|
||||
|
||||
-- diff = dot(normal, light_dir)
|
||||
src0.rgb = temp[2] ,
|
||||
src1.rgb = temp[1] :
|
||||
DP3 src0.rgb src1.rgb ,
|
||||
temp[5].a = DP ;
|
||||
|
||||
-- diff = max(diff, 0)
|
||||
src0.a = temp[5] :
|
||||
temp[5].a = MAX src0.a src0.0 ;
|
||||
|
||||
-- intensity = diff + 0.125
|
||||
src0.a = temp[5] ,
|
||||
src1.a = float(32) : -- 0.125
|
||||
temp[5].a = MAD src0.a src0.1 src1.a ;
|
||||
|
||||
--
|
||||
-- specular
|
||||
--
|
||||
-- temp[3] -- view pos (world space)
|
||||
-- view_dir = normalize(f_view_pos - f_world_pos)
|
||||
src1.rgb = temp[3] , -- f_light_pos
|
||||
src0.rgb = temp[0] , -- f_world_pos
|
||||
srcp.rgb = neg : -- (f_light_pos - f_world_pos)
|
||||
DP3 srcp.rgb srcp.rgb ,
|
||||
temp[3].a = DP ;
|
||||
src0.a = temp[3] :
|
||||
temp[3].a = RSQ |src0.a| ;
|
||||
src0.a = temp[3], src0.rgb = temp[3] :
|
||||
temp[3].rgb = MAD src0.rgb src0.aaa src0.000 ;
|
||||
|
||||
-- reflect(I, N)
|
||||
-- I - 2.0 * dot(N, I) * N
|
||||
-- reflect_dir = reflect(-light_dir, norm)
|
||||
-- reflect_dir = reflect(-temp[2], temp[1])
|
||||
-- I - 2.0 * dot(N, I) * N
|
||||
-- - (2.0 * dot(N, I)) * temp[1] + -temp[2]
|
||||
src0.rgb = temp[1] , -- N=normal
|
||||
src1.rgb = temp[2] : -- I=light_dir dot(N, -I)
|
||||
temp[6].r = DP3 src0.rgb -src1.rgb ;
|
||||
src0.rgb = temp[6] ,
|
||||
src1.rgb = float(64) : -- 2.0
|
||||
temp[6].r = MAD src0.r00 src1.r00 src0.000 ;
|
||||
src0.rgb = temp[6] ,
|
||||
src1.rgb = temp[1] , -- N
|
||||
src2.rgb = temp[2] : -- I
|
||||
temp[6].rgb = MAD -src0.rrr src1.rgb -src2.rgb ;
|
||||
|
||||
-- spec = max(dot(view_dir, reflect_dir), 0.0)
|
||||
src0.rgb = temp[6] , -- reflect_dir
|
||||
src1.rgb = temp[3] : -- view_dir
|
||||
temp[6].r = DP3 src0.rgb src1.rgb ;
|
||||
src0.rgb = temp[6] :
|
||||
temp[6].a = MAX src0.r src0.0 ;
|
||||
|
||||
-- spec = pow(spec, 32)
|
||||
src0.a = temp[6] :
|
||||
temp[6].a = LN2 src0.a ;
|
||||
src0.a = temp[6] ,
|
||||
src1.a = float(72) : -- 32
|
||||
temp[6].a = MAD src0.a src1.a src1.0 ;
|
||||
src0.a = temp[6] :
|
||||
temp[6].a = EX2 src0.a ;
|
||||
|
||||
OUT TEX_SEM_WAIT
|
||||
src0.a = temp[4],
|
||||
src0.rgb = temp[4] ,
|
||||
src1.a = temp[6] ,
|
||||
src1.rgb = temp[6] :
|
||||
out[0].a = MAX src0.a src0.a ,
|
||||
out[0].rgb = MAD src0.111 src1.aaa src1.000 ;
|
||||
48
drm/matrix_cubesphere_specular.vs.asm
Normal file
48
drm/matrix_cubesphere_specular.vs.asm
Normal file
@ -0,0 +1,48 @@
|
||||
--
|
||||
-- dot(m[0], v), dot(m[1], v), dot(m[2], v), dot(m[3], v)
|
||||
--
|
||||
|
||||
-- input[0] -- position
|
||||
-- input[1] -- texture
|
||||
-- input[2] -- normal
|
||||
|
||||
-- consts[0] -- trans
|
||||
-- consts[4] -- world_trans
|
||||
-- consts[8] -- normal_trans
|
||||
|
||||
-- out[0] -- position clip space
|
||||
-- out[1] -- object position world space
|
||||
-- out[2] -- normal
|
||||
-- out[3] -- light position world space
|
||||
-- out[4] -- view position world space
|
||||
-- out[5] -- texture
|
||||
|
||||
-- position clip space
|
||||
temp[1].x = VE_DOT const[0].xyzw input[0].xyzw ;
|
||||
temp[1].y = VE_DOT const[1].xyzw input[0].xyzw ;
|
||||
temp[1].z = VE_DOT const[2].xyzw input[0].xyzw ;
|
||||
temp[1].w = VE_DOT const[3].xyzw input[0].xyzw ;
|
||||
|
||||
-- position world space
|
||||
temp[2].x = VE_DOT const[4].xyzw input[0].xyzw ;
|
||||
temp[2].y = VE_DOT const[5].xyzw input[0].xyzw ;
|
||||
temp[2].z = VE_DOT const[6].xyzw input[0].xyzw ;
|
||||
temp[2].w = VE_DOT const[7].xyzw input[0].xyzw ;
|
||||
|
||||
-- normal world space
|
||||
temp[3].x = VE_DOT const[4].xyz0 input[2].xyz0 ;
|
||||
temp[3].y = VE_DOT const[5].xyz0 input[2].xyz0 ;
|
||||
temp[3].z = VE_DOT const[6].xyz0 input[2].xyz0 ;
|
||||
|
||||
-- position (clip space)
|
||||
out[0].xyzw = VE_ADD temp[1].xyzw const[0].0000 ;
|
||||
-- position (world space)
|
||||
out[1].xyzw = VE_ADD temp[2].xyzw const[0].0000 ;
|
||||
-- normal
|
||||
out[2].xyzw = VE_ADD temp[3].xyz0 const[0].0000 ;
|
||||
-- light pos (world space)
|
||||
out[3].xyzw = VE_ADD const[8].xyzw const[8].0000 ;
|
||||
-- view pos (world space)
|
||||
out[4].xyzw = VE_ADD const[9].xyzw const[9].0000 ;
|
||||
-- texture
|
||||
out[5].xyzw = VE_ADD input[1].xy00 const[0].0000 ;
|
||||
1312
model/cubesphere_smooth.h
Normal file
1312
model/cubesphere_smooth.h
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user