Hey there!
In a current project I use a compute shader to run a simulation. I pass several Agents into the shader and calculate their velocity. I want to be able to chance the way of calculation at runtime, basically scripting a brain.
What I tried to do:
void Advect (uint3 id : SV_DispatchThreadID)
{
//dataBuffer[id.x].Position += dataBuffer[id.x].Velocity;
float3 pos=float3(0,0,0);
for( uint i = 0;i < 100; i++ )
{
... Setup ...
#include "Brain.code"
... Finish ...
}
//update velocity
dataBuffer[id.x].Velocity = w*dataBuffer[id.x].Velocity + pos;
//advect position
dataBuffer[id.x].Position = dataBuffer[id.x].Position + dataBuffer[id.x].Velocity;
}
I want to fill the Brain.code file with the corresponding actions and run it in the shader. This works fine with a pre-generated file but is there some way to tell the shader to recompile when the file changes at runtime?
↧