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"

Paper2D: Drawing primitives into a render texture

Is it possible to draw primitives (lines, triangles..) into a texture? I'm currently playing with Paper2D. To achieve a certain effect I need to create a "mask" texture by drawing shapes into it. This texture has to be updated every frame and multiplied into the rest of the rendered scene. The result is comparable to the example below. Basically it modifies the rendered scene's brightness, sort of like a post processing effect.

I've done this in Cocos2D previously and now I'm thinking about porting it over to UE4 for better portability and because of the convenient editors. How would I go about this in UE4 and Paper2D?

alt text

Product Version: Not Selected
Tags:
more ▼

asked Sep 13 '14 at 06:53 PM in Rendering

avatar image

Bajee
290 21 33 138

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

1 answer: sort voted first

Hey Bajee -

There are two possible ways to achieve this effect. One way would be to take a post process material which increases the brightness of objects found behind the mesh and assign it to a basic mesh shape like the flashlight's triangle and adjust the 3D scale of that mesh to simulate shape change. There are some limitations to this method as you would have to do some complicated variable alignment to check for blocking objects and then either fun a gradient fade to cut the brightness effect or change the Relative Scale 3D.

The other method would require a significant investment into some Programming and is explored quite nicely on this website here, http://www.redblobgames.com/articles/visibility/

Hopefully this will point you in the right direction, if you have further questions about this method please feel free to comment below -

Eric Ketchum

more ▼

answered Sep 25 '14 at 06:20 PM

avatar image

Lovecraft_K ♦♦ STAFF
36.7k 702 260 736

avatar image Bajee Sep 25 '14 at 07:50 PM

Hi Eric. Thanks for the reply. The second method is exactly what I mean. I implemented a very similar lighting in the Cocos2d engine a while back (using this article from gamedev.net). My problem is not about calculating the shadow geometry, but porting this solution to UE4. Mainly because it's a huge code base and I don't even know where to look first.

The way I did it in Cocos2d was to first let the engine render the unlit scene, like this ugly example: alt text

Then I added a final step, where I rendered all the lights (and shadows) into a render texture. This texture was then multiplied into the framebuffer (with the already rendered scene) to get the final result: alt text

Since I posted this question I learned about the UTextureRenderTarget2D class. I didn't have much time to look into it yet and I found very little information on how to use it. Can I use this class to render some 2D shapes into a texture which I then multiply into the scene as a post processing effect?

In my Cocos2d implementation I simply used some OpenGL draw calls to render the lights and shadows into the render texture. I think we are not supposed to do that in UE4 for portability reasons (right?). What would I use instead? What is a low level drawing API that would allow me to efficiently draw some colored and/or textured triangles?

Thanks!

avatar image Lovecraft_K ♦♦ STAFF Sep 26 '14 at 03:13 PM

Hey Bajee -

Yes I think you are on the right track and know that I think I have a better handle on exactly what you are asking, we actually have a tool that will probably immensely help you out. In the Art tools section of the Engine content you can find a render to texture workflow including imposter sprites which I believe would give you what you want, information can be found here, https://docs.unrealengine.com/latest/INT/Engine/Content/Tools/RenderToTextureTools/3/index.html

Thank You

Eric Ketchum

(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