Friday, January 18, 2019

New product : Env Probe

Hi !

This product is the companion/sibling/compliment of the "Env Box", which is a set of 20 cube maps to make your latex, or any metal object like an armor, shine realistically, as if there was an actual reflection of the world around it.

If you want to go one step further and make your own Second Life environments, and possibly sell them, you need a tool to help you do that. This is the role of the Env Probe that I will explain here.

The purpose of this product is to position your camera in a way that you can take six snapshots of the surroundings and create a seamless cubemap from those pictures. Then you upload those six pictures and set each prim of an empty Env Box (full perms, included). Once the box is loaded with your pictures, it is ready to sell. You may want to write your own scripts to control it, if you are a programmer, before selling it. Or you may want to simply keep it for your own usage, whichever you prefer.

Once this is done, you may or may not want to rez the new Env Box in-world, for example to simulate the reflection of the room around you. When you step out of that room, there is no point in keeping that environment anymore, you might even want to make another one for the next room.

Or you may decide to wear the Env Box you made regardless of where you are. It's entirely your choice.

The Env Probe is a complimentary product to the Env Box, but neither needs the other one to work. They just work better together


There is no demo for this product, but this whole post details it all so you know exactly what to expect.

You can find this product here on the Marketplace and its price is L$240. It contains one HUD, one probe, one example environment (the one we will be demonstrating here), all three are copy/mod/no-trans.

There is also an empty, unscripted Env Box that is full perms and ready to receive your textures and be sold at the price of your choice. The included "EnvBoxPosition" script is used for positioning the box where the probe is, and is copy/no-mod/no-trans. Finally, there is a simple unscripted sphere to help you test your environments.

If you are good, you will quickly recoup your expenses by selling your own environments in no time.


Here is an example of one of the rooms in my house having its own environment made with this product :





What we want to achieve is something like this :





Of course, spheres are all good and well, but we're here for shiny latex, right ?




Yeah, that's what I thought.

I know the reflections are over the top in these pictures, it is on purpose to show you what to expect in the final result, but you can tone the brightness down of course.

The product contains an example Env Box with this very environment.


This post, unlike the others, does not demonstrate the product then details the manual, but rather exposes the procedure step-by-step to take the snapshots and to upload them in SL after a little tweaking. It is meant to be comprehensive so that you don't have to think hard or guess anything every step you take. Just follow the procedure and you'll have your very own environments in no time.

The following procedure assumes that you are making a new environment for a room inside a house, but it works just as well for an outdoors environment. I will use the study room I showed above as an example to illustrate the different steps of the procedure.

Please note that using a RLV is strongly recommended as the included HUD will control your zoom. If you are not a RLV user and do not want to download a viewer supporting RLV capabilities, no problem, you will just have one additional step to take manually.




Before you even begin, there is one thing you need to take care of. You must do this only once, not every time you create a new environment.

You need to download ImageMagick, which is a free software that we will use to flip the pictures horizontally and vertically. Let's get this out of the way now.

To download ImageMagick for Windows, go to this location :

http://www.imagemagick.org/script/download.php#windows

If you are a MacOS user, go there :

http://www.imagemagick.org/script/download.php#macosx

And if you are a Linux user, get it there :

http://www.imagemagick.org/script/download.php#unix


ImageMagick is a well known tool for image manipulation, montage, collage etc. It is very powerful and virus-free (but check with your anti-virus anyway, you can never be too careful). The Windows installation is straightforward and the x64 version with dll included should do just fine, but do read the instructions if you run in any trouble. If you're using Unix, sorry, you're a geek. I don't need to help you, you probably already know more than I do. If you're using MacOS, I uh... don't know. Please don't look at me.

Once it is installed, if you are a Windows user its location should already be in the path. Check it by opening a command prompt (Start menu, type "cmd" then Enter) then type "magick" and press Enter. If you see something that begins with "Usage: magick tool" etc, then your ImageMagick is installed properly.

 
ImageMagick is installed properly.



Now that this is out of the way, you can follow the procedure for every new environment you want to create. Be aware that at some point you will need to upload the pictures you'll take, and that requires to spend L$10 per picture, which means L$60 per environment since there are six pictures per environment.

If you don't want to download and install ImageMagick for any reason, you will need to flip the pictures by hand with Gimp or Photoshop after having taken them. It is easy to do but takes more time since it would have to be manual instead of automatic.



A. Prepare your folder on your hard drive

