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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Vertex color ignored for FCanvasTriangleItem with material

I'm drawing a triangle onto an FCanvas and the VertexColor node is coming through as white in my material. Looking through the code to try to track down why, I see that in FCanvasTriangleItem::Draw, if the material is non-null, the code path ends up calling FTriangleRenderer::DrawTriangle with a default argument for InVertexColor. The vertex colors specified on the FCanvasUVTri are not used at all. If there is no material, everything works as expected.

Is this a bug? If it's intended, is there some other process I should be using instead of this? I'm attempting to draw some primitives from an ICustomSlateElement and need to pass through vertex color to the material for each triangle.

Product Version: UE 4.8
Tags:
more ▼

asked Jul 13 '15 at 11:56 PM in Bug Reports

avatar image

kamrann
2.1k 83 34 120

avatar image Doug E ♦♦ STAFF Jul 14 '15 at 04:10 PM

Hey kamrann-

Could you post the code you're using to make your draw calls? I would like to try reproducing this on my machine however I'm not sure I can follow your steps from the description. Looking at the code directly will help me setup a test case for myself.

Cheers

Doug Wilson

avatar image kamrann Jul 14 '15 at 05:26 PM

Hi Doug. There's no need to recreate the custom slate context in which I'm doing this, this behaviour can be observed anywhere you try to draw a triangle onto a canvas with a material. In fact I've just experimented and found it's super easy to reproduce.

Create a HUD blueprint and override the drawing as below. alt text

The material you hook up should just be an unlit material which plugs a VertexColor node directly into the emissive. Enable your HUD class in your game mode and run. No matter what color you set in the DrawMaterialTriangle node, the triangle will be white.

The cause is:

  1. FCanvasTriangleItem::Draw, when MaterialRenderProxy is not null, calls FCanvasTriangleRendererItem::AddTriangle (with the correct triangle vertex colors).

  2. FCanvasTriangleRendererItem::Render_RenderThread delegates to FTriangleRenderer::DrawTriangle.

  3. FTriangleRenderer::DrawTriangle takes in the FCanvasUVTri (which contains the vertex color data), but also takes in a parameter InVertexColor, which defaults to white. It then uses this to set the colors of all three vertices and ignores the colors in the FCanvasUVTri.

testhud.png (100.3 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

Hi kamrann -

I have placed a bug report in as UE-18707 and will keep you informed as we investigate a solution. If you feel that you have already implemented a successful solution I do recommend submitting a pull request and reference the UE number listed above.

Thank You

Eric Ketchum

more ▼

answered Jul 15 '15 at 08:48 PM

avatar image

Lovecraft_K ♦♦ STAFF
36.7k 702 260 735

avatar image kamrann Jul 16 '15 at 12:19 PM

Okay, pull request submitted. Cheers.

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

Hey kamrann-

UI only relates to screen space rather than 3D space. The Draw Material triangle node is passing a 2D vector to the material, however the Vertex Color node is expecting a 3D vector so it doesn't know what to do with what is being passed in. Since there is no depth component the value passed in is ignored. With the default VertexColor node plugged into the emissive of your material it will appear white. Using a vector 3 node to set the emissive color in the material will change the color of the triangle in game.

Cheers

Doug Wilson

more ▼

answered Jul 15 '15 at 02:43 PM

avatar image kamrann Jul 15 '15 at 06:09 PM

Sorry I don't follow. The VertexColor node exposes the color value interpolated between colors attached to each vertex. This interpolation is valid regardless of whether the primitive was specified in 3D or screen space. It works just the same was as the UV interpolation, which is working correctly.

The DrawMaterialTriangle node has a color pin for each vertex, the only reason to have these pins is to pass them through to the material via the VertexColor node. Currently they are ignored in the code I referenced, and as such are serving no purpose.

Just to be sure, I just made the obvious fix to the code in my local github clone and it now produces the expected behaviour. I could submit it as a pull request but it seems unnecessary since the change takes 1 minute to make.

(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