view3ds 0073 by macgub

git-svn-id: svn://kolibrios.org@8719 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2021-05-12 00:26:00 +00:00
parent 1c24cac315
commit 73122f1cb1
9 changed files with 7546 additions and 7756 deletions

View File

@ -198,24 +198,7 @@ ret
;---------------------------- edi - pointer to vector ----- ;---------------------------- edi - pointer to vector -----
;----------------------- out : none ;----------------------- out : none
normalize_vector: normalize_vector:
if Ext = SSE2 | Ext = SSE | Ext = SSE3 if Ext >= SSE3
movups xmm0,[edi]
andps xmm0,[zero_hgst_dd]
movups xmm1,xmm0
mulps xmm0,xmm0
movhlps xmm2,xmm0
addps xmm0,xmm2
movaps xmm2,xmm0
shufps xmm2,xmm2,11100001b
addps xmm0,xmm2
shufps xmm0,xmm0,0
rsqrtps xmm0,xmm0
mulps xmm0,xmm1
movlps [edi],xmm0
movhlps xmm0,xmm0
movss [edi+8],xmm0
end if
if 0 ; Ext >= SSE3
movups xmm0,[edi] movups xmm0,[edi]
andps xmm0,[zero_hgst_dd] andps xmm0,[zero_hgst_dd]
movups xmm1,xmm0 movups xmm1,xmm0
@ -227,8 +210,7 @@ if 0 ; Ext >= SSE3
movlps [edi],xmm0 movlps [edi],xmm0
movhlps xmm0,xmm0 movhlps xmm0,xmm0
movss [edi+8],xmm0 movss [edi+8],xmm0
end if else
if Ext < SSE
fninit fninit
fld dword [edi+vec_x] fld dword [edi+vec_x]

View File

@ -312,9 +312,11 @@ stencil_line:
sub ecx,.x1 sub ecx,.x1
movss xmm2,.z1 ; cz movss xmm2,.z1 ; cz
.ccalc: .ccalc:
; movss xmm1,xmm2 movss xmm1,xmm2
comiss xmm2,dword[esi] cmpltss xmm1,dword[esi]
jg @f movd eax,xmm1
cmp eax,-1
jnz @f
movss dword[esi],xmm2 movss dword[esi],xmm2
@@: @@:
add esi,4 add esi,4

View File