The first thing to do is to create a folder in a location of your choice. For the sake of the example, let's say you create a folder named "Slenv" at the root of your "C:" hard drive.


You are of course free to put it where you want and to name it what you want.

Once the folder is created, go inside it and create a text file that you will call "flip.bat". The ".bat" is important because it will be a MS-DOS batch file with a very simple set of instructions that will tell ImageMagick to flip the snapshots that you will save in this folder. The name of the file (here, "flip") is not important but the ".bat" extension is.



Answer "Yes" when the system asks you if you really want to change the extension.

Then right-click on this file and select "Edit" to open the text editor.



And now you are going to program. Don't panic ! Just copy the following lines and paste them in the file, then press Ctrl-S to save, and close the editor.

@echo off

mogrify -flop *_F*.jpg
mogrify -flop *_R*.jpg
mogrify -flop *_B*.jpg
mogrify -flop *_L*.jpg

mogrify -flip *_U*.jpg
mogrify -flip *_D*.jpg



The "mogrify" calls are calls to a component of ImageMagick that is in charge of running a command over several files. Here, it takes the "flip" and "flop" parameters to flip two pictures vertically and to flip horizontally four pictures, respectively. Those are the six pictures you are going to take in SL shortly. You might have guessed that the "_F" suffix means "Front", "_R" means "Right", and so on with "Back", "Left", "Up" and "Down". If you hadn't figured that out already, now you know. This also means that you will need to name your snapshots accordingly.

That's it. No more programming.

Of course, if you have already taken this step once, no need to create a new batch file and copy this code in it. Simply copy the "flip.bat" file you've created before to the folder you are using for this new environment.

Now that the file is created, you can go to the next step.



B. Prepare your settings

First of all, you want to make sure that nothing around you moves. No avatars (unless you want them to appear in the pictures), no pets, no moving objects, nothing. The sun must not move either so you can't use a day cycle, it has to be a specific Windlight Setting.

Also make sure that the clouds do not move or you'll see seams in the sky in the resulting cube map. You can use a Windlight setting where the clouds are still (Firestorm has a few) or create your own.

And make sure that you are not inside the room, or in any location that can be seen from inside the room.

Once everything is set, you can go to the next step.



C. Rez the Env Probe

The box contains one Env Probe that looks like a hollow glowing box with a yellow cross in the middle. Rez it somewhere in the room :

 


You can resize it to be the same dimensions as the room, but it is not mandatory. In fact, at this stage of the procedure, the dimensions of the probe do not matter at all, all that matters is where its center is, because that's where your camera will be.

I recommend making it so the center of the probe is roughly at the center of the room (which is why it is a good idea to resize it now, because the cross in the middle of the probe will de facto indicate the center of the room). However, it is a good idea to keep the center around hip level so that the reflections will look normal as seen on a standing avatar. If the ceiling is high (and ceilings in SL are often high), prefer keeping the center of the probe at hip or chest level otherwise the reflections will look like they are seen from above, and the avatars will look taller than they really are.

What you want is the bottom side of the probe to touch the floor, and that each of the four vertical sides to touch each wall (if the room is rectangular, that is). If you are making an outdoors environment, you don't need to bother about resizing the probe, just about positioning it well.




Notice that in this particular room, I pushed the sides of the box to touch the walls on the front and back, but the bookcases instead of the walls on the left and right sides. This is because an avatar cannot walk through the bookcases, making them effectively walls. It doesn't matter though, I could have pushed the sides through the bookcases to touch the walls behind them, the center would have remained roughly at the same spot. I did it this way so you see the "left" and "right" labels on the sides, but where you put the limits is entirely up to you.

The yellow cross in the middle indicates the center of the room :


Please note that although I didn't do it in this example, you can actually rotate the box around its Z axis, in case the room is not aligned with the global grid (or you want the Front side to be turned towards the north direction, for example, as it is turned towards the east here). Just keep in mind that you can rotate it ONLY around the Z axis, because SL does not allow for any camera roll, so rotating around its X or Y axis would not deliver the expected results.

In other words, the "Bottom" side must always be horizontal and below the yellow cross, and the "Top" side must always be horizontal and above the cross. Don't give the box any pitch or roll, only yaw.

Once the probe is positioned and resized the way you want, you can go to the next step.



D. Wear the HUD

The product also contains a HUD which is in charge of controlling your camera. It is very simple to use, you basically always click on the same button, the one labeled "Next".

