Closed Zifkan closed 1 year ago
Okay so 2 parts to this:
(1) You could use a static array to send over the planes assuming the number will be static. Here's a quick sample of code from something I did a little while ago (borrowed from internal engine code):
// Struct def
SHADER_PARAMETER_ARRAY(FVector4f, FrustumPlanes, [5])
...
// PassParameter setup
for (int32 PlaneIndex = 0; PlaneIndex < 5; ++PlaneIndex)
{
PassParameters->FrustumPlanes[PlaneIndex] = FVector4f(InViewDesc.Planes[PlaneIndex]);
}
(2) I'm not exactly sure what might be going wrong with your code sample above but here are a few observations:
SHADER_PARAMETER_RDG_BUFFER_SRV(Buffer<float4>, ...)
-> SHADER_PARAMETER_RDG_BUFFER_SRV(Buffer<FVector4f>, ...)
sizeof(FVector)
-> sizeof(FVector4f)
PF_FloatRGBA
is using 16bit floats. PF_A32B32G32R32F
should be the one for 32bit. (although the ordering may need to be reassembled on the shader side)Hope this helps.
Ty for you answer.
First way worked fine, but 2nd still not. Anyway i used easiest first way for pass my planes into shader and... i have same problem with mine BoundBoxesBuffer its doesn't pass data into too and there i can't use it as static because its huge and obvious dynamic
First way worked fine, but 2nd still not.
To add onto the answer you already got: I had a similar frustrating issue before I remembered UE internally uses doubles (FVector4 = FVector4d, not FVector4f). I'm assuming Params.CameraPlanes.GetData()
is pointing to a TArray<FVector4>
. So you were taking an array of 4 doubles, and telling the shader to interpret 4floats.
Your 2 options would be to convert your input Params.CameraPlanes (dispatch params) to a TArray<FVector4f>
first
OR go back to FVector4 everywhere but change all the shader buffers to Buffer<double4>
First way worked fine, but 2nd still not.
To add onto the answer you already got: I had a similar frustrating issue before I remembered UE internally uses doubles (FVector4 = FVector4d, not FVector4f). I'm assuming
Params.CameraPlanes.GetData()
is pointing to aTArray<FVector4>
. So you were taking an array of 4 doubles, and telling the shader to interpret 4floats.Your 2 options would be to convert your input Params.CameraPlanes (dispatch params) to a
TArray<FVector4f>
first OR go back to FVector4 everywhere but change all the shader buffers toBuffer<double4>
ty for reply i already solve this problem
Hello im on UE 5.3. I need some help with passing data into like this. Params.CameraPlanes this is TArray.
Declaration buffer look like this
And in Compute shader
So problem that data passed incorrect. Im not sure about using PF_FloatRGBA in GraphBuilder.CreateSRV. I also tried PF_A32B32G32R32F. So tips about this param will be welcome Thank you for any tips