@ -1,3 +1,227 @@
;===============================================================
do_edges_list:
push ebp
mov ebp,esp
sub esp,32
.ed_cnt equ [ebp-4]
.edd_ptr equ [ebp-8]
.counter equ [ebp-12]
mov ebx,[edges_ptr]
mov eax,[triangles_ptr]
mov ecx,[triangles_count_var]
@@:
movdqu xmm0,[eax]
movq [ebx],xmm0
pshufd xmm0,xmm0,11001001b
movq [ebx+8],xmm0
pshufd xmm0,xmm0,11001001b
movq [ebx+16],xmm0
add ebx,24
add eax,12
loop @b
mov ebx,[edges_ptr]
mov ecx,[triangles_count_var]
lea ecx,[ecx*3]
.mxd:
mov eax,[ebx]
cmp eax,[ebx+4]
jl @f
movq xmm0,[ebx]
pshufd xmm0,xmm0,11100001b
movq [ebx],xmm0
@@:
add ebx,8
loop .mxd
; insert sort
mov ebx,[edges_ptr]
mov ecx,[triangles_count_var]
lea ecx,[ecx*3]
mov esi,ecx
shl esi,3
add esi,ebx
.ccc:
mov eax,[ebx+8]
cmp eax,[ebx]
jge .g
movq xmm0,[ebx+8]
push ebx
.c:
cmp ebx,esi
jge .done
cmp ebx,[edges_ptr]
jl .done
cmp eax,[ebx]
jge .done
movq xmm7,[ebx]
movq [ebx+8],xmm7
sub ebx,8
jnz .c
add ebx,8
.done:
movq [ebx+8],xmm0
.p:
pop ebx
.g:
add ebx,8
dec ecx
cmp ecx,1
jnz .ccc
; insert sort again
mov ebx,[edges_ptr]
mov ecx,[triangles_count_var]
lea ecx,[ecx*3]
mov esi,ecx
shl esi,3
add esi,ebx
.count:
push ecx
push ebx
xor ecx,ecx
mov eax,[ebx] ; count
.aa:
inc ecx
add ebx,8
cmp ebx,esi
jge .br ; break
cmp eax,[ebx]
je .aa
mov .counter,ecx
pop ebx
mov edi,ebx
sub edi,8
mov edx,[ebx+8]
.ccc2:
cmp ebx,esi
jbe @f
add esp,4
jmp .ff
@@:
mov eax,[ebx+12]
mov edx,[ebx+8]
cmp eax,[ebx+4]
jge .gg2
movq xmm0,[ebx+8]
push ebx
.c2:
cmp eax,[ebx+4]
jge .done2
movq xmm7,[ebx]
movq [ebx+8],xmm7
sub ebx,8
cmp ebx,edi
jz @f
cmp [ebx+8],edx
jz .c2
@@:
.done2:
add ebx,8
movq [ebx],xmm0
.p2:
pop ebx
.gg2:
add ebx,8
dec ecx
cmp ecx,1
jnz .ccc2
pop ecx
sub ecx,.counter
add ebx,8
ja .count
jmp .ff
.br: ;break
add esp,8
.ff:
; count edges
mov ecx,0
mov edx,[triangles_count_var]
lea edx,[edx*3]
mov ebx,[edges_ptr]
; mov esi,edx
; shl esi,3
; add esi,[edges_ptr]
.nx:
movq xmm0,[ebx]
add ebx,8
; cmp ebx,esi
; jae @f
movq xmm1,[ebx]
; @@:
pcmpeqd xmm0,xmm1
pmovmskb eax,xmm0
and eax,0xff
cmp eax,0xff
jz @f
inc ecx
@@:
dec edx
jnz .nx
mov .ed_cnt,ecx
lea ecx,[ecx*3]
shl ecx,2
add ecx,65536
mov ebx,12
mov eax,68
mov edx,.edd_ptr
int 0x40 ; -> allocate memory to triangles
mov .edd_ptr, eax ; -> eax = pointer to allocated mem
mov ebx,[edges_ptr]
mov ecx,[triangles_count_var]
lea ecx,[ecx*3]
.seek:
movq xmm0,[ebx]
movq xmm1,[ebx+8]
pcmpeqd xmm1,xmm0
pmovmskb edx,xmm1
and edx,0xff
cmp edx,0xff
je @f
movq [eax],xmm0
add eax,8
@@:
add ebx,8
loop .seek
mov eax,68
mov ebx,13
mov ecx,[edges_ptr]
int 0x40 ; release old edges ptr
mov eax,.edd_ptr
mov ecx,.ed_cnt
mov [edges_ptr],eax
mov [edges_count],ecx
mov esp,ebp
pop ebp
ret
;=======================
do_sinus: do_sinus:
.x equ [ebp-8] .x equ [ebp-8]
.y equ [ebp-12] .y equ [ebp-12]
@ -19,21 +243,53 @@ do_sinus:
cld cld
rep stosd rep stosd
pop edi pop edi
; movzx eax,[sinus_flag]
; mov edx,10
; mul edx
; mov [sin_amplitude],eax
; mov [sin_frq],eax
fninit fninit
;if Ext = SSE2
; movups xmm1,[const0123] ; xmm1 - init values
; mov eax,0x000000ff
; movd xmm2,eax
; shufps xmm2,xmm2,0 ; xmm2 - mask value
; mov eax,4
; movd xmm3,eax
; shufps xmm3,xmm3,0
.again: .again:
if 0
fild dword .x
fidiv [sin_frq]
fsin
fimul [sin_amplitude]
fiadd dword .y
fistp dword .new_y
else
fild dword .x fild dword .x
fmul [sin_frq] fmul [sin_frq]
fistp dword .temp fistp dword .temp
mov eax, .temp mov eax, .temp
; mov bx, [angle_x]
; add bx, [angle_y]
; movzx ebx,bx
; shr ebx,1 ; change phase
; add eax,ebx
and eax, 0x000000ff and eax, 0x000000ff
; cdq
; mul [sin_frq]
; and eax,0x000000ff
; and ax,0x00ff
; cwde
fld dword [sin_tab+eax*4] fld dword [sin_tab+eax*4]
fimul dword [sin_amplitude] fimul dword [sin_amplitude]
fiadd dword .y fiadd dword .y
fistp dword .new_y fistp dword .new_y
end if
mov eax,.new_y mov eax,.new_y
or eax,eax or eax,eax
jl .skip jl .skip
@ -244,7 +500,109 @@ end if
ret ret
;align 16
; emboss_bias:
; dw 128, 128, 128, 128, 128, 128, 128, 128
if 0 ; old emb proc
; emboss - after drawing all,
; transfer screen buffer into bump map
; and draw two bump triangles
; *************************************
mov esi,screen
mov edi,bumpmap2
mov ecx,TEXTURE_SIZE/3
cld
if Ext=NON
xor eax,eax
xor bh,bh
xor dh,dh
@@:
lodsb
movzx bx,al
lodsb
movzx dx,al
lodsb
add ax,bx
add ax,dx
; cwd
; div [i3]
;; push ax
;; pop bx
;; shr bx,3
;; shr ax,2
;; add ax,bx
lea eax,[eax*5]
shr ax,4
stosb
loop @b
else
emms
pxor mm1,mm1
mov ebx,0x0000ffff
@@:
movd mm0,[esi]
punpcklbw mm0,mm1
movq mm2,mm0
psrlq mm2,16
movq mm3,mm0
psrlq mm3,32
paddw mm0,mm2
paddw mm0,mm3
movd eax,mm0
and eax,ebx
lea eax,[eax*5]
shr ax,4
stosb
add esi,3
loop @b
end if
push ebp
push dword 0 ; env coords
push word 0
push word SIZE_X
push word SIZE_Y
push dword 0
push dword 0 ; bump coords
push word SIZE_X
push word SIZE_Y
push word 0
mov eax,SIZE_Y
mov ebx,SIZE_X*65536+0
xor ecx,ecx
mov edx,bumpmap2
mov esi,envmap
mov edi,screen
call bump_triangle
push dword SIZE_X shl 16 + SIZE_Y ; env coords
push word 0
push word SIZE_X
push word SIZE_Y
push word 0
push dword SIZE_X shl 16 + SIZE_Y ; bump coords
push word 0
push word SIZE_X
push word SIZE_Y
push word 0
mov eax,SIZE_Y
mov ebx,SIZE_X * 65536+0
mov ecx,SIZE_X shl 16 + SIZE_Y
mov edx,bumpmap2
mov esi,envmap
mov edi,screen
call bump_triangle
pop ebp
ret
end if
;********************************EMBOSS DONE******************************* ;********************************EMBOSS DONE*******************************

