Tutorial - Buildings part 2 - More Windows/Translucency

Users of the Amabilis product 3D Canvas, that has now had to change its name to 3D Crafter can find continuing discussions here.

Moderator: Moderators

Locked
User avatar
decapod
Building GWR Highworth Branch 1917-1926
Posts: 3097
Joined: Tue Dec 04, 2001 12:00 am
Location: Carshalton, Surrey
Contact:

Tutorial - Buildings part 2 - More Windows/Translucency

Post by decapod »

It's about time I did another tutorial.
I think I'll continue with the signal box and make this a short one about Translucency, with a bit of an explanation on how it works. This building is going to be very close to the tracks, probably at the end of a platform so it would be nice to have some interior detail.
I'm going to add a few more windows to make the Aylesford box:
http://www.semgonline.com/location/pics ... fdvc-1.jpg

I'll start with my first model (resaved as a new 3DC file)

- Right click on the main body of the box and select "Show Only" - This makes the scene less cluttered and easier to work with. I have also applied a plain texture.

- I use the Inset operation with positioning and scaling in the Y and Z directions to add a large window on one side and a smaller one the other side.

- I use the same operation to create the two smaller end windows. However, due to the non-square original face I had to use the equalize (Y Axis) to make the top and bottom edges horizontal, then the same operation to equalize the vertical sides in the X axis. These were then positioned and scaled.

- Each of the new window faces were then extruded by -0.05m



You may notice the door is a bit higher too - to shift it up I right clicked with the face selection tool, then selected
"Selection->Grow" on the menu. This selects the door face and the frame faces around it. You can then use the Bottom Right widget to shift all the faces up together.

If we have translucent windows, we will need an interior.

- For this I take a copy of the shadow base object from the .100 LOD, paste it back into the Main group, Invert it and set the group position to 0,0,0

- I can then shrink it slightly, by holding down the Ctrl key and dragging on the X/Z scaling area of the Bottom Right Widget, until it roughly matches the extruded windows.



Here I have used the paint tool with a 60% translucent material on the window faces to show the result more clearly.
DECAPOD
OOOOO
User avatar
decapod
Building GWR Highworth Branch 1917-1926
Posts: 3097
Joined: Tue Dec 04, 2001 12:00 am
Location: Carshalton, Surrey
Contact:

Re: Tutorial - Buildings part 2 - More Windows/Translucency

Post by decapod »

Here's a handy tip I didn't mention in the first tutorial.

I don't have a detailed drawing for this building, the windows are being sized by eye. Consequently it is a bit more difficult to make accurate textures.

Using the orthographic views in 3DC and zooming in to the left/right/front/back, you can take a screenshots that can then be placed onto the texture files (using your paint tool of choice)



I've used the 4 view selection here, but you can just change the current view to orthographic instead (and back to perspective once you have finished)

I just chop out the parts I need from this image and paste them into the texture file.

These can also be scaled vertically or horizontally and the proportions remain correct. This will let me position and "baked" shadow under the window sill etc.

DECAPOD
OOOOO
User avatar
decapod
Building GWR Highworth Branch 1917-1926
Posts: 3097
Joined: Tue Dec 04, 2001 12:00 am
Location: Carshalton, Surrey
Contact:

Re: Tutorial - Buildings part 2 - More Windows/Translucency

Post by decapod »

It has taken me a while to get to the next step.
Creating reasonable looking textures takes longer than making the model in the first place.

Anyway - I have now created a TGA file from the initial texture shown above.
Currently I have masked off the solid area (alpha = 1) and left the windows transparent (alpha = 0).

The texture was then applied in parts using the texture area selection, the Alt/Face Selection (select faces pointing in the same direction) and the Fill Operation (paint pot button on the left)

Luckily, with this model, I can re-use the texture for the interior faces, applied using the flip horizontal arrow on the material tab.
I'm hoping to use the same material options for the whole model so that the model is drawn efficiently. With luck the interior will be darkened by the shadowing in RS so I may not need another material to darken it.



Right - time to add a bit more detail (window frames, levers and tables etc) and some translucency....
DECAPOD
OOOOO
Schmalspur
Been on the forums for a while
Posts: 237
Joined: Mon Oct 22, 2007 2:06 pm

