Home Unreal Engine

material RTT in UDK

Hello,

Is it possible to render a material's output directly to a texture? I've seen plenty of tutorials on the scene capture actor, but implementing something simple like directly rendering to a texture from a shader seems to elude me. I suppose it can be done using a custom node and just writing the HLSL, but I don't see how I could pass a render target from one shader / material to another (which is the end goal, here).

Thoughts?

Replies

  • JamesWild
    Options
    Offline / Send Message
    JamesWild polycounter lvl 8
    For what purpose? For 99% of the uses of this, rendering to a texture is an intermediate step that will cost you memory and performance, and lose you image quality.

    Just take the output of whatever material you want in a texture and pipe it directly into however you plan to use it in the other.

    As you don't mention any lighting involved I'm assuming there is none and it's just emissive.
  • graffy
    Options
    Offline / Send Message
    In my case, the idea would be to take a gradient mask I've created procedurally and apply it as a texture, so that it can be manipulated with UV coordinates. When you say "pipe it directly" into another material, is this a reference to the material function call node?
  • Angry Beaver
    Options
    Offline / Send Message
    Angry Beaver polycounter lvl 7
    why can't you incorporate the gradient mask into the other shader?
  • LoTekK
    Options
    Offline / Send Message
    LoTekK polycounter lvl 17
    UDKFlattenToTexture.PNG

    Assuming you have a really good reason not to just incorporate your gradient masking in the other shader itself, UDK should have the options shown above in the Material Instance interface. Enable the checkboxes above, and once you close the material instance, it should bake out a texture (shares the same name as the mat instance).

    (at least, I'm pretty sure that's not custom to our Unreal build, anyway)
  • JamesWild
    Options
    Offline / Send Message
    JamesWild polycounter lvl 8
    I don't have those options though there's something similar in the mobile area. I believe Unreal might use some kind of "flattening" for lightmass, as it can't exactly run the shaders on the CPU (though it might CPU interpret the node tree I guess)
  • graffy
    Options
    Offline / Send Message
    I don't see the "Texture Flatten Settings" either. Rats.

    Regarding incorporating the gradient into the original texture, of course I can. But I'm creating some rather complex procedural gradients, and I quickly realized how valuable it'd be to render a procedural gradient to a texture of NxN size, and replace the procedural output with an image (at least as far as optimization is concerned). It has it's uses, anyway.

    If I really need it, I can always write some quick GLSL or something to do the job, but I was hoping there was a way to do that in UDK.
  • fearian
    Options
    Offline / Send Message
    fearian greentooth
    This would actually be really useful. Thinking about procedural shaders that add snow or moss... weathering... you could make a texture generation material in UDK similar to the upcoming dDo and run meshes through it, baking out the texture. Very useful for artists who can't write shaders but know UDK. Would be useful to bake down these procedural textures for a low spec game that doesn't want a ton of complicated mats in a scene, too.

    Sorry to bump without a solution, but I thought I'd throw my support behind anyone who wants to make this possible!
  • JamesWild
    Options
    Offline / Send Message
    JamesWild polycounter lvl 8
    That, I believe, is what the existing flatten settings are for under Mobile, possibly also used for Lightmass radiosity bouncing. Flatten down the surface to basic textures that aren't computationally expensive to render/raytrace.

    I have wanted to play around with the idea of a totally GPU based painting program for a LONG time, but always had other stuff to do.
  • ambershee
    Options
    Offline / Send Message
    ambershee polycounter lvl 17
    graffy wrote: »
    Hello,

    Is it possible to render a material's output directly to a texture? I've seen plenty of tutorials on the scene capture actor, but implementing something simple like directly rendering to a texture from a shader seems to elude me. I suppose it can be done using a custom node and just writing the HLSL, but I don't see how I could pass a render target from one shader / material to another (which is the end goal, here).

    Thoughts?

    You can do it with a little bit of UnrealScript, but the implementation is quite slow (but then so are rendertargets anyway). You can create a RenderTarget and draw a Material tile to that through the canvas. You may find it is a frame behind, I'm not sure as I've never tried it.
Sign In or Register to comment.