View File

@ -60,25 +60,24 @@ calc_one_col:
; stack - other parameters ; stack - other parameters
; out - eax - 0x00rrggbb ; out - eax - 0x00rrggbb
.dot_prd equ dword[ebp+4] ; dot product - cos x - not now .dot_prd equ dword[ebp+4] ; dot product - cos x - not now
.min_col_r equ [ebp+8] ; minimum color - ambient .min_col_r equ word[ebp+8] ; minimum color - ambient
.min_col_g equ word[ebp+10] .min_col_g equ word[ebp+10]
.min_col_b equ word[ebp+12] .min_col_b equ word[ebp+12]
.max_col_r equ [ebp+14] ; maximum color - specular .max_col_r equ word[ebp+14] ; maximum color - specular
.max_col_g equ word[ebp+16] .max_col_g equ word[ebp+16]
.max_col_b equ word[ebp+18] .max_col_b equ word[ebp+18]
.org_col_r equ [ebp+20] ; orginal color - diffuse .org_col_r equ word[ebp+20] ; orginal color - diffuse
.org_col_g equ word[ebp+22] .org_col_g equ word[ebp+22]
.org_col_b equ word[ebp+24] .org_col_b equ word[ebp+24]
.n equ word[ebp+26] ; shines - not implemented .n equ word[ebp+26] ; shines - not implemented
.temp equ word[ebp-2] .temp equ word[ebp-2]
.color_sum_r equ [ebp-6] .color_sum_r equ dword[ebp-6]
.color_sum_g equ [ebp-10] .color_sum_g equ dword[ebp-10]
.color_sum_b equ [ebp-14] .color_sum_b equ dword[ebp-14]
; color = ambient+cos(x)*diffuse+(cos(x)^n)*specular ; color = ambient+cos(x)*diffuse+(cos(x)^n)*specular
mov ebp,esp mov ebp,esp
sub esp,14 sub esp,14
mov ax,.min_col_r mov ax,.min_col_r
add ax,.max_col_r add ax,.max_col_r
add ax,.org_col_r add ax,.org_col_r
@ -96,38 +95,8 @@ calc_one_col:
add ax,.org_col_b add ax,.org_col_b
cwde cwde
mov .color_sum_b,eax mov .color_sum_b,eax
if 0
movq xmm0,.min_col_r
movq xmm1,.max_col_r
movq xmm2,.org_col_r
packuswb xmm0,[the_zero]
packuswb xmm1,[the_zero]
packuswb xmm2,[the_zero]
punpcklbw xmm0,xmm1
punpcklbw xmm2,[the_zero]
packusdw xmm2,[the_zero]
cvtdq2ps xmm0,xmm0
cvtdq2ps xmm1,xmm1
cvtdq2ps xmm2,xmm2
haddps xmm0,xmm0
haddps xmm1,xmm1
haddps xmm2,xmm2
haddps xmm0,xmm0
haddps xmm1,xmm1
haddps xmm2,xmm2
cvtss2si eax,xmm0
cvtss2si ebx,xmm1
cvtss2si ecx,xmm2
mov .color_sum_r,eax
mov .color_sum_g,ebx
mov .color_sum_b,ecx
end if
; fld .dot_prd ; fld .dot_prd
; fild .n ; fild .n
; fxch st1 ; fxch st1
@ -154,7 +123,7 @@ end if
faddp ; st0=first piece of col, st1=dot_pr^n.. faddp ; st0=first piece of col, st1=dot_pr^n..
fiadd .min_col_b fiadd .min_col_b
fimul .max_col_b fimul .max_col_b
fidiv dword .color_sum_b fidiv .color_sum_b
fistp .temp fistp .temp
movzx eax,.temp movzx eax,.temp
shl eax,16 shl eax,16
@ -166,19 +135,19 @@ end if
faddp faddp
fiadd .min_col_g fiadd .min_col_g
fimul .max_col_g fimul .max_col_g
fidiv dword .color_sum_g fidiv .color_sum_g
fistp .temp fistp .temp
mov ax,.temp mov ax,.temp
mov ah,al mov ah,al
shl eax,8 shl eax,8
fimul word .max_col_r fimul .max_col_r
fild word .org_col_r fild .org_col_r
fmulp st2,st fmulp st2,st
faddp faddp
fiadd word .min_col_r fiadd .min_col_r
fimul word .max_col_r fimul .max_col_r
fidiv dword .color_sum_r fidiv .color_sum_r
fistp .temp fistp .temp
mov ax,.temp ;eax - 0xbbgg00rr mov ax,.temp ;eax - 0xbbgg00rr
; mov ah,al ; mov ah,al

