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"

How to put custom vertex/fragment shader into camera component?

I am trying to use camera component to render to texture. And I need custom vertex and fragment shader in that camera component for effect.

I tried to search but only found document about material shader. I am wondering how to put them into camera.

Edit: I am trying to replace the default fragment shader as I did in Unity Engine with SetReplacementShader(). Instead of color, I want to put instance id/object id into the pixels in Fragment Shader.

Edit2: In following link I see that global fragment shader could be used for material. I am wondering how fragment shader could be applied to camera/Scene Capture 2D component. https://forums.unrealengine.com/development-discussion/rendering/24218-converting-glsl-shader-to-material-nodes

Product Version: UE 4.15
Tags:
more ▼

asked Sep 29 '17 at 04:48 PM in Rendering

avatar image

yangl1
1 1 2 3

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

1 answer: sort voted first

materials are both pixel/fragment and vertex shaders combined, In order for all engine effect to work properly UE4 has centered shader code and materials are extending this code. Extra HLSL code is generate from nodes you placing. You can manipulate vertex shader by inputing "World Position Offset" which will manipulate position of vertices.

Now i don't really understand what you want to do, for me it sounds like you want to apply effect to what render to texture captured, you can aplly that in material that add the texture and based on texture data you can add effects, alternatively you can add post processing to capture camera, but then you can only manipulate pixels. Here is how you do post processing material:

https://docs.unrealengine.com/latest/INT/Engine/Rendering/PostProcessEffects/PostProcessMaterials/

If you mean oyu want to write custom HLSL you need to search how to write usf files:

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

I never dives in to this so not sure what it's limitations are definitly is less limited then materials themselves, but you still most likely be forced to use material to apply you shaders in usf. You can also apply HLSL code in Custom node:

https://docs.unrealengine.com/latest/INT/Engine/Rendering/Materials/ExpressionReference/Custom/

You should use usf as a last resort, the material system guaranties that everything will work right, so i think best option for you is first option to apply effect with material that uses captured texture aspecially that you want to play with vertices too.

more ▼

answered Sep 29 '17 at 07:57 PM

avatar image

Shadowriver
37.2k 936 172 1116

avatar image yangl1 Sep 29 '17 at 09:17 PM

Thank you very much for helping! Actually I am trying to render from camera component to texture with pixels set as the object id, So I know from which object each pixel is rendered from. I know in Unity Engine we can replace the default fragment shader with SetReplacementShader(). I am wondering if we can do the same in Unreal Engine. Not super sure but I guess it's hard to do so in pixel shader.

Thanks!

(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