PDA

View Full Version : Render to Texture Examples



sxp2high
Jan 12 2012, 13:17
Render to Texture (RTT) Examples
aka Picture in Picture (PiP)


Using and editing the demo missions
- Just extract the rar file to your missions folder "Users\USERNAME\Documents\Take On Helicopters\Missions".
- Open the in-game Editor and load the example mission.
- Open the SQF files with an text editor. I recommend Notepad++ (http://notepad-plus-plus.org/) with C++ Syntax highlighting and a mono space font, like Consolas (http://en.wikipedia.org/wiki/Consolas).


Related links, threads and tutorials
- SQF syntax (http://community.bistudio.com/wiki/sqf)
- camera.sqs (http://community.bistudio.com/wiki/camera.sqs)
- Unit Rec/play + Camera training. (http://forums.bistudio.com/showthread.php?t=129897)
- Spawn a helo with camera (http://forums.bistudio.com/showthread.php?t=128444)



1. Basic usage with camera, changing texture renders on-the-fly and multiple "rendertargets"

http://i1202.photobucket.com/albums/bb367/truBTK/rtt1.jpg

Download Demo Mission (http://arma2.co/files/index.php?dir=Take%20On%20Helicopters/Missions%20-%20Singleplayer/&file=RTT_Example_Basics.United_States_H.rar)

List of Commands that I used in this Demo:
http://community.bistudio.com/wiki/camCreate
http://community.bistudio.com/wiki/camPrepareFov
http://community.bistudio.com/wiki/camPrepareTarget
http://community.bistudio.com/wiki/camCommitPrepared
http://community.bistudio.com/wiki/cameraEffect
http://community.bistudio.com/wiki/camTarget
http://community.bistudio.com/wiki/camSetFov
http://community.bistudio.com/wiki/camSetTarget
http://community.bistudio.com/wiki/setObjectTexture ---> http://community.bistudio.com/wiki/CfgVehicles_Config_Reference#hiddenSelections
http://community.bistudio.com/wiki/execVM
http://community.bistudio.com/wiki/hintC
http://community.bistudio.com/wiki/hint
http://community.bistudio.com/wiki/setPiPEffect






2. Using heli mounted cameras, auto-zoom and user controlled camera changes (Zoom and FLIR)

http://i1202.photobucket.com/albums/bb367/truBTK/rtt_heli.jpg

Download Demo Mission (http://arma2.co/files/index.php?dir=Take%20On%20Helicopters/Missions%20-%20Singleplayer/&file=RTT_Example_Heli.United_States_H.rar)

List of Commands that I used in this Demo:
http://community.bistudio.com/wiki/camCreate
http://community.bistudio.com/wiki/camPrepareFov
http://community.bistudio.com/wiki/camPrepareTarget
http://community.bistudio.com/wiki/camCommitPrepared
http://community.bistudio.com/wiki/cameraEffect
http://community.bistudio.com/wiki/camTarget
http://community.bistudio.com/wiki/camSetFov
http://community.bistudio.com/wiki/camSetTarget
http://community.bistudio.com/wiki/execVM
http://community.bistudio.com/wiki/hintC
http://community.bistudio.com/wiki/hint
http://community.bistudio.com/wiki/setPiPEffect
http://community.bistudio.com/wiki/addAction
http://community.bistudio.com/wiki/waitUntil
http://community.bistudio.com/wiki/action
http://community.bistudio.com/wiki/setActualCollectiveRTD
http://community.bistudio.com/wiki/sleep
http://community.bistudio.com/wiki/this
http://community.bistudio.com/wiki/select
http://community.bistudio.com/wiki/while
http://community.bistudio.com/wiki/isNil
http://community.bistudio.com/wiki/distance
http://community.bistudio.com/wiki/min
http://community.bistudio.com/wiki/max
http://community.bistudio.com/wiki/Math_Commands
http://community.bistudio.com/wiki/boolean
http://community.bistudio.com/wiki/nil
http://community.bistudio.com/wiki/format
http://community.bistudio.com/wiki/setActualCollectiveRTD
http://community.bistudio.com/wiki/action

Thromp
Jan 12 2012, 17:48
Fantastic thing :)
one day i hope to get to play with more ,

Keep up good work and Knowledge sharing it will keep this game alive ;)

[EVO] Dan
Jan 12 2012, 20:10
awesome, some new stuff to help us along with missions

Master85
Jan 12 2012, 20:25
really nice demo mission

but perhaps it's better not to use "rendertarget0" - "rendertarget2" but own names (perhaps with author tags) when creating rendertargets (with cameraEffect)
because those names are used for the mirrors in cars/helis

[EVO] Dan
Jan 12 2012, 20:28
or perhaps use vehiclenametarget or objectnametarget

sxp2high
Jan 12 2012, 21:08
but perhaps it's better not to use "rendertarget0" - "rendertarget2" but own names (perhaps with author tags) when creating rendertargets (with cameraEffect)
because those names are used for the mirrors in cars/helis

Yep, you're totally right. Didn't thought of that. :thumbsup:

James2464
Jan 14 2012, 12:14
awesome!! when can we see FLIR and cockpit stuff??

sxp2high
Jan 14 2012, 13:54
It will be up soon, by tomorrow I think.

It's a lot more regarding heli mounted cameras I'm going to demonstrate. Auto-zoom, manual zoom, switching target, switching to FLIR, etc. Almost everything you'll need to create a camera-based scenario. :)

James2464
Jan 15 2012, 03:14
It will be up soon, by tomorrow I think.

It's a lot more regarding heli mounted cameras I'm going to demonstrate. Auto-zoom, manual zoom, switching target, switching to FLIR, etc. Almost everything you'll need to create a camera-based scenario. :)

wow, are you hired by BIS? Is this for Arma 3? it better be! :D

sxp2high
Jan 25 2012, 21:56
Sorry about the delay, didn't had much time to finish it yet. But I'm almost done. Will post it asap.


Is this for Arma 3?
I think Render To Texture is on the "confirmed features" list for ArmA3. :thumbsup:

Xeno
Feb 1 2012, 19:44
Just a little bit fun based on your script...

The camera follows players so it's basically for MP (others can watch what a randomly selected player is doing, all players are seeing the same player):

http://www10.pic-upload.de/thumb/01.02.12/sdjdzakkat9q.jpg (http://www.pic-upload.de/view-12825361/tohwall.jpg.html)

Xeno

Thromp
Feb 2 2012, 21:05
Hmm ,
this would make good scenario for multiplayer
timetrial mission maybe 6 players , 1 pilot 5 spectators watch the helo and then next person take turn to fly :) , just sit and watch the screen until its your turn ?
its possible with this script ?

Prize = You was there and had fun :)

sxp2high
Feb 14 2012, 09:36
http://i1202.photobucket.com/albums/bb367/truBTK/US_BinLaden_88_551250t.jpg

Good idea, Thomp! It's definitely possible!

Slapstick
Mar 6 2012, 00:53
Has anyone tried these examples with the latest 1.04 release candidate? I was going to try something similar with Java, but I can't even get the first example mission working. The scripts "work", but the three screens remain black (sometimes white). I've tried moving closer or farther away, but all I have achieved is causing the game to CTD...

I'm using a GTX260 with 295.73 drivers.

Slapstick
Mar 8 2012, 00:00
Ok, I was able to solve the problem with the images not rendering by tweaking my video options.

But now I have a a problem that has me stumped... the camera is pointing in (approx) 180 degrees the wrong direction. See this screen shot (http://www.suderman.com/toh/RTT.png).

Note that in the screenshot the camera is projecting images that contain the shadows from the screens themselves. So the camera is working, it is just pointed in the wrong direction. The parts of the demo that change the mode (TI, Color Correction, etc) work just fine, and the bit with the three screens displaying three different modes at once works. But anything that involves moving, zooming or re-aiming the camera doesn't.

I've made no changes to the mission, and just downloaded a new copy to take this screenshot.

Thromp
Mar 8 2012, 17:20
Ok, I was able to solve the problem with the images not rendering by tweaking my video options.

I had same problem and used same fix :( however some still dont work just show blackout with some pixelating blue black ocasionally )
It really is hard to debug now there adding three new shader bollocks in toh.cfg , i am on verge of giving this up until i am on the dole / retired its all a bit of needle and haystack at the moment .

Slapstick
Mar 12 2012, 23:13
I went ahead and ported (most of) the mission to Java and the Java mission works (and doesn't work) in exactly the same manner as the SQF mission. So either something has changed in the game engine or I'm still having settings/driver issues.

Thromp
Mar 13 2012, 22:09
there is some new Renderto texture changes in the latest Beta try them now, could have fixed your problems

Slapstick
Mar 14 2012, 17:08
And indeed it did. The first time I tried the SQF mission I had a CTD with a popup dialog from nVidia saying the graphics card drivers had crashed and been restarted. However, subsequent attempts ran fine and both missions (SQF and Java version) worked as expected. The nVidia updater just notified me that new drivers are available so hopefully all will be good now.

Thromp
Mar 14 2012, 19:21
Nice one
Yeah just got the Nvidia pop up too , hopefully it will fix the alt tab retardness i am having lately too

neokika
Mar 21 2012, 12:45
http://www10.pic-upload.de/thumb/01.02.12/sdjdzakkat9q.jpg (http://www.pic-upload.de/view-12825361/tohwall.jpg.html)

Xeno

Hey,

I'm still wondering how to achieve this? Put a picture in picture scene in a monitor/tv/etc.

Thanks,
_neo_

sxp2high
Mar 21 2012, 14:05
Hi neo,

check out the first example mission, it's all there.

It's pretty easy really. Just create a cam and set the object texture to the rendertarget (cam):


_cam = "camera" camCreate (getPosATL player);
_cam camPrepareFov 0.700;
_cam camPrepareTarget (vehicle player);
_cam camCommitPrepared 0;
_cam cameraEffect ["INTERNAL", "BACK", "rendertarget0"];


_screen setObjectTexture [0, "#(argb,256,256,1)r2t(rendertarget0,1.0)"];

This is for objects only, and only for objects, which have hidden selections defined. (setObjectTexture compatible)


For cockpit displays you have to use BIS_fnc_PIP (http://community.bistudio.com/wiki/BIS_fnc_PIP). (Second example mission)


If you need further assistance, please be more specific, what you are not getting :)

neokika
Mar 21 2012, 19:17
Thanks sxp2high,

Exactly what I meant.

_screen setObjectTexture [0, "#(argb,256,256,1)r2t(rendertarget0,1.0)"];

Mr. Charles
Apr 8 2012, 03:33
Has anyone managed to use this with Bis_fnc_PlayVideo?