View File

@ -1,12 +1,15 @@
; DATA AREA ************************************ ; DATA AREA ************************************
i3 dw 3 i3 dw 3
i6 dd 6
i12 dd 12 i12 dd 12
i36 dd 36
i256 dw 256 i256 dw 256
i255d dd 255 i255d dd 255
dot_max dd 1.0 ; dot product max and min dot_max dd 1.0 ; dot product max and min
dot_min dd 0.0 dot_min dd 0.0
env_const dd 1.05 env_const dd 1.05
correct_tex dw 255
tex_x_div2 dw TEX_X / 2 tex_x_div2 dw TEX_X / 2
tex_y_div2 dw TEX_Y / 2 tex_y_div2 dw TEX_Y / 2
xobs dw 0 ;SIZE_X / 2 ;200 ;observer = camera xobs dw 0 ;SIZE_X / 2 ;200 ;observer = camera
@ -54,6 +57,7 @@
points_ptr dd 0 points_ptr dd 0
points_rotated_ptr dd 0 points_rotated_ptr dd 0
points_translated_ptr dd 0 points_translated_ptr dd 0
edges_ptr dd 0
screen_ptr dd 0 screen_ptr dd 0
Zbuffer_ptr dd 0 Zbuffer_ptr dd 0
vertices_index_ptr dd 0 vertices_index_ptr dd 0
@ -64,6 +68,9 @@
edit_end_x: edit_end_x:
dw 0 dw 0
edit_end_y dw 0 edit_end_y dw 0
x_start: dw 20
y_start: dw 20
mouse_state dd 0 mouse_state dd 0
@ -343,9 +350,19 @@ base_vector:
if Ext=SSE3 if Ext=SSE3
db ' (SSE3)' db ' (SSE3)'
end if end if
db ' 0.072',0 db ' 0.073',0
labellen: labellen:
STRdata db '-1 ' STRdata db '-1 '
lab_vert:
db 'Vertices count: '
lab_vert_end:
lab_tr:
db 'Faces count: '
lab_tr_end:
lab_ed:
db 'Edges count: '
lab_ed_end:
all_lights_size dw lightsend-lights all_lights_size dw lightsend-lights
@ -410,6 +427,8 @@ lightsend:
align 16 align 16
abs_mask:
dd 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff
emboss_bias: emboss_bias:
dw 128, 128, 128, 128, 128, 128, 128, 128 dw 128, 128, 128, 128, 128, 128, 128, 128
zero_hgst_dd: zero_hgst_dd:
@ -434,7 +453,7 @@ align 16
fptr dd 0 ;workarea fptr dd 0 ;workarea
file_name: file_name:
db '/rd/1/3d/house.3ds',0 db '/rd/1/3d/house.3ds',0
; db '/tmp0/1/ant.3ds',0 ; db '/tmp0/1/ant.3ds',0
rb 256 rb 256
@ -465,21 +484,9 @@ align 8
col3 dd ? col3 dd ?
scale dd ? ; help scale variable scale dd ? ; help scale variable
;== points_count_var dd ? ;
triangles_count_var dd ? triangles_count_var dd ? ; dont change order
points_count_var dd ? edges_count dd ? ;
; size_y_var:
; yres_var dw ?
; size_x_var:
; xres_var dw ?
x_start:
dw ?
y_start:
dw ?
;===
point_index1 dd ? ;-\ point_index1 dd ? ;-\
point_index2 dd ? ; } don't change order point_index2 dd ? ; } don't change order

View File

