#Raycasting fries my GPU
52 messages · Page 1 of 1 (latest)
I'm a bit of a shader noob so I can't help you there, but 50°C isn't very hot for a gpu :)
I actually don't know the temperature, because I don't have a program to see it, but by touching the GPU I can say it's very very hot
assuming ur pc isn't messed up , this is probably b/c you aren't using hardware raytracing
uuh, I'm not sure where to see it. I'm on Windows 11
press Ctrl + Shift + Esc
What is hardware raytracing 😕
I mean there is only the GPU usage, but not the temperature
when you are implementing raytracing in the way you are doing it, it is called 'software raytracing', much like if you rendered on the CPU instead of the GPU it would be called 'software rendering'. you aren't taking advantage of the GPU's hardware raytracing abilities so it is really slow
wow, uuh, how to make it hardware?
you can't with bevy's wgpu backend, see https://github.com/gfx-rs/wgpu/issues/1040
you'd need to write your own backend using a graphics API like Vulkan directly, https://www.khronos.org/blog/vulkan-ray-tracing-final-specification-release
Oh 😦
that isn't to say you can't improve the performance of your software raycasting - just you probably aren't doing what you think you are doing
*can't yet 🙂
yea
I trying to implement a dynamic lighting in my Terraria clone like this https://www.reddit.com/r/Terraria/comments/vhtlmk/testing_a_modified_lighting_engine/. I thought I can achieve it by using ray casting
It does not use raycasting. For every light source, light is spread horizontally and vertically within a certain range. The tiles in the corners (the vast majority) are then iterated over, with each tile taking one iteration. Each tile gets its light only from the tile to the left or right of it (depending on the direction pointing toward the light source) and above or below it. Even though each tile is only directly affected by two other tiles, I have a precomputed table of values affecting each individual tile’s calculations so that the overall effect is that light travels outward in all directions.
oh yeah terraria would not run on hardware from back when it was released if it was raytracing lol
Yeah 😄
Just add a bit more info on the software vs hardware raytracing. It's true that using hardware raytracing will be faster, but a compute based raytracer will still be orders of magnitude faster than a cpu based raytracer. My own cpu based raytracer is way faster than that for simple scenes with a few spheres so a compute based simple raytracer should really not be that slow
I looked at the shader code and I didn't see anything obviously wrong with it
Are you compiling with optimization? It's possible the bottleneck isn't the gpu
I'm compiling with the level of 3 for dependencies, and 0 for the crate. Does it affect on GPU shaders?
no, but it could affect the communication between the cpu and gpu
looking at the shader again, what's the size of the tile buffer?
Oh, makes sense, thank you. But I don't think that is the problem
It depends on the size of viewport. For 1280x720 it is 80x45
how many bytes
I think the issue might be your angle < 50 thing. It's a lot of iterations to have to do on every instance of the shader. I'm not super familiar with 2d based raytracing though, so not sure how to do that
It kinda looks like you are looking in every direction for every pixel, which doesn't seem efficient. Generally, raytracers look in a few random directions and try to mostly aim at the light direction, but it's possible I'm missing something
i think he was actually making a raycaster, which would explain the performance
yeah, I keep thinking they are interchangeable terms even if they aren't, but you are right that there's no tracing going on here
yea
Yeah, I also had such thoughts, I need to do raycasting only one time, but I don't know how to workaround it in a shader
🤔 what do you mean by only one time?
Shader runs raycasting for every pixel which is very very inefficient, but I actually need to do it only for one pixel (the one that the cursor point on)
Like I need to do raycasting only if it's the new frame
I need to do raycasting only once per frame
But instead I do raycasting 1280x900 times per frame
honestly, if it just runs once from a single point, it might be simpler to just do it on the cpu
because calling a shader like that for only one pixel just adds a ton of overhead for very little gains
unless maybe you figure out a way to run one shader per angle thing, to that could parallelize I guess