# Debugging USF (Unreal Shader Files)

**URL:** <https://forums.unrealengine.com/t/debugging-usf-unreal-shader-files/4746>\
**Category:** Rendering\
**Tags:** unreal-engine\
**Created:** [May 21, 2014, 12:53am UTC](https://forums.unrealengine.com/t/debugging-usf-unreal-shader-files/4746 "2014-05-21T00:53:01Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![ambershee](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ambershee](https://forums.unrealengine.com/u/ambershee)\
**Post date:** [May 21, 2014, 12:53am UTC](https://forums.unrealengine.com/t/debugging-usf-unreal-shader-files/4746/1 "2014-05-21T00:53:01Z")

</div>

Hello!

I’m looking for information on how people go about debugging USF shaders - including when they are not working, but also if they are not compiling (where can one get information on why they are failing?).

Edit: I’ve found this document, which is a good start!

> **[Shader Development](https://docs.unrealengine.com/4.27/en-US/ProgrammingAndScripting/Rendering/ShaderDevelopment/)**
>
> Information for graphics programmers writing shaders.

---

<div class="post-metadata">

**Author:** ![ambershee](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ambershee](https://forums.unrealengine.com/u/ambershee)\
**Post date:** [May 21, 2014, 5:00am UTC](https://forums.unrealengine.com/t/debugging-usf-unreal-shader-files/4746/2 "2014-05-21T05:00:02Z")

</div>

Thanks - all handy information. Hopefully someone’ll have a decent idea of how to debug it with something like the VS tools.

---

<div class="post-metadata">

**Author:** ![ambershee](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ambershee](https://forums.unrealengine.com/u/ambershee)\
**Post date:** [May 22, 2014, 10:42pm UTC](https://forums.unrealengine.com/t/debugging-usf-unreal-shader-files/4746/4 "2014-05-22T22:42:40Z")

</div>

Thanks - that’s more or less what I’ve been up to, but having a decent tool to work with would be infinitely more helpful 😕

---

<div class="post-metadata">

**Author:** ![Drayan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Drayan](https://forums.unrealengine.com/u/Drayan)\
**Post date:** [June 20, 2014, 10:51am UTC](https://forums.unrealengine.com/t/debugging-usf-unreal-shader-files/4746/5 "2014-06-20T10:51:19Z")

</div>

For my part, I was able to capture frame with RenderDoc and with Nvidia nSight. It work very well, both. (With a little preferences for Nvidia nSight, because it’s pluged in VS).

But I can’t have HLSL code out of my shaders. (I modified the flags of ShaderFormatD3D to have DEBUG\_SHADERS 1, it should therefore compile shaders with debug info, but I got the shaders in ASM…)  
If someone have a solution to have the debug symbols, it would be great !

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_69853c21](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_69853c21](https://forums.unrealengine.com/u/anonymous_user_69853c21)\
**Post date:** [June 20, 2014, 12:43pm UTC](https://forums.unrealengine.com/t/debugging-usf-unreal-shader-files/4746/6 "2014-06-20T12:43:00Z")

</div>

Sorry, I don’t have a solution.  
I’ve tried to capture debug data with pix and with renderdoc, but without success. Actually, with renderdoc I can run the editor lobby (where I need to select a project) and nothing more - on project select editor closes without any errors. Renderdoc logs have no error info too. So how do you using it?

Upd.: I packaged a game and now can run renderdoc with it. But I don’t know - packaging happens in release mode, so maybe where’s some data loss? Another sad side - in order to debug shader I need to build a project what takes 15 min on my machine. Oh, and no hlsl too, just asm, but it’s better than nothing.

---

<div class="post-metadata">

**Author:** ![Drayan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Drayan](https://forums.unrealengine.com/u/Drayan)\
**Post date:** [June 22, 2014, 5:32pm UTC](https://forums.unrealengine.com/t/debugging-usf-unreal-shader-files/4746/7 "2014-06-22T17:32:26Z")

</div>

Hello,

Okay, maybe I’ll make a tutorial for this; I found a way to have HLSL code in nvidia nsight, with renderdoc, it doesn’t work (even if it _should_…).  
Actually, UE4 strip debug information from the compiled shaders in the UE4 shader compression process. I found how to add debug information in the shader, but I didn’t see that the after the compilation, the shaders was compressed, and farewell debug informations.

I have another problem now, but it’s very probably because my hardware doesn’t allow it, more than a problem with nsight or UE4 -\> I can’t make breakpoint in shaders. But well, I can have the output of UE4 (there’s actually two way to have them), and I can have some information in the pipeline with nsight. It’s enough for now, but I’ll probably check on the nvidia website if the breakpoint problem come from my hardware (I don’t even meet the UE4 minimum _shame_), or if the compilation process omit some informations.

**EDIT :**  
I can confirm the problem come from my configuration, as stated on the nvidia website.

> [@NVidia](#):
>
> You cannot debug a shader with a local debugging configuration. You must configure your system for remote debugging to debug a shader.

So I’ll try later, if I need, to remote debug my UE4 project on another computer, from this one.

Anyway, if someone need it, you should now be able, with a remote configuration, to set breakpoint in a shaders. 🙂

PS : I’m not english speaker/writer. So, if you found some big mistakes, please, let me know.

---

<div class="post-metadata">

**Author:** ![Drayan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Drayan](https://forums.unrealengine.com/u/Drayan)\
**Post date:** [June 24, 2014, 8:54am UTC](https://forums.unrealengine.com/t/debugging-usf-unreal-shader-files/4746/9 "2014-06-24T08:54:24Z")

</div>

> [@DanielW;82571](#):
>
> I haven’t tried source in Nsight for a while, but some things you can try:
> 
> - Remove the call to D3DStripShader in D3D11ShaderCompiler.cpp. You have to recompile ShaderCompileWorker Win64 Development to propagate the change. And then add a space or something to common.usf to force shaders to recompile (if you are working on a global shader just edit it a bit).
> - In UE4 we compile the shaders in a different app (ShaderCompileWorker) which allows making use of all your cores. However tools like NSight don’t know about this other app and they only hook the compile calls in the main executable. If you open BaseEngine.ini and set bAllowCompilingThroughWorkers=False, any future shaders will be compiled from the main executable. Of course, this will make compiling super slow.

Thanks,

That’s exactly what I’m doing, but I didn’t add a space in common.usf. This could explain why I only got my Vertex Factory source in nsight and not the others ?  
And I can try for removing the compiling with worker. (Already did too, actually). But, as you said, it’s very slow. And (I guess) as I’m working on a VF, every times I make a change to my VF it need to recompile all the shaders (around 4000 shaders…).

With the worker, it takes something like 10 minutes on my computer. So without, it will be long…

In annex, sometimes my VF compile in less than a seconds (it just recompile the VF ?), sometimes it recompile the whole… I don’t really know why.

---

<div class="post-metadata">

**Author:** ![Drayan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Drayan](https://forums.unrealengine.com/u/Drayan)\
**Post date:** [June 25, 2014, 12:48pm UTC](https://forums.unrealengine.com/t/debugging-usf-unreal-shader-files/4746/11 "2014-06-25T12:48:24Z")

</div>

Yes, that’s make sense, thanks for your input .

Actually, I WAS looking at Local VF. Until I understand what it make. But well, I’ll change my ShouldCache methods.

Thanks again !

---

<div class="post-metadata">

**Author:** ![Temaran](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Temaran](https://forums.unrealengine.com/u/Temaran)\
**Post date:** [August 27, 2014, 11:51pm UTC](https://forums.unrealengine.com/t/debugging-usf-unreal-shader-files/4746/12 "2014-08-27T23:51:08Z")

</div>

Hello!

I do not mean to necro this thread, but I thought my small tutorial on this topic might be useful for people who find this thread but are still wondering what tools can be used and how.  
Here is the link:

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

I hope this will be useful to someone 🙂

Best regards,  
Temaran

---

<div class="post-metadata">

**Author:** ![MarkEntingh](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/markentingh/32/984569_2.png) [@MarkEntingh](https://forums.unrealengine.com/u/MarkEntingh)\
**Post date:** [April 7, 2024, 10:09am UTC](https://forums.unrealengine.com/t/debugging-usf-unreal-shader-files/4746/13 "2024-04-07T10:09:45Z")

</div>

I’m new to developing shaders using USF, but I would say, try creating a shader first using [shadertoy.com](http://shadertoy.com) and translate the GLSL code over to HLSL once you are satisfied with the results that you created on shadertoy.