@ -1,643 +1,115 @@
;-procedure draws smooth shaded lines (I mean interpolation 24 bit-- ; Line drawing procedure by Pablo Reda.
;-color), with z coord interpolation-------------------------------- ; Gouraud extension by Maciej Guba.
;-author: Maciej Guba (www.macgub.hekko.pl)------------------------- ;****************************************************
;-in : ------------------------------------------------------------- line_grd: ; eax=x1 ebx=y1 ecx=x2 edx=y2
;----- edi - pointer to screen buffer ------------------------------ ; xmm0 - color1 argb as 4 dword float
;----- esi - pointer to Z buffer ----------------------------------- ; xmm1 - color2 argb as 4 dword float
;------ constans : SIZE_X, SIZE_Y - screen width and height--------- ; xmm2 - z1 as dword float
;----------------- ROUND - fixed point shift------------------------ ; xmm3 - z2 as dword float
;------ other parameters via stack---------------------------------- ; mm0 - Z buffer
smooth_line: ; mm1 - screen buffer
.x1 equ ebp+4 ; mm2 - screen width
.y1 equ ebp+6
.z1 equ ebp+8
.r1 equ ebp+10 cmp ebx,edx
.g1 equ ebp+12 ; je horizontal_grd
.b1 equ ebp+14 jg .noswap
.x2 equ ebp+16 xchg eax,ecx
.y2 equ ebp+18 xchg ebx,edx
.z2 equ ebp+20 movaps xmm7,xmm0
.r2 equ ebp+22 movaps xmm0,xmm1
.g2 equ ebp+24 movaps xmm1,xmm7
.b2 equ ebp+26 movaps xmm7,xmm2
movaps xmm2,xmm3
movaps xmm3,xmm7
.line_lenght equ ebp-2 .noswap:
.delta equ ebp-6
.delta_x equ ebp-10 cvtsi2ss xmm7,eax
.delta_y equ ebp-14 cvtsi2ss xmm6,ebx
.dr equ ebp-18 cvtsi2ss xmm5,ecx
.dg equ ebp-22 cvtsi2ss xmm4,edx
.db equ ebp-26 subss xmm7,xmm5
.dz equ ebp-30 subss xmm6,xmm4
.cr equ ebp-34 andps xmm7,[abs_mask] ; 0x7fff
.cg equ ebp-38 andps xmm6,[abs_mask] ; 0x7fff
.cb equ ebp-42 maxss xmm7,xmm6 ; xmm7 - delta
.cz equ ebp-46 shufps xmm7,xmm7,0
movaps xmm6,xmm3
;.line_lenght equ ebp-48 rcpps xmm7,xmm7
.screen equ ebp-52 subss xmm6,xmm2
.zbuffer equ ebp-56 mulss xmm6,xmm7 ; xmm6 - delta z
.ccoord equ ebp-60 ;current coordinate movaps xmm5,xmm1
.czbuf equ ebp-64 subps xmm5,xmm0
.cscr equ ebp-68 mulps xmm5,xmm7 ; xmm5 - delta col argb
.xres equ ebp-72
.yres equ ebp-76
.xresm1 equ ebp-80 shl eax,16
.yresm1 equ ebp-84 shl ecx,16
.xresp1 equ ebp-88 sub eax,ecx
.yresp1 equ ebp-92 push ebx
.xres3 equ ebp-96 push edx
.xres4 equ ebp-100 sub ebx,edx
add ebx,1
macro .update_cur_var cdq
{ idiv ebx
if Ext=NON mov esi,eax
mov ebx,[.dz] add ecx,$7fff
add [.cz],ebx pop ebx
mov ebx,[.dr] pop edx
add [.cr],ebx .lineas:
mov ebx,[.dg] mov eax,ecx
add [.cg],ebx add eax,esi
mov ebx,[.db] push ebx
add [.cb],ebx push eax
elseif Ext=MMX push edx
movq mm0,[.cz] shr ecx,16
movq mm1,[.cg] shr eax,16
paddd mm0,mm2 ;[.dz] call horizontal_grd
paddd mm1,mm3 ;[.dg] pop edx
movq [.cz],mm0 pop ecx
movq [.cg],mm1 pop ebx
elseif Ext >= SSE2 add ebx,1
; movups xmm1,[.cz] cmp ebx,edx
paddd xmm1,xmm0 jle .lineas
; movups [.cz],xmm1 ret
end if
} horizontal_grd: ; eax=x1 ebx=y1 ecx=x2
macro .draw_pixel cmp ecx,eax
{ jg .m
mov [esi],ebx ; actualize Z buffer xchg ecx,eax
if Ext>=SSE2 .m:
movaps xmm7,xmm1 ;[.cb] ;;xmm1 sub ecx,eax
shufps xmm7,xmm7,00111001b jnz .nn
psrld xmm7,ROUND add ecx,1
packssdw xmm7,xmm7 .nn:
packuswb xmm7,xmm7 movd edx,mm2
pand xmm7,xmm6 ;[.mask] imul ebx,edx
movd [edi],xmm7 add eax,ebx
else movd edi,mm1
lea edi,[edi+eax*4]
mov eax,[.cb] push eax
sar eax,ROUND push ebx
mov [edi],al movd ebx,mm0
; and eax,0x000000ff ; clean unused bits lea ebx,[ebx+eax*4]
mov ebx,[.cg] .l:
sar ebx,ROUND ; movss xmm4,xmm2 ; xmm2 - cur z
mov [edi+1],bl ; cmpnltss xmm4,[ebx]
; mov ah,bl ; movd eax,xmm4
mov edx,[.cr] ; or eax,eax
sar edx,ROUND ; jnz @f
mov [edi+2],dl comiss xmm2,[ebx]
end if jng @f
; shl ebx,16 movaps xmm4,xmm0 ; xmm0 - cur col
; or eax,ebx cvtps2dq xmm4,xmm4
; mov [edi],eax packssdw xmm4,xmm4
} packuswb xmm4,xmm4
macro .sort movd [edi],xmm4
{ @@:
addss xmm2,xmm6
if Ext >= MMX addps xmm0,xmm5
movq mm0,[.x1] add edi,4
movq mm1,[.x2] sub ecx,1
movq [.x1],mm1 jnz .l
movq [.x2],mm0 pop ebx
else pop eax
mov edx,[.x1] ret
xchg edx,[.x2]
mov [.x1],edx
mov edx,[.z1]
xchg edx,[.z2]
mov [.z1],edx
end if
mov edx,[.g1]
xchg edx,[.g2]
mov [.g1],edx
}
emms
mov ebp,esp
sub esp,128
mov eax,[.x1] ; check if parameters exceedes screen area
mov ebx,[.x2]
or eax,ebx
test eax,80008000h
jne .end_line
movzx edx,word [size_x_var]
mov [.xres],edx
dec edx
movzx ecx,word [size_y_var]
mov [.yres],ecx
dec ecx
cmp word[.x1],dx ;SIZE_X
jg .end_line
cmp word[.x2],dx ;SIZE_X
jg .end_line
cmp word[.y1],cx ;SIZE_Y
jg .end_line
cmp word[.y2],cx ;SIZE_Y
jg .end_line
mov edx,[.xres]
shl edx,2
mov [.xres4],edx
shr edx,2
lea edx,[edx*3]
mov [.xres3],edx
mov edx,[.xres]
mov ecx,[.yres]
dec edx
dec ecx
mov [.xresm1],edx
mov [.yresm1],ecx
add edx,2
add ecx,2
mov [.xresp1],edx
mov [.yresp1],ecx
mov [.screen],edi
mov cx,[.x1]
cmp cx,[.x2]
je .vertical_l
mov cx,[.y1]
cmp cx,[.y2]
je .horizontal_l
mov ax,[.x1]
sub ax,[.x2]
cmp ax,0
jg @f
neg ax ; calc absolute value
@@:
mov [.delta_x],ax
mov bx,[.y1]
sub bx,[.y2]
cmp bx,0
jg @f
neg bx
@@:
mov [.delta_y],bx
cmp ax,bx
je .deg45_l
jl .more_vertical_l
jg .more_horizon_l
jmp .end_line
;
.horizontal_l:
mov ax,[.x1]
mov bx,[.x2]
cmp bx,ax
jge @f
.sort
@@:
mov bx,[.x2]
sub bx,[.x1]
movsx ebx,bx
cmp ebx,0 ;line lenght equql 0
je .end_line
mov [.delta_x],ebx
call .calc_delta
mov eax,[.xres] ;SIZE_X
movsx ebx,word[.y1]
mul ebx
add esi,eax
lea eax,[eax*3]
add esi,eax
add edi,eax
movsx eax,word[.x1]
add esi,eax
lea eax,[eax*3]
add edi,eax
add esi,eax
mov ecx,[.delta_x]
movsx ebx,word[.r1]
shl ebx,ROUND
mov [.cr],ebx
movsx ebx,word[.g1]
shl ebx,ROUND
mov [.cg],ebx
movsx ebx,word[.b1]
shl ebx,ROUND
mov [.cb],ebx
movsx ebx,word[.z1]
shl ebx,ROUND
mov [.cz],ebx
if Ext >= SSE2
movups xmm1,[.cz]
end if
.hdraw:
if Ext >= SSE2
movd ebx,xmm1
else
mov ebx,[.cz]
end if
cmp [esi],ebx
jle .skip
.draw_pixel
.skip:
add edi,3
add esi,4
.update_cur_var
loop .hdraw
jmp .end_line
.vertical_l:
mov ax,[.y1]
cmp [.y2],ax
jge @f
.sort
@@:
mov bx,[.y2]
sub bx,[.y1]
movsx ebx,bx
cmp ebx,0
je .end_line
mov [.delta_y],ebx
call .calc_delta
mov eax,[.xres] ;SIZE_X
movsx ebx,word[.y1]
mul ebx
add esi,eax
lea eax,[eax*3]
add edi,eax
add esi,eax
movsx eax,word[.x1]
add esi,eax
lea eax,[eax*3]
add esi,eax
add edi,eax
mov ecx,[.delta_y]
movsx ebx,word[.r1]
shl ebx,ROUND
mov [.cr],ebx
movsx ebx,word[.g1]
shl ebx,ROUND
mov [.cg],ebx
movsx ebx,word[.b1]
shl ebx,ROUND
mov [.cb],ebx
movsx ebx,word[.z1]
shl ebx,ROUND
mov [.cz],ebx
if Ext >= SSE2
movups xmm1,[.cz]
end if
.v_draw:
if Ext >= SSE2
movd ebx,xmm1
else
mov ebx,[.cz]
end if
cmp [esi],ebx
jle @f
.draw_pixel
@@:
add edi,[.xres3]
add esi,[.xres4]
.update_cur_var
loop .v_draw
jmp .end_line
.deg45_l:
mov word[.line_lenght],ax
mov ax,[.x1]
cmp [.x2],ax
jge @f
.sort
@@:
mov bx,[.y2]
sub bx,[.y1]
movsx ebx,bx
cmp ebx,0
je .end_line
mov [.delta_y],ebx
mov bx,[.x2]
sub bx,[.x1]
movsx ebx,bx
mov [.delta_x],ebx
call .calc_delta
mov eax,[.xres]
movsx ebx,word[.y1] ;calc begin values in screen and Z buffers
mul ebx
lea ebx,[3*eax]
add edi,ebx
shl eax,2
add esi,eax
movsx eax,word[.x1]
lea ebx,[eax*3]
add edi,ebx
shl eax,2
add esi,eax
movzx ecx,word[.line_lenght]
movsx ebx,word[.r1]
shl ebx,ROUND
mov [.cr],ebx
movsx ebx,word[.g1]
shl ebx,ROUND
mov [.cg],ebx
movsx ebx,word[.b1]
shl ebx,ROUND
mov [.cb],ebx
movsx ebx,word[.z1]
shl ebx,ROUND
mov [.cz],ebx
.d45_draw:
if Ext >= SSE2
movd ebx,xmm1
else
mov ebx,[.cz]
end if
cmp [esi],ebx
jle @f
.draw_pixel
@@:
cmp dword[.delta_y],0
jl @f
add edi,[.xres3] ;SIZE_X*3+3
add edi,3
add esi,[.xres4] ;SIZE_X*4+4
add esi,4
jmp .d45_1
@@:
sub edi,[.xres3] ;(SIZE_X*3)-3
sub edi,3
sub esi,[.xres4] ;(SIZE_X*4)-4
sub esi,4
.d45_1:
.update_cur_var
loop .d45_draw
jmp .end_line
.more_vertical_l:
mov word[.line_lenght],bx
mov ax,[.y1]
cmp [.y2],ax
jge @f
.sort
@@:
mov bx,[.y2]
sub bx,[.y1]
movsx ebx,bx
cmp ebx,0
je .end_line ;=======================
mov [.delta_y],ebx
mov ax,[.x2]
sub ax,[.x1]
cwde
shl eax,ROUND
cdq
idiv ebx
mov [.delta],eax
call .calc_delta
mov eax,[.xres] ;SIZE_X
movsx ebx,word[.y1] ;calc begin values in screen and Z buffers
mul ebx
lea ebx,[3*eax]
add esi,ebx
add esi,eax
add edi,ebx
mov [.cscr],edi
mov [.czbuf],esi
movzx ecx,word[.line_lenght]
movsx ebx,word[.r1]
shl ebx,ROUND
mov [.cr],ebx
movsx ebx,word[.g1]
shl ebx,ROUND
mov [.cg],ebx
movsx ebx,word[.b1]
shl ebx,ROUND
mov [.cb],ebx
movsx ebx,word[.z1]
shl ebx,ROUND
mov [.cz],ebx
if Ext >= SSE2
movups xmm1,[.cz]
end if
movsx ebx,word[.x1]
shl ebx,ROUND
mov [.ccoord],ebx ; .ccoord -> x coordinate
.draw_m_v:
mov edi,[.cscr]
mov esi,[.czbuf]
mov eax,[.ccoord]
sar eax,ROUND
lea ebx,[eax*3]
add edi,ebx
add esi,ebx
add esi,eax
if Ext >= SSE2
movd ebx,xmm1
else
mov ebx,[.cz]
end if
cmp [esi],ebx
jle @f
.draw_pixel
@@:
mov eax,[.delta]
mov ebx,[.xres3]
add [.ccoord],eax
mov eax,[.xres4]
add dword[.cscr],ebx ;SIZE_X*3 ;
add dword[.czbuf],eax ;SIZE_X*4
.d_m_v1:
.update_cur_var
dec ecx
jnz .draw_m_v
jmp .end_line
.more_horizon_l:
mov word[.line_lenght],ax
mov ax,[.x1]
cmp [.x2],ax
jge @f
.sort
@@:
mov bx,[.x2]
sub bx,[.x1]
movsx ebx,bx
cmp ebx,0;=======================
je .end_line
mov [.delta_x],ebx
mov ax,[.y2]
sub ax,[.y1]
cwde
shl eax,ROUND
cdq
idiv ebx
mov [.delta],eax
call .calc_delta
;calc begin values in screen and Z buffers
movsx ebx,word[.x1]
mov eax,ebx
add esi,ebx
lea ebx,[3*ebx]
add esi,ebx
add edi,ebx
mov [.cscr],edi
mov [.czbuf],esi
movzx ecx,word[.line_lenght]
movsx ebx,word[.r1]
shl ebx,ROUND
mov [.cr],ebx
movsx ebx,word[.g1]
shl ebx,ROUND
mov [.cg],ebx
movsx ebx,word[.b1]
shl ebx,ROUND
mov [.cb],ebx
movsx ebx,word[.z1]
shl ebx,ROUND
mov [.cz],ebx
if Ext >= SSE2
movups xmm1,[.cz]
end if
movsx ebx,word[.y1]
shl ebx,ROUND
mov [.ccoord],ebx ; .ccoord -> y coordinate
.draw_m_h:
mov edi,[.cscr]
mov esi,[.czbuf]
mov eax,[.ccoord] ; ccoord - cur y coordinate
sar eax,ROUND
mov ebx,[.xres] ;SIZE_X
mul ebx
add esi,eax
lea eax,[eax*3]
add esi,eax
add edi,eax
if Ext >= SSE2
movd ebx,xmm1
else
mov ebx,[.cz]
end if
cmp [esi],ebx
jle @f
.draw_pixel
@@:
mov eax,[.delta]
add [.ccoord],eax
add dword[.cscr],3 ;
add dword[.czbuf],4
.update_cur_var
dec ecx
jnz .draw_m_h
.end_line:
mov esp,ebp
ret 24
.calc_delta:
mov ax,[.z2]
sub ax,[.z1]
cwde
shl eax,ROUND
cdq
idiv ebx
mov [.dz],eax
mov ax,[.r2]
sub ax,[.r1]
cwde
shl eax,ROUND
cdq
idiv ebx
mov [.dr],eax
mov ax,[.g2]
sub ax,[.g1]
cwde
shl eax,ROUND
cdq
idiv ebx
mov [.dg],eax
mov ax,[.b2]
sub ax,[.b1]
cwde
shl eax,ROUND
cdq
idiv ebx
mov [.db],eax
if Ext=MMX | Ext = SSE
movq mm2,[.dz]
movq mm3,[.dg]
else if Ext >= SSE2
movups xmm0,[.dz]
movups xmm6,[.mask]
end if
ret
.mask:
dq 0xffffffff00ffffff
dq 0xffffffffffffffff