There should not be any red button on the HUD, otherwise that means that you have rezzed more than one probe, or no probe at all. The HUD needs exactly one probe rezzed in-world in order to work. If you have two probes or more, derez all of them except one, then click on the "Scan Probes" button to set things straight.

HUD with no probe detected


HUD with exactly one probe detected


Now that the buttons are all green or dark yellow, you can go to the next step.



E. Position your camera

Or rather, let your HUD do it for you.

Click on the "Next" button once, and your camera should be moved inside the center of the probe and oriented to look straight through its "Front" side (notice that the probe itself becomes invisible so it does not appear on the pictures). If you are a RLV user, your zoom should automatically change to 90° and you can already go to the next step.

Otherwise you have to change the zoom yourself. Here is how to do it.

Open the Debug Settings window by clicking on "Debug Settings" in the "Advanced" menu on your top menu bar. If you don't see an "Advanced" menu there, press Ctrl-Alt-D to show it :


In the window that appears, type "CameraAngle" (without a space between "Camera" and "Angle") :


This means that your camera currently has a vertical Field Of View of 1.047 radian (that's 60°). Replace "1.047" with "1.5708" (that's exactly 90°) and hit Enter :


It will probably be rounded to 1.571 upon validation but don't mind that, it won't make a difference.

Voila, your Field Of View is now set to 90° and you are ready to take the first snapshot. Go to the next step.

This is what looking through the front side looks like, with 90° FOV.



F. Take a snapshot

Press Ctrl-Shift-S to make the Snapshot window appear. Make sure that the HUDs are not showing, and neither is the Interface.


The snapshot will need to be square so set the dimensions to 512x512, like this (remember to uncheck "Constrain proportions") :


The snapshot preview should now look like this :


Now click on the small arrow to the right of the "Save" button, and choose "Save As..." :


Select the folder you have created in the window that opens and go in it by double-clicking on it :


Then enter the name "Room_F" in the edit field at the bottom of the window :


Press Enter and that's it, your first snapshot is taken. It should be square and in JPG format. Make sure that it didn't save in PNG format because otherwise the batch file won't modify it (unless you want to change all the "jpg" parts in the file into "png") and the textures will take longer to upload.

