Help and Questions

fixed!

working on dithering:

1 Like

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

1 Like

Wow that’s cool

1 Like

And I’m glad you noticed because I put that intentionally :smiley:

1 Like

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!

1 Like

nice!

1 Like

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?

2 Likes

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)

1 Like

image

@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?

2 Likes

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
1 Like

@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?

1 Like

yea its the floyd steinberg dithering algorithm

1 Like

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.

1 Like

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]
}
2 Likes

hmmm. brain hurt. (:point_right:゚ヮ゚):point_right:

1 Like

@richard How do I make a sprite clip through a wall in 3D rendering mode?

1 Like

@unknown_Ink1 did you try setting ā€œghost through wallsā€ on the sprite?

ghost-through-walls

1 Like