View File

@ -1,4 +1,14 @@
View3ds 0.072 - march 2021
1. New displaying model - texturing with bilinear filtering and transparency
simultanusly. Note that filtering is done only inside polygon. To better
quality of image there is a need to use floats coordinates of texture to pass
as arguments to single triangle rendering proc.
2. Optimizations.
3. SSE3 version runs correct on SSE2 cpus, but real phong, glass and
transparented texturing with filtering rendering models are disabled.
-----------------------------------------------------------------------------------
View3ds 0.071 - VIII 2020 View3ds 0.071 - VIII 2020
1. New displaying model - glass - it's two pass rendering. First pass calculates 1. New displaying model - glass - it's two pass rendering. First pass calculates
Z position of all front pixels, second render image with adding reflective Z position of all front pixels, second render image with adding reflective

View File

@ -1,7 +1,12 @@
View3ds 0.072 - tiny viewer to .3ds and .asc files with several graphics View3ds 0.073 - tiny viewer to .3ds and .asc files with several graphics
effects implementation. effects implementation.
What's new? What's new?
1. I introduced procedure for searching nonredundand edges.
2. Writing some info about object: vertices, triangles unique edges
count.
1. New displaying model - texturing with bilinear filtering and transparency 1. New displaying model - texturing with bilinear filtering and transparency
simultanusly. Note that filtering is done only inside polygon. To better simultanusly. Note that filtering is done only inside polygon. To better
quality of image there is a need to use floats coordinates of texture to pass quality of image there is a need to use floats coordinates of texture to pass
@ -26,21 +31,23 @@ Buttons description:
8. rand. light: Randomize 3 unlinear lights( so called Phong's illumination). 8. rand. light: Randomize 3 unlinear lights( so called Phong's illumination).
9. Blur: blur N times; N=0,1,2,3,4,5 9. Blur: blur N times; N=0,1,2,3,4,5
10.11,12,13. loseless operations (rotary 90, 180 degrees). 10.11,12,13. loseless operations (rotary 90, 180 degrees).
12. emboss: Do emboss effect( flat bumps ), use 'bumps deep' button to do edges more deep. 12. emboss: Do emboss effect( flat bumps ), use 'bumps deep' button to do edges
more deep.
13. fire: do motion blur ( looks like fire ). 13. fire: do motion blur ( looks like fire ).
14. move: changes meaning x,y,z +/- buttons -> obj: moving object, camr: moving camera, wave: x,y +/- increase, 14. move: changes meaning x,y,z +/- buttons -> obj: moving object, camr: moving
decrease wave effect frequency and amplitude. camera, wave: x,y +/- increase, decrease wave effect frequency and amplitude.
15. generate: Generates some objects: node, Thorn Crown, heart... 15. generate: Generates some objects: node, Thorn Crown, heart...
16. bumps: random, according to texture. 16. bumps: random, according to texture.
17. bumps deep -> create bumps deeper or lighter. 17. bumps deep -> create bumps deeper or lighter.
18. re-map tex -> re-map texture and bump map coordinates, to change spherical mapping 18. re-map tex -> re-map texture and bump map coordinates, to change spherical
around axle use 'xchg' and 'mirror' buttons, then press 're-map tex' button. mapping around axle use 'xchg' and 'mirror' buttons, then press 're-map tex' button.
19. bright + -> increase picture brightness. 19. bright + -> increase picture brightness.
20. bright - -> decrease picture brightness. 20. bright - -> decrease picture brightness.
21. wav effect -> do effect based sine function. 21. wav effect -> do effect based sine function.
22. editor -> setting editing option. If is "on" then red bars are draw according to each vertex, Pressing 22. editor -> setting editing option. If is "on" then red bars are draw according to each
and moving left mouse button (cursor must be on handler)- change vertex position. If left mouse button vertex, Pressing and moving left mouse button (cursor must be on handler)- change
is released apply current position. You may also decrease whole handlers count by enable culling (using vertex position. If left mouse button is released apply current position. You may also
appropriate button) - some back handlers become hidden. decrease whole handlers count by enable culling (using appropriate button) - some
back handlers become hidden.
Maciej Guba III 2021 Maciej Guba V 2021

File diff suppressed because it is too large Load Diff