fixed!
working on dithering:
WOOOOOAAAAAAAHHH!!
Thatās stunningly beautiful! The raycasting in itself is an art, this would look so good combined with a gameā¦
shadowcasting is a more accurate term! I should probably have renamed the project
Wow thatās cool
And Iām glad you noticed because I put that intentionally
dithering is now available in the extension! It runs pretty well even though I havenāt optimized anything yet. Expect it to get faster, though!
nice!
pretty cool, but when using the normal 16x16 tilemap you dont get to see much of the dithering
most of the time you only see half of the dithered tiles, so i was thinking maybe adding a setting for that?
hey @richard, i was making a dithering algorithm i mad faster by using bit shifting but i does not work anymore, it does not give me a error but the dithering does not work anymore?
with bit shifting
without
i tried to add parentheses when i made this post but that also didnāt work
what am i doig wrong?
(if you want to test with a smaller image you can change the return block in the āTheImageā function, also do it in blocks it will save you some problems) (for creating a new image i havent made a website for it yet as Iām still stuck on html so for now you can use this)
@YuHayate looks like youāre trying to do bitshifting in order to replace the division by 16 in your code. Bitshifting does indeed work for that, but itās integer division. That means it will cut off the decimal point component of the result. All of those fractions above have numerators that are less than 16, meaning that bitshifting to the right by 4 will simply return 0.
if thatās so shouldnāt the dithering just not spread the error instead of not working?
also now that i read this twice idk if you looked at what i sent
those variables are there only in the one without bit shifting (only used there)
insted of doing
errR * 7/16
errG * 7/16
errB * 7/16
// ect
i did
(errR * 7) >> 4
(errG * 7) >> 4
(errB * 7) >> 4
@YuHayate iām not really sure what your code is trying to do, so itās tough for me to debug it. were you basing this off of some pre-existing code?
yea its the floyd steinberg dithering algorithm
Iām pretty sure my earlier comment on this stands. This algorithm requires the decimal component of the error for whatever reason so bitshifting isnāt going to work.
If you really wanted to do bitshifting, you could represent everything as fixed point numbers (thatās what the Fx8 stuff in Arcade is for). That being said, itās not going to make your program faster in the browser. On hardware, yes, but your computer has absolutely no trouble doing regular old division.
if youāre looking to speed up this code, I think you might want to reconsider how youāre representing your image. A string of all the hex codes is going to be tough to work with and parsing all those many thousands of pixels will be pretty slow.
How did you generate this string in the first place? I think youāll have more luck if you rewrite whatever script you have to output a buffer instead. Buffers are like arrays of bytes and you can define them using the syntax:
hex`00112233445566778899aabbccddeeff`
Each two numbers in that string represents a byte in hexadecimal format. Fun fact, those HTML color codes you have in your string are also hexadecimal strings, so you can convert it into a hex buffer simply by removing the #, space, quotes, and comma characters from your string and wrapping it in the hex``
syntax!
Once you have it in a buffer, you can access pixel data like so:
const myImage = hex`aabbcc`
function getR(image: Buffer, index: number) {
return image[index * 3]
}
function getG(image: Buffer, index: number) {
return image[index * 3 + 1]
}
function getB(image: Buffer, index: number) {
return image[index * 3 + 2]
}
hmmm. brain hurt. (ļ¾ć®ļ¾)
@richard How do I make a sprite clip through a wall in 3D rendering mode?
@unknown_Ink1 did you try setting āghost through wallsā on the sprite?