Download

Possible to draw a material to a render texture?

I would like to draw an arbitrary material onto a render texture. Is that possible?

My game’s pawns are essentially a bunch of textures layered on top of each other. In the game world, I load all of the various textures into a material instance and then put the material instance onto a flat plane. I would like to do something similar, but instead of putting the material onto a plane in the game world, I want to draw the whole material onto a render texture that I then send to a Scaleform movie with SetExternalTexture.

Does anyone know how I can do that?

The closest thing I could figure out was to set up my material, more or less, as its own swf movie. Then I used the GFxMoviePlayer’s RenderTexture. Now I’m going to see if instead of using a render texture inside another movie, maybe I can just use the movie itself inside another movie.

I know how to load a movie into another movie in the Flash player using the Loader class, and I know how to create a new object from a symbol in the library. But this is going to be more complicated because I don’t know how to use Loader to load another movie from inside the game. And I can’t just create a new instance of a symbol in my library because I need each instance to have its own textures instead of sharing textures with all the other instances.

We used frames in the movie and used the frames for each different picture.

Example is: one movie 4 frames 0=sunny pic 1=cloudy pic 2=rain pic 3= snow pic. Then what i did when you connect to a map it checks what its weather is and pulls that frame to display that picture.

Do you know how many movies you will have? and do you know what pics you want in that movie? If so, then list the movies in default properties then all you have to do is pull that movie and what ever pics on what ever frame of the movie you ask it to show.
Define an array for your movies
List all of your movies in default properties like this.

//holds all your movies
var array<SwfMovie> OurMovies;
var GFxObject MapScreenMC; 
var GFxCLIKWidget CurWidget; 
var private int FrameNumber;

event bool WidgetInitialized(name WidgetName, name WidgetPath, GFxObject Widget) 
{ 
    super.WidgetInitialized(WidgetName, WidgetPath, Widget); 
    MapScreenMC = RootMC.GetObject(string(WidgetName)); // 
    `log("PBGFxMPLoadingScreen::WidgetInitialized() MapScreenMC = "$MapScreenMC); // 
    `log("PBGFxMPLoadingScreen::WidgetInitialized:, " @ WidgetName @ " :, " @ WidgetPath @ " :, " @ Widget); 
    if( WidgetName == 'loadss' )//name of button in the flash menu 
    { 
        MapScreenMC.GotoAndStopI(FrameNumber); 
        return TRUE;
    } 
    return FALSE; 
 }


simulated function SetTheFrame(int FrameNum) 
{ 
    FrameNumber = FrameNum;
} 

DefaultProperties 
{
  //path to you movies,  pak folders paths
  OurMovies[0] = SwfMovie'UDKFrontEnd.udk_loading'
  OurMovies[1] =  SwfMovie'UDKFrontEnd.Compound'
  OurMovies[2] =  SwfMovie'UDKFrontEnd.Compound2'
}

That is all we have in our file to pull pictures from frames on which ever movie we choose. Not sure if this what your after but it sounds like it would do what you are after. You will open and close and choose frames on the movie to show from the controller.

Thanks @gamepainters but what I’m trying to do is to make any movie able to load any other movie, and any movie should be able to load any number of images. I started off trying to set up render textures and SetExternalTexture, but I’ve actually accomplished more or less what I need to do with UILoader. I still have the issue with the images being too dark and saturated. Maybe I can figure that out next.

Remember how i showed you how to load or open a movie, use this.

 //Loading Screen 
 exec function StartLoadingScreen(string MapLoadingScreen) 
 { 
      StartTheLoadingScreen(MapLoadingScreen);
      if (WorldInfo.NetMode == NM_Standalone || WorldInfo.NetMode == 
          NM_ListenServer) 
            SetTimer(0.1, true, 'StartMapLoadingScreenTimer');
}

//Loading Screen simulated reliable client function 
 StartTheLoadingScreen(string MapLoadingScreen) 
 { 
     local bool DidItLoad; 
     local int FrameNum; 
     local MobileHUD mobileHUD; 

     mobileHUD = mobileHUD(myHUD); myHUD.bShowHUD = false; 
     mobileHUD.bShowGameHud = false;
     bIsInLoadingScreen = false; 

    if ( LoadingScreen == none ) 
    {
      LoadingScreen = new class'PBGFxMPLoadingScreen';
        FrameNum = ChooseTheLoadingScreen(LoadingScreen, MapLoadingScreen);
    } 

   if ( LoadingScreen != none )
   { 
      LoadingScreen.PlayerOwner = self; 
      LoadingScreen.Init(LocalPlayer(self.Player));
      bIsInLoadingScreen =  true;
      DidItLoad = LoadingScreen.Start(false); 
      //`log("PBPlayerController::StartTheLoadingScreen() DidItLoad = "$DidItLoad);

   if(DidItLoad)
   {
    LoadingScreen.SetTheFrame(FrameNum); 
    //`log("PBPlayerController::StartTheLoadingScreen() FrameNum = "$FrameNum);
   }
 } 
}

Now you can use LoadingScreen. to access which ever movie you have in the array in default properties.
EXAMPLE: LoadingScreen.OurMovies[2]; //Make sense? this will pull movie 2, then choose the frame the picture is on and it will show that picture or texture. You will be able to pull any movie.

Example code:

 simulated function int ChooseTheLoadingScreen(PBGFxMPLoadingScreen LoadingS, string MapLoadingScreen)
 {
     local int i, FrameNum; 
     local string CurrentMapName; 
     local PBGameReplicationInfo GRI; 
      local bool FoundMovie;

      GRI = PBGameReplicationInfo(WorldInfo.GRI); 
       FoundMovie = false;

  if(!GRI.IsVotedInMap()) 
  {
 //after 1st map we need this to get proper loading screen 
 CurrentMapName = WorldInfo.GetMapName(true);

 if((MapLoadingScreen != "") && (MapLoadingScreen != CurrentMapName)) 
 {
    CurrentMapName = MapLoadingScreen;
  }
} 
else
{
      CurrentMapName = GRI.GetVotedOnMap();
       GRI.VotedInMap = false; 
}
 //movies must be the same name as the map so we get proper maps Movie 
 for(i=0;i<LoadingS.default.OurMovies.length;i++) 
 { 
     if(CurrentMapName ~= string(LoadingS.default.OurMovies[i]))
    {  
       FoundMovie = true; 
       LoadingS.SetMovieInfo(LoadingS.default.OurMovies[i]); 
       break;
     } 
 }

if((!FoundMovie) && (CurrentMapName != "PBS-Store"))
{ 
     LoadingS.SetMovieInfo(LoadingS.default.OurMovies[0]); 
 } 

 //get the frame in the movie and return it, to load the proper loadingscreen 
 if(IsItAWareHouseMap(CurrentMapName, GRI) || (CurrentMapName ~= "PBS-Store") ) 
 { 
         FrameNum = 1; 

     if(CurrentMapName ~= "PBS-Store")
     { 
         LoadingS.SetMovieInfo(LoadingS.default.OurMovies[29]);
     }
 } 
else
  { 
      //`log("PBPlayerController::GetTheFrameNum() GRI = "$GRI);
     if(GRI == none) 
       GRI = PBGameReplicationInfo(WorldInfo.GRI);

     FrameNum = GetTheFrameNum(GRI); //we check what weather its on and send that frame number for that weather picture.
  } 
  return FrameNum;
 }

Hope this helps