{{tag>graphic skin texture environmentroom}}
[[:start|Start Page]] >> [[:gamedev|Game Development with the Drag[en]gine]] >> [[gamedev:skinproperties|Skin Texture Properties]] >> [[gamedev:texturepropertylist|Texture Property Database]] >> **environmentroom**
====== Skin Texture Property: environmentroom ======
Defines an environment room to simulate a 3 dimensional on a flat surface.
|Excepted Data Source|3 component image|
|Data Range|0 or greater|
|Default Value|(not set)|
|Affected Modules|Graphic|
|Linked Properties|[[environmentroom_size|environmentroom.size]]|
====== Description ======
The **environmentroom** texture property defines an environment room to use to produce the illusion of a 3 dimensional room behind a flat wall. This is typically used to create a more realistic illusion of a room behind a window in contrary to flat window textures. Environment rooms are environment map type cube or equirectangular texture containing a prerendered illusion of a room.
{{ :gamedev:textureproperties:envroom_params.png |Calculation using blender scripts}}
Math behind the rooms
The environment room is oriented with the x axis along the texture u direction, the y axis along the negative texture v direction and the z axis along the negative normal direction. The room extends along the x and y axis map to the texture coordinate range from 0 to 1 in the respective room axis.
The size of the room is defined with the [[environmentroom_size|environmentroom.size]] texture property. The x component is calculated as the ratio between the height and the width. The y component is the ratio between the depth and the width. This gives the following formula to calculate the [[environmentroom_size|environmentroom.size]] value for a room of the given size:
* size.x = height / width
* size.y = depth / width
The position of the room is located at the (0.5,0.5) texture coordinates.
The texture coordinates on the flat surface maps to the invisible negative z axis face of the room. For texture coordinates outside the 0 to 1 range a room is simulated for each integer range. Hence texture coordinates from 0 to 1 produce a room as does the range from 1 to 2 and so forth. This way multiple rooms next to each other can be created without extra work. The location of the texture coordinates can be either calculated manually or automatically with the blender scripts. In all cases the ratio of the window texture coordinates has to match the ratio as specified by the [[environmentroom_size|environmentroom.size]] texture property. The formula for calculating the texture coordinates is like this:
* tc.u = position.x / width
* tc.v = position.y / height
Position is on the room wall where the window is located. This calculation applies if the position is measured from the bottom left room position
{{ :gamedev:textureproperties:envroom_uvproject.png |Calculation using blender scripts}}
Calculation using blender scripts
Using the blender scripts the texture coordinates can be easily calculated automatically. For this you can use again the size of the room to calculate the parameters needed. Use the "Project UV" button on the toolbar to start a projection unwrapping. Using the following parameters the result matches the room you desire:
* scaling.x = 1 / width
* scaling.y = 1 / height
* offset.x = 0
* offset.y = 0.5
If required the offset can be adjusted to shift the location of the room behind the windows.
The environment room is used if this texture property is defined. Otherwise normal rendering is used.
Environment room maps can exist in different formats ranging from Cube Maps all the way to 2D Atlas reduced formats. All these are defined in the Drag[en]gine using an image. This works since images can have a depth or layers (z coordinates). To define a proper Cube Map for use with this texture property the image has to have a depth of 6 with each layer specifying a single face of the Cube Map. The ordering of the faces is the following:
* Layer 0 (z=0): Positive X Axis
* Layer 1 (z=1): Negative X axis
* Layer 2 (z=2): Positive Y Axis
* Layer 3 (z=3): Negative Y Axis
* Layer 4 (z=4): Positive Z Axis
* Layer 5 (z=5): Negative Z Axis
Each layer has to be oriented along the other two positive axes. Hence the positive x axis layer has to be oriented with the image x and y axis along the cube map y and z axis. The negative z axis image is not used thus a 5 layer image is accepted as cube map too.
The source is typically a floating point image with 3 color components with values 0 or greater.
The default value for this texture property is (not set) which disables environment room rendering.
====== Examples ======
{{ youtube>unWGhT1tfeM?600x450 |Environment Rooms Preview Video}}
{{ youtube>LRca7DMrk1A?600x450 |Environment Rooms in Action}}
\\
Epsylon Specific Videos
{{ youtube>5DytEdfhHoQ?600x450 |Environment Rooms in Action}}
{{ youtube>N_tbeRXN6Kk?600x450 |Create Env-Rooms in Epsylon}}