The resulting file will be named "Room_F_001.jpg" (the SL viewer always renames its snapshots with increasing 3-digit numbers, starting from 001, don't mind that) and look like this :


A square, 512x512 JPG texture taken from a certain spot in the room with a Field of View of 90°... See where this is going ? You are going to do this five more times to fill a full cube.



G. Repeat steps E and F

What you just did in steps E and F (moving your camera then taking the snapshot), you need to do it five more times, once for every side including up and down.

So repeat them by clicking on "Next", refreshing your snapshot preview with Ctrl-Shift-S and saving your snapshot (no need to set the dimensions again, your viewer should have kept your parameters already).

But the name of the file will change depending on the direction you are looking :

- For Right, name it "Room_R".
- For Back, name it "Room_B".
- For Left, name it "Room_L".
- For Up, name it "Room_U".
- For Down, name it "Room_D".

Once the five repetitions are done, go to the next step.

The order of the sides the camera looks through is always Front - Right - Back - Left - Up - Down. Clicking "Next" goes from one side to the next, "Prev" goes back one step. You can also click on any of the direction yourself to orient your camera towards that direction if you missed a shot.

At the end of the repetitions, your folder should look like this :


And your images should look like this (I'm displaying them in the order they were taken) :

Room_F

Room_R

Room_B

Room_L

Room_U

Room_D


If you messed up and took the same shot several times (like I did when writing this post), maybe there will be a file named "002" or even higher, so now might be a good time to review your pictures and see which ones are to be kept. You should end up with 6 pictures in any case, one for each side.

You can rename the files if you want, for example to remove the "001" part, but make sure their names end with a "_" followed by the letter they already had ("F", "R" etc), otherwise the batch file won't modify them. It doesn't matter if there is a number after the "_x" part and what this number is, the batch file doesn't care about it so you can leave it there.



H. Reset your camera

You can now click on the cross to release your camera. If you are a RLV user, your zoom will be set back to normal, otherwise press Ctrl-9 to set it back to normal manually.



I. Run the batch

It is now time to modify your snapshots. If you did not do this, the reflection would look weird because any writing seen in the environment would still be readable (instead of mirrored like it should be, since we are trying to simulate a reflection here), and the up and down pictures would be oriented badly and would not match the rest.

Here is how the pictures we just took would look on a reflecting surface, if we didn't flip them :

 


As you can see, the bottom of the green couch does not match the rest of its body, the brown chairs are inverted (the dark one should be on the left, since it is on the right in-world), the staircase is inverted too (it should go to the left, since it goes to the right in-world), etc.

Nothing matches, so we need to do something about it. This is where the "flip.bat" batch file comes into play.


Simply double-click on the "flip.bat" file that you created or copied earlier :


It will briefly open an MS-DOS window and if everything goes well, you should not see anything appear in it before it closes. If you see anything written there, it is probably an error and something went wrong with the names of your files.

What you just did was flip four pictures horizontally and two pictures vertically. Attention, if you run the file again, it will flip the pictures again and you'll have them back to how they were when you took them. And you'll have to run the batch once more.

The pictures are now ready to be uploaded in SL, go to the next step.



J. Upload the pictures to SL

In your viewer, open the "Upload" menu by clicking on the "Build" menu then on "Upload". Once there, click on "Bulk (L$10 per file)...".


It will open an explorer window, select the folder you are working with, where the six pictures are located. Select all six (not the batch file, obviously) :


Like I pointed out above, be aware that you will spend L$10 per picture, which means creating an environment costs you L$60. Make sure you have the money for that and that you can afford to spend it.



K. Apply to an Env Box

You will now apply the textures you have uploaded (and paid for) to the empty Env Box contained in the product. That one is unscripted but the sibling product, the actual "Env Box", contains scripted boxes. It doesn't matter which one you use for this step, but it will matter for the steps below.

Rez an Env Box (sample or actual, or even one that you made from scratch if you want) and edit it (right-click, "Edit"). It is probably invisible so you need to press Ctrl-Alt-T to see it. If you chose to rez the sample Env Box, then you will see it in red immediately. If you chose to use one of the scripted Env Boxes and you can't see it, then you will want to bring its menu up (say "/456 *" on the chat), go to "Options..." and click on "Visible" to make it visible.


Now tick "Edit Linked" to be able to modify one prim at a time.

Then click on one of the prims, any of them except the root prim which is a small sphere in the middle. Any of the hollow rectangles will do. Let's say you click on the "Front" one.


Check its name in the General tab of the Edit window :

It should show "Front", "Back", "Left", "Right", "Up" or "Down".

Switch to the "Features" tab on the Edit window :


Then drag and drop the appropriate texture onto the right texture square next to the "Light" checkbox :


Alternatively,  you can click on that square and choose the appropriate texture in the window that appears, that works too.

The appropriate texture is :

- Front : Room_F
- Right : Room_R
- Back : Room_B
- Left : Room_L
- Up : Room_U
- Down : Room_D

In the retail Env Boxes, "Up" is named "Sky" and "Down" is named "Ground", but the meanings are the same. The "EnvBox" script just needs those prims to be named "Sky" and "Ground" instead of "Up" and "Down".

That's it, you have created your environment ! If you want to create another one, repeat steps A to K (with E and F being repeated six times), you can choose another name for your pictures instead of "Room" if you want.




L. Position the Env Box

This step is optional and relevant only if you want to use the environment for this room in particular. If you want to wear the Env Box and/or sell it (or give it away) instead, you can skip this step.

If you want your new environment box to be static, i.e. not be worn but rather stay where it is in-world, then you must first drop the script inside it. Edit it, then go to the Content tab, and drag and drop the "EnvBoxPosition" script in it. Wait a little and it will be ready.

Then you click on the "Position" button on the HUD. This has three effects :

- It tells the Env Box to position itself where the probe is, taking its angle and dimensions.
- It hides the Env Box.
- It sets the radius of each projection according to the size.
- It sets the brightness to 50%.
- It removes the EnvBoxPosition script from the box so your box is once again unscripted.

This picture shows you what it does (I made the probe 50% transparent and turned the box visible so you can see it take the same dimensions and position) :




M. Clean after yourself

When you're done, you should derez the probe either by deleting it manually or by clicking on "Derez Probe" on the HUD. Otherwise if you rez a probe later to make another environment, the HUD will complain that it detects more than one probe.


If you've read this far and made your own environment, congratulations ! Let me offer you a little shiny latex dance as a reward :)



Have fun creating and selling your own environments !

Marine