#Raycasting fries my GPU

52 messages · Page 1 of 1 (latest)

jade gazelle
#

Hi! I was playing with shaders and trying to implement a raycasting (and I actually succeeded) but I get 5 fps and my RTX 2060 heats over 50°C.
I don't know why this is happening. Help me, please

modest coral
#

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 :)

jade gazelle
quartz timber
#

mine idles at 47*C

#

windows task manager can tell you if you're on windows

ancient flare
jade gazelle
ancient flare
jade gazelle
jade gazelle
ancient flare
# jade gazelle What is hardware raytracing 😕

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

jade gazelle
ancient flare
jade gazelle
#

Oh 😦

ancient flare
# jade gazelle 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

fading current
#

*can't yet 🙂

ancient flare
#

yea

jade gazelle
ancient flare
#

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.

jade gazelle
#

lol

#

omg

ancient flare
#

at least you won't need to write your own backend!!

quartz timber
#

oh yeah terraria would not run on hardware from back when it was released if it was raytracing lol

still vortex
#

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

jade gazelle
#

I'm compiling with the level of 3 for dependencies, and 0 for the crate. Does it affect on GPU shaders?

still vortex
#

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?

jade gazelle
#

Oh, makes sense, thank you. But I don't think that is the problem

jade gazelle
ancient flare
jade gazelle
#

4 + 4 +4 I think (u32 and vec2<f32>)

#

for the one tile

#

so 80 x 45 x (4 + 4 + 4)

still vortex
#

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

ancient flare
#

i think he was actually making a raycaster, which would explain the performance

still vortex
jade gazelle
still vortex
#

🤔 what do you mean by only one time?

jade gazelle
#

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

still vortex
#

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