K
K
Ksenia2018-06-30 06:33:56
Shaders
Ksenia, 2018-06-30 06:33:56

Is it possible to arrange mat. calculation w / w shader and pass the result to the script (Unity)?

Hey!
Tell me, is it possible to transfer long one-time mats to Unity. calculations on the GPU?
Sorry for the noob question, I don't understand how it works.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Daniil Basmanov, 2018-06-30
@Ksushqa

You can, but it won't be faster in all cases, and eventually you'll still have to profile to understand the payoff. Video cards are good at working with vectors and have special instructions that allow you to perform several arithmetic operations at a time, respectively, and your algorithm should use these strengths, if you just need to calculate the factorial, then there is no point in messing with the video card, you will lose more on loading / uploading data from the GPU.
As for the implementation, this can be done either with compute shaders or with regular shaders, it all depends on the capabilities of the target platform. On a computer, if you really want to, you can also tie CUDA. If you haven’t worked with shaders before, then I can advise The Book of Shaders, it's not about Unity, but it's sensible enough.
By the way, if your task is not to transfer to a video card, but to optimize, then the processors are also not badly sewn, they have SIMD, maybe this will suit you better.

G
GavriKos, 2018-06-30
@GavriKos

Can. You wrote the answer in the title - through the shader. Here:
https://docs.unity3d.com/Manual/ComputeShaders.html
PS the javascript tag, what does it have to do with it?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question