pouët.net

free directional madness, or evil x-interpolator bugs

category: code [glöplog]
 
I'm trying to code a simple DOS demo in Watcom C, and I coded a free directional planes effect. Currently it works at 40x100 grid (interpolated to 320x100 and displayed in 320x100@60Hz tweaked mode 13h), but...
my horizontal grid-interpolation routine (fdInterpolateHorizontal() in sourcecode) produces some bugs when texture coordinates wraps around: i.e if two nodes contain 0x20 and 0x40 it works fine, but when they contain 0xF0 and 0x00 it counts backward and distorts texture coordinates. SHIT!

Currently it looks like that: BB Image
(notice that interpolation bugs at texture eges, and yes, ugly XOR pattern :)

Source code and executable: http://rghost.ru/7tnPmhcwh

Any ideas? :)
added on the 2015-11-03 18:57:57 by wbcbz7 wbcbz7
but it looks better like this! it's almost glitch art!
Maali, yep! :D
Gargaj, erm...it describes a texture wrapping method in D3D, however i'm doing all stuff in software...thanx anyway :)
added on the 2015-11-03 19:29:58 by wbcbz7 wbcbz7
without spending too much time thinking about this, but if you keep the values in ux0 ux1 etc. left aligned (so they occupy the higher order bits), do the subtraction and then do a right shift to get the fixed point format you want, the sign extension of the right shift should solve your problem (unless you zoom out too much and get kinda aliasing problems, but that would be a general problem at some point).
added on the 2015-11-03 20:00:23 by jix jix
wormsbiysk: the principle is the same though - you test for the "shortest distance".
added on the 2015-11-03 20:09:17 by Gargaj Gargaj
use signed (short) ints as texcoords and pow2 map; solved.
added on the 2015-11-03 20:44:52 by superplek superplek
Quote:
use signed (short) ints as texcoords and pow2 map; solved.

YES! it works now properly! (currently at 60fps only on P250MMX (83x3.5), shame :), trying to optimize it)
added on the 2015-11-04 09:25:52 by wbcbz7 wbcbz7
40x100 grid sounds huge to me. You can easily make a silky smooth 320x200 version with 8x8 blocks (so grid size of 40x25).
added on the 2015-11-04 10:22:07 by Preacher Preacher
yep, now i'm using 40x25 grid and tracing takes about 40-50 scanlines but grid interpolation takes one entire frame(!) in 320x200 and texturing takes another 150-200 scanlines.
so it worka only in two frames = 30fps in 320x200 :(
added on the 2015-11-04 10:42:41 by wbcbz7 wbcbz7
I haven't looked at the code but that's slow as shit of course:
- any floats involved at any point? kill 'em
- 32-bit color? use mmx
- poorly cached memory reads?
- no divs!

etc.
added on the 2015-11-04 11:30:31 by superplek superplek
Second try: http://rghost.ru/8HFpsSptB (and red rasterbar)

compiler options:

Code:wcl386.exe freedirf.c -zp16 -fp5 -ox -or


and profile log:
Code: 164374 1040 fdNormalize 595449 1 fdInterpolateVertical 2187873 1 fdInterpolateHorizontal 17818894 1 fdbuildSinTable 107057 1040 fd3dRotate 2773401 1 fdbuildTexture 754647 1 fdCalcPlanes 1595055 1 fdDrawPlanes 37364119 1 main

(don't mind sincalc and texture building routines as they are called once in beginning ;)

As I can see the most CPU hogging procedures are fdInterpolateHorizontal and fdDrawPlanes which I think just suffers from cache misses.

Quote:
- 32-bit color? use mmx

no, 8-bit color, I can use mmx of course but it will cause troubles with dosbox
Code:- no divs!

two float divs in tracing routine (but processed for each node in grid)
added on the 2015-11-04 12:40:57 by wbcbz7 wbcbz7
jesus christ why all the tables? only to blit it in drawplanes? :)

get rid of 'em, no wonder with all those temporaries and pointers you're giving that x86 a hard time

1. calculate grid (straightforward and simple)
2. bilerp it *directly* to screen
added on the 2015-11-04 14:22:47 by superplek superplek
in one word: simplify
added on the 2015-11-04 14:23:10 by superplek superplek
you're touching way more memory than necessary to get it done (gargaj can we have a fucking edit feature here already if you can find the time in between polishing your ferrari?)
added on the 2015-11-04 14:24:16 by superplek superplek
No.
added on the 2015-11-04 14:32:37 by Gargaj Gargaj
asshole
added on the 2015-11-05 20:40:34 by superplek superplek
I've heard Pouet is open source now!
added on the 2015-11-06 09:04:52 by Kylearan Kylearan
well, almost :D
anyway, thanx to all :)
added on the 2015-11-06 13:58:08 by wbcbz7 wbcbz7

login