AskingQuestions / Shadeup

A language for WebGPU that makes writing shaders easier
https://shadeup.dev
137 stars 4 forks source link

Support UE5.1 #1

Closed colinbouvry closed 1 year ago

colinbouvry commented 1 year ago

Hello I believe that ComputeShader_rt.zip does not work without some issues.

AskingQuestions commented 1 year ago

Hey, thanks for the report!

I've just pushed a release (8629bd8) which should address the issues you're running into on 5.1.

Feel free to pull down the latest archive from the repo or download from the site and let me know if it's working for you. Thanks

Example of the Compute Shader RT build running in 5.1:

snip

colinbouvry commented 1 year ago

Thanks and congrat ! RT works now. How do you do to refresh shader ExampleComputeShader.usf without relaunch UE ? With ComputeShader_mat I have this error : image

AskingQuestions commented 1 year ago

Awesome!

Ctrl + Shift + . will recompile shaders. That should update your compute shader as you make changes

You'll also want to follow this guide from Epic on how to enable Shader development mode: https://docs.unrealengine.com/4.26/en-US/ProgrammingAndScripting/Rendering/ShaderDevelopment/#retryingoncompileerrors

See the section that contains this:

Retrying on compile errors With r.ShaderDevelopmentMode enabled, you will get the opportunity to retry on shader compile error. This is especially important for global shaders since it is a fatal error if they do not compile successfully.

In debug, with the debugger attached, you will hit a breakpoint and get the compile error in the Visual Studio output window. You can then Double-click the error log to be taken directly to the offending line.

colinbouvry commented 1 year ago

enable r.ShaderDevelopmentMode by setting it to 1 I change the .usf file in visual studio and Ctrl + Shift + . for recompile shaders and nothing change. I just changed RenderTarget[DispatchThreadId.xy] = float3(1.0, 0.0, 0.0); to test Any idea ?

AskingQuestions commented 1 year ago

Hmm, was it rendering the checkerboard previously? Also, are you using the plain compute shader to render target example or the material to render target one?

If you're using the material to render target example please make sure the Use with virtual heightfield mesh is checked off in the material editor for the material you're using:

image

colinbouvry commented 1 year ago

It rendering the checkerboard previously. I use ComputeShader_rt. I'm using the plain compute shader to render target and material with render target inside image image

colinbouvry commented 1 year ago

I still can't update the new shader ! Is it possible to add usf into UE5 ?

AskingQuestions commented 1 year ago

Can you paste this into the usf file just as a sanity check and then restart the editor:

#include "/Engine/Public/Platform.ush"

RWTexture2D<float3> RenderTarget;

[numthreads(THREADS_X, THREADS_Y, THREADS_Z)]
void MySimpleComputeShader(
    uint3 DispatchThreadId : SV_DispatchThreadID,
    uint GroupIndex : SV_GroupIndex )
{
    // Simple checkerboard
    int x = floor(DispatchThreadId.x / 16.f);
    int y = floor(DispatchThreadId.y / 16.f);
    int c = (x + y % 2) % 2;

    RenderTarget[DispatchThreadId.xy] = float3(1.0, 0.0, 0.0);
}
AskingQuestions commented 1 year ago

Are you getting the image error still?

colinbouvry commented 1 year ago

I check usf and relaunch I have well the red color. I have always the problem to refresh shader ! Any idea ?

AskingQuestions commented 1 year ago

The only thing I can think of would be to add r.ShaderDevelopmentMode 1 to your ConsoleVariables.ini as per the ue guide

When working on shaders, be sure to enable r.ShaderDevelopmentMode by setting it to 1. The easiest way is to edit ConsoleVariables.ini so it is done every time you load. This will enable retry-on-error and shader development related logs and warnings.

Could there be any macro or external keyboard thing that's intercepting the Ctrl Shift . shortcut?

colinbouvry commented 1 year ago

I add r.ShaderDevelopmentMode 1 to my ConsoleVariables.in I have a popup when I tape Ctrl Shift . but I think It is always at 100% no change detected. It's the same ! I have "LoadingPhase": "PostConfigInit" it is correct ?

colinbouvry commented 1 year ago

I type this command : recompileshaders changed

[2022.12.04-00.27.56:440][129]LogShaders: Shader directory mapping /ComputeShaderShaders -> ../../../../../../dev/UnrealProjects/CCA/Plugins/ComputeShader_Plugin/Shaders/ComputeShader/Private [2022.12.04-00.27.57:431][129]LogShaderCompilers: Warning: [Searching for changed files] took [0.5761] s [2022.12.04-00.27.57:432][129]LogShaderCompilers: Warning: No Shader changes found.

The path is it wrong ?

colinbouvry commented 1 year ago

It works now ! I added changed lines in usf file and now it works with this command "recompileshaders changed" It does not work with AZERTY keyboard CTR + SHIFT + . ! Thanks a lot AskingQuestions

AskingQuestions commented 1 year ago

Ah, glad to hear it, and happy to help!