ayoubkhammassi / customcomputeshaders Goto Github PK
View Code? Open in Web Editor NEWThe minimal source code for adding and using a custom compute shader in Unreal Engine 4
License: MIT License
The minimal source code for adding and using a custom compute shader in Unreal Engine 4
License: MIT License
This is not an issue :-)
I'm trying to learn more about RDG in Unreal and HLSL, so far so good, with one exception: I'm trying to pass an array of a custom struct from C++ to HLSL via a structured buffer, and I currently don't know how to tell the C++ buffer: hey, this is your data so you can pass it to the GPU.
it is possible that I don't fully comprehend the role and scope of a structured buffer...
In C++ my shader has
SHADER_PARAMETER_RDG_BUFFER_UAV(RWStructuredBuffer<FMyStuff>, MyStuffBuffer)
Then at some point I create it
FRDGBufferRef MyStuffBuffer = GraphBuilder.CreateBuffer(MyStuffBufferDesc, TEXT("MyStuffBuffer"));
here I was expecting to be able to do something like
MyStuffBuffer.SetData(some TArray<FMyStuff>)
then I assign it to the parameters
PassParameters.MyStuffBuffer = GraphBuilder.CreateUAV(MyStuffBuffer);
And then I pass everything to the GPU via
FComputeShaderUtils::AddPass
I was hoping there is a way, after I create the RDG buffer in C++, to set its data/payload as some TArray<FMyStuff>
that I previously created and populated in C++
I poked around the source code, but to no avail, this specific aspect of RDG still eludes me ๐
do you happen to have any idea, by any chance? Thanks!
Removing *
from *whiteNoiseCS
solved the issue for me.
4.26 has a signature for FComputeShaderUtils::Dispatch
that doesn't require a deference:
static void Dispatch(FRHIComputeCommandList& RHICmdList, const TShaderRef<TShaderClass>& ComputeShader,
Disclaimer: I'm using a custom 4.26 build. Haven't checked the official build.
Hey just a heads up I had to add
#include "/Engine/Public/Platform.ush"
to the top of the shader in order to get it to compile in UE 4.25. Posting in case anyone else comes across this issue.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.