No announcement yet.

Texture Render Targets Scaleform Issue

  • Filter
  • Time
  • Show
Clear All
new posts

    Texture Render Targets Scaleform Issue

    class ExampleScreen extends Actor placeable
    /** This will be the flash movie that this actor plays. */
    var() noclear SwfMovie ScreenMovie;
    /** This will be the green screen texture onto which the ScreenMovie projects. */
    var ExampleTextureRenderTarget2D ScreenTexture;
    /** The flash player to play the flash movie. */
    var ExampleScreenPlayer ESP; // Extends from GFxMoviePlayer, just has an extra function that overrides Start() to call both super.Start() and Advance(0).
    /** The static mesh actor which will have the flash movie playing on it. */
    var StaticMeshComponent EScreen;
    /** To be able to add the flash movie to the actor, I have to be able to manipulate the material interface. */
    var MaterialInstanceConstant EMIC;
    event PostBeginPlay()
    	ESP = new class'ExampleScreenPlayer';
            // This is a wrapper class to TextureRenderTarget2D to change RT's SizeX and SizeY each to 512 (because they're both "const"), as well as changing the Format enum default to PF_Format=A8R8G8B8 (I'm trying to recreate the "green screen" render targets you see when they're created in the editor.)
    	ScreenTexture = new class'ExampleTextureRenderTarget2D';
            // Adopting the same method in Uscript that Matt Doyle does via kismet and the editor in his videos.
            //   Except using unrealscript instead of "Open GFx Movie" kismet.
    	ESP.RenderTexture = ScreenTexture;
    	ESP.RenderTextureMode = RTM_AlphaComposite;
    	EMIC = new class'MaterialInstanceConstant';
    	EScreen.SetMaterial(0, EMIC);
            // The material is only a texture parameter node that plugs directly into the emissive slot.
            //    The material uses the AlphaComposite opacity setting, just like the video tutorial.
    	EMIC.SetTextureParameterValue('Emissive', ScreenTexture);
    	// Native.
    	// Custom.
    	begin Object Name="Screen" Class="StaticMeshComponent"
    	end Object
    What you end up with is this big ugly white area on the static mesh component in question. Any idea what it is that I'm doing wrong and how I can go about fixing it (if possible)? Or is there some sort of native backend that prevents this from being possible?

    Ideally I would like to avoid having to use kismet to have a flash material playing on my actor. So any help would be welcome and appreciated.

    I unfortunately have never created a render texture on a mesh in the game world without using Kismet. So I don't know what could be wrong. I can try to come up with a solution, but it might take me a while to get to it.


      I haven't tried this, but I'm looking at the way you manage the render target.

      You're subclassing TextureRenderTarget2D in order to override the size, but there's a Create() function that should be called after instancing, and that is where size is set. So, at a guess:

      ScreenTexture = new class'ExampleTextureRenderTarget2D';
      ScreenTexture.Create( 1024, 1024 );
      If your subclass is just using default properties to circumvent the const it probably won't work. Const usually implies that variables can only be updated through a native function.

      Edit: could be wrong, there's a cpp Init() function that may already create it during instantiation. /shrug


        You're creating the Texture Render Target incorrectly.

        You need to use the static functions to create them.

        /** creates and initializes a new TextureRenderTarget2D with the requested settings */
        static native noexport final function TextureRenderTarget2D Create(int InSizeX, int InSizeY, optional EPixelFormat InFormat = PF_A8R8G8B8, optional LinearColor InClearColor, optional bool bOnlyRenderOnce );


          Excellent! Everything works now. Thanks a lot, you guys