Re: Tutorial - Buildings part 2 - More Windows/Translucency

Post by Schmalspur »

Nice tutorial Paul, these will be very helpful to a lot of people :)

Regards, Jack
User avatar
Acorncomputer
Very Active Forum Member
Posts: 10699
Joined: Wed Oct 17, 2007 5:37 pm
Location: Horley, Surrey, (in a cupboard under the stairs)

Re: Tutorial - Buildings part 2 - More Windows/Translucency

Post by Acorncomputer »

Absolutely perfect for the set of models I will be working on soon.

Thanks very much.
Geoff Potter
Now working on my Bluebell Railway route for TS2022
RISC OS - Now Open Source
User avatar
decapod
Building GWR Highworth Branch 1917-1926
Posts: 3097
Joined: Tue Dec 04, 2001 12:00 am
Location: Carshalton, Surrey
Contact:

Re: Tutorial - Buildings part 2 - More Windows/Translucency

Post by decapod »

A quick tutorial for window frames.
Again, probably worth adding these for something so close to the line.
Some useful modelling tips in this process that can be applied to other types of objects.

To set a frame into the hole the simplest way I have found is to first select the faces around the edge that make up the hole:



- Copy the faces and paste them back onto the original object.

- With face tool selected, Right click Select->All->Faces
- Extrude Operation (0.05m, 2")
- I have also scaled the object to 0.025m (1") thick and used the flood fill with a white part of the texture.



- Now setting the group position of the frame object to 0,0,0 puts it exactly in the right place.

- The cross frames are made from 2 cubes scaled to the right width and height and a bit narrower than the frame
- I created these as a new group, keeping the centres together. I deleted the faces on the ends of the cross piece to save 8 polys.
- Select one of the bars, then run the Butt Object plugin.
- Select the target as the window frame and centre on X,Y and Z - for an exactly centred frame.

DECAPOD
OOOOO
User avatar
decapod
Building GWR Highworth Branch 1917-1926
Posts: 3097
Joined: Tue Dec 04, 2001 12:00 am
Location: Carshalton, Surrey
Contact:

Re: Tutorial - Buildings part 2 - More Windows/Translucency

Post by decapod »

I've skipped over quite a lot of work here, all fairly basic stuff.
Firstly I have changed the TGA texture file so that the windows are no longer completely transparent.
When you load up the model you may notice some of the walls behind the windows become transparent, this is just 3DC behaviour and will not happen in railsim - more on this later.
I have cut and pasted back into position, the faces that make up the window panes and renamed the objects "window" so I can find them later.



I have also added a few scaled cubes to make up a table, a box and some point levers.
Adding these was made simpler by making the exterior skin invisible (Right Click -> Uncheck Visible)
You will also notice I have moved just about all the objects, apart from the shadow and night parts, into the main group.
Unless there are animations, there is no real need to have multiple groups and they cause models to be less efficient in RailSim.
Using the material manager I made sure all my material fields had default values of the TexDiff Shader.
Again, the fewer different materials you have, the more efficiently the model is drawn in the Sim.

This model is getting quite detailed - just over 1000 polys so far! LOD's will make most of this vanish when you move away in a scene but it should look good close up.


Now to make the windows translucent on export I just right click on each object, set the Alpha Tx material property to "Translucency" and the Rail Sim Field to "BlendATexDiff"



Alpha Tx
========
This field signals to the exporter how to create some of the material parameters.

None or Blank - indicates Solid. The texture alpha channel is ignored, something called "Alpha Testing" is turned off.

Transparency - The texture alpha is checked. If it is mostly transparent, it is treated as completely invisible.

Translucency - This actually turns off the Alpha testing in the same way as the "None" option, however it also turns off Z-Writing or Depth Buffering. This means that objects are drawn behind faces with this material option set.


The Z-Buffer
============
The graphics engine keeps a hidden record of the distance of every pixel on the screen from the camera, the Z or depth buffer.
When an object is drawn on a 3D scene, every pixel is checked against the buffer.
If it is closer, it is drawn. Usually the new object then updates the Z buffer for the pixels.
This way more distant object are hidden by closer ones, regardless of the order in which they are drawn.
This also applies to translucent objects - objects behind will not always be drawn, unless they turn off writing to the Z buffer.

Related Information:
When 2 faces are drawn close together you'll sometimes see artifacts caused by inaccurate depth buffering. The engine can't decide which one should be on top - this is called "Z-Fighting".
The way to fix Z-Fighting is to apply a Z-Bias to the object you want to be on top.
This is possible with the new exporter by adding Zbias=1 to the RailSimX field.

TexDiff and BlendATexDiff
=========================

The BlendA part of the shader just allows you to put translucency on top of more translucency.
In theory you could still use TexDiff with translucent parts, but the result may not look quite right.
DECAPOD
OOOOO
User avatar
decapod
Building GWR Highworth Branch 1917-1926
Posts: 3097
Joined: Tue Dec 04, 2001 12:00 am
Location: Carshalton, Surrey
Contact:

Re: Tutorial - Buildings part 2 - More Windows/Translucency

Post by decapod »

I'm experiencing real problems getting this translucency to work properly for scenery items in the Sim.

The windows work when viewed from one angle, but the background vanishes when you change viewpoint. The flora also shows through the translucency.

Can anyone think of a scenery item in any of the standard rail sim packages that uses translucency?
I've not found one yet.

I have a suspicion it doesn't work and that alpha sorting is non-existent in RS1.
I'm getting more and more frustrated by the poor quality of the programming in this sim.
Bumping animations, no true specular mapping, only volume shadowing which gets truncated, objects that sometimes vanish when the viewpoint moves slightly.
MSTS1 does a much better job in a lot of cases.
DECAPOD
OOOOO
Schmalspur
Been on the forums for a while
Posts: 237
Joined: Mon Oct 22, 2007 2:06 pm

Re: Tutorial - Buildings part 2 - More Windows/Translucency

Post by Schmalspur »

decapod wrote:I'm experiencing real problems getting this translucency to work properly for scenery items in the Sim.

The windows work when viewed from one angle, but the background vanishes when you change viewpoint. The flora also shows through the translucency.

Can anyone think of a scenery item in any of the standard rail sim packages that uses translucency?
I've not found one yet.

I have a suspicion it doesn't work and that alpha sorting is non-existent in RS1.
I'm getting more and more frustrated by the poor quality of the programming in this sim.
Bumping animations, no true specular mapping, only volume shadowing which gets truncated, objects that sometimes vanish when the viewpoint moves slightly.
MSTS1 does a much better job in a lot of cases.
I haven't either, I have stuck with just having windows with no glass or using photos for the windows. I thought maybe it was the 3DC exporter, but if it is RS then this is quite a significant omission.

Regards, Jack
PaulH2
Very Active Forum Member
Posts: 1843
Joined: Wed Dec 19, 2001 12:00 am
Location: Rio Rancho, New Mexico, USA
Contact:

Re: Tutorial - Buildings part 2 - More Windows/Translucency

Post by PaulH2 »

decapod wrote:I have a suspicion it doesn't work and that alpha sorting is non-existent in RS1.
Developer Docs, 4.03, page 5: "There is NO true alpha sorting in the game engine. Therefore it is NOT advisable to use shaders with alpha. If shaders with alpha are used, the polygons using alpha may sort incorrectly in the game engine."

I'm also just using cut out windows as I've had basically the same problems with translucent windows and put it down to the lack of alpha sorting. Certainly makes some things (no smoking signs on carriage windows for example) far harder than it should be!

Paul
Bringing Merseyrail 1980 back to life, slowly...

Image
moranb
Well Established Forum Member
Posts: 860
Joined: Tue Oct 05, 2004 7:41 am

Re: Tutorial - Buildings part 2 - More Windows/Translucency

Post by moranb »

I don't know if it is strictly speaking a scenery item or not, but the static HST loco under misc. does have translucent windows. The blueprint for this item appears to be a normal scenery blueprint when looked at with RS tools. At any rate it does appear that translucency is possible for static items with RS.

BFM
Locked

Return to “3D Crafter”