View Full Version : Render-To-Texture + CLIK UILoader
Allar
09-19-2010, 07:15 PM
Is it possible to use render to texture textures with the click ui loader?
It appears that I can use any other texture just fine, but render to texture textures appear to not render at all.
EDIT: Solved. You can use SetExternalTexture to load in a render texture, but you can only use SetExternalTexture if you DO NOT PACK TEXTURES when you import your .swf. At least in the August build.
John J
09-19-2010, 08:59 PM
Yes, I have done it. Well, I don't do it with the UI_Loader but you can place an image in your fla then swap it in Unreal Script in your movie player with SetExternalTexture.
http://udn.epicgames.com/Three/Scaleform.html#Swapping%20Images%20at%20Runtime
Example:
var TextureRenderTarget2D RTT_Example;
function SetupRTT()
{
SetExternalTexture("MyImage",RTT_Example);
}
defaultproperties
{
RTT_Example=TextureRenderTarget2D'MayPackage.MyRTT '
}
MyImage is the instance name of the image placed in the movie and RTT_Example is the RTT in your package. Then just call your function from AS as needed.....
import flash.external.ExternalInterface;
ExternalInterface.call("SetupRTT");
You seem to know your way around AS and UScript, but let me know if you run into trouble. One issue I am having though is the RTT is being rendered at 50% opacity, so if over black it looks really dark. Trying to figure that out now.
Allar
09-19-2010, 09:23 PM
Hmmm, I assumed that because I couldn't use it in the UILoader that even if I were to force it by SetExternalTexture that it wouldn't work either...
Thats what I get for assuming.
Thanks John!
Allar
09-19-2010, 09:57 PM
Hmmm, every call I make to SetExternalTexture to change an exported image in flash, either Texture2D or render texture, causes it to crash... /ponders...
Log error is useless too, just states CRITICAL ERROR
John J
09-19-2010, 10:06 PM
There are a few "moving parts" here so I'm not sure what it might be. I use it just fine in the August build.
I am extending GFxMoviePlayer and using that but I doubt that has anything to do with it. Where are you putting your SetExternalTexture function?
Allar
09-19-2010, 10:14 PM
I'm currently extending GFxMoviePlayer, calling SetExternalTexture in the same fashion you are above. I think its an issue with my flash side of things...
Currently I have a .png thats being exported with a unique identifier. If I pass in a identifier that doesn't exist into SetExternalTexture, nothing happens but it also doesn't crash, so I'm sure its trying to do something with that .png. Am I supposed to be exporting a movie clip instead? I recently tried that but it also did nothing but also didn't crash...
I feel pretty dumb right now xD
John J
09-19-2010, 10:35 PM
Are you passing SetExternalTexture the identifier of the image? I think I incorrectly said "instance name" above even though an image can't have an instance name. :o
I don't think this is it, but here are my declarations in AS:
_global.gfxExtensions = true;
import flash.external.ExternalInterface;
import com.scaleform.udk.utils.UDKUtils;
The only other thing I can think of is to make sure your names match up. Sorry.
Allar
09-19-2010, 10:47 PM
Hmmmm; just ain't working for me... weird...
Well, I guess I'll back to boring static images
Allar
09-19-2010, 10:52 PM
Sorry for yet another double post, but I solved it...
Apparently you cant set external textures when you import your .swf with "Pack Textures" checked. Well thats as shame.
John J
09-19-2010, 10:54 PM
Aha.... Didn't think about that. Glad you got it working.
Allar
09-19-2010, 11:10 PM
http://www.forecourse.com/RealtimeCharPreview.jpg
http://www.forecourse.com/RealtimeWeaponPreview.jpg
Finally, now I can start on some more functionality....
SaMeH
09-20-2010, 03:23 AM
wow nice work i want tutorial :P
John J
09-20-2010, 07:29 AM
That's exactly the sort of thing I was working on Allar. :D
So how did you get your RTT to not render at 50% opacity? Mine is always half opaque no matter what I do.
Allar
09-20-2010, 08:57 AM
Make sure your near plane is as near it can get to the subject and your far plane is as close to the subject as possible as well.
That helps a bit.
And because I couldn't figure that out....
I cheated. I pasted the image in Flash over itself twice, for the weapon (since it has a wider range of motion horizontally texturespace wise) I had to paste it 3 times.
Inefficient? Sure, but show me a better way.
John J
09-20-2010, 05:43 PM
Hehe... that is pretty inefficient but certainly effective! For a frontend UI you probably wouldn't see the hit but I hate hacky solutions like that is I can help it. I'm working the issue from another angle as well, so I'll share the solution if there is one.
John J
10-02-2010, 11:26 PM
Ok Allar, here you go........
Make the image in the Flash scene a movieclip then apply a colorTransform to it making the alpha a full 255 (white). Apparently when you swap textures with a RTT it does something funky with the alpha in the color transform so you need to essentially reset it.
Here is what I did:
import flash.geom.ColorTransform;
import flash.geom.Transform;
var colorTrans:ColorTransform = new ColorTransform();
var trans:Transform = new Transform(WeaponHolder);
colorTrans.alphaOffset = 255;
trans.colorTransform = colorTrans;
'WeaponHolder' is the name of my movieclip. I'm not sure if import statements need to be there or not, but I did. And then all you need to do is mess with the gamma setting on the RTT in the editor to get the lighting right.
Works great for me.
-John
Allar
10-02-2010, 11:37 PM
Wow, now why would it screw up the alpha on swap? :0
In any case, thanks man!
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.