x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Modifying vertex normals & tangents in custom shader code

I want to port a Unity3D project that I created to UE4.

The game uses a custom vertex shader to modify positions, normals & tangents from the incoming vertices to bend them to form a sphere. The effect can be seen here: https://www.youtube.com/watch?v=CyTU03Ceo6I

I was able to modify the vertex positions with a custom node and put the result into the "World Position Offset", while subtracting the world position at the same time to have a new unique vertex position.

My problem is that I have no idea how to modify the normals & tangets for correct lighting.

As I see this, the "World Position Offset" is the only node that is computed in the vertex shader part, but theree are no normal / tangent vertex nodes available.

I may be able to modify the interpolated vertex normal in the fragment shader part and modify the "Normal" node accordingly, but from a performance view, this would be a bad option.

For the tangent, there is no output node at all.

Product Version: Not Selected
Tags:
more ▼

asked Nov 07 '14 at 09:39 AM in Rendering

avatar image

Lyve
6 2 3 3

avatar image ThisGuy5234 Nov 07 '14 at 12:37 PM

Hi Nils,

Tetrissphere ftw!

I have not much experience with the unreal material system.

But, afaik, you can access the normals as seen here:

https://docs.unrealengine.com/latest/INT/Engine/Rendering/Materials/MaterialInputs/index.html

For accessing tangent-space, perhaps this helps ?

https://docs.unrealengine.com/latest/INT/Engine/Rendering/LightingAndShadows/BumpMappingWithoutTangentSpace/index.html

Have fun & GL, Carsten

avatar image edoublea Nov 07 '14 at 05:57 PM

I am also interested in this topic. I've seen a lot of people posting examples where they have manually calculated normals inside of the vertex shader (or used other trickery, like binormals/tangents offsets), and are then passing those vertex-shader calculations through the CustomizedUV inputs (to avoid taxing the pixel-shader).... but I have yet to see any kind of in-depth discussion of how to handle those manual normal calculations.

Is there a universal approach that will work in most cases, or is it a unique case for each type of vertex shader? (depending on the offsets, etc).

Thanks in advance.

avatar image Lyve Nov 10 '14 at 09:32 AM

As i see it, the "real" method would be to create a custom shader (.usf file) to do what I want. But the documentation lacks a lot of things there:

https://docs.unrealengine.com/latest/INT/Programming/Rendering/ShaderDevelopment/index.html

Where do I have to put the .usf files to? Dragging them into the editor results in "unknown file format". Is there a default folder for shaders? Lots of information is missing there at the moment.

avatar image darkgaze Feb 24 '18 at 05:24 PM

After all this time since you asked this, not many things have changed in the engine. It's not just putting the usf files somewhere. You have to create lots of classes and structures and overwrite stuff. You can see some help here, but it's really complicated and needs a lot of graphics experience. https://medium.com/@lordned/unreal-engine-4-rendering-overview-part-1-c47f2da65346

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Custom shaders go into the Engine\Shaders directory. What you will want to look into is Vertex factories. Take a look at my Fluid Surface plugin for an example of implementing a custom vertex factory that has its own USF shader. Make sure to be logged into your github account and that is linked to ur UE4 account before clicking the link (Otherwise u will get a 404 error): https://github.com/Ehamloptiran/UnrealEngine/releases/tag/FluidSurface-4.5

more ▼

answered Nov 10 '14 at 12:38 PM

avatar image

Ehamloptiran
1.5k 50 9 59

avatar image karltheawesome Apr 08 '15 at 10:57 AM

Hi Ehamloptiran, I tried clicking the link you provided while logged in and it still didn't work. Is this code still available? I would be really grateful if I could have a look at it.

avatar image hausfrau87 Oct 17 '17 at 12:37 PM

Nate is hosting the plugin here now: https://github.com/marynate/FluidSurface

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question