Page 1 of 2

adding shadows

Unread postPosted: Thu Jun 23, 2011 5:03 pm
by eyein12
hey guys whats the shader for adding shadows to a structure. i would like the concrete beams of my underpass to display a shadow against the wall.

thanks as always!

Re: adding shadows

Unread postPosted: Thu Jun 23, 2011 5:14 pm
by TVRRMAN
eyein12 wrote:hey guys whats the shader for adding shadows to a structure. i would like the concrete beams of my underpass to display a shadow against the wall.

thanks as always!


Eyein12, I depending on the shader being used, I believe its StencilShadow.fx, and you'll want the shadow model named specifically as shadowmodel or something along those whereabouts.I've had good results in 3D Canvas setting up my models as such with that naming sequence.

Hope this helps.

Re: adding shadows

Unread postPosted: Fri Jun 24, 2011 2:11 pm
by GreatNortherner
Hi,

There's also the "outside shadow box" method, which Sly has discussed at UKTS a while ago: Have the shadow object OUTSIDE of the main object, so in other words, the shadow is larger than the main object. Invert the shadow object's faces (inside out) for best effect.

This is a much quicker way of getting a low detailed dynamic shadow to show up.

Here's the full story:
http://forums.uktrainsim.com/viewtopic. ... &sk=t&sd=a

Cheers,
Michael

Re: adding shadows

Unread postPosted: Fri Jun 24, 2011 2:56 pm
by eyein12
michael,

as always thank you for your help, you've re-ignited my interest in this again. will give it a whirl on sunday!
That sounds alot easier.
cheers!

ian

Re: adding shadows

Unread postPosted: Mon Jun 27, 2011 2:01 pm
by eyein12
didnt turn out right. i just created a box around my model and added stencil shadow.fx and conventional naming is right too. but i just added a grey.ace texture to it and didnt work for me. whats the texture need to be if any?

thanks

Re: adding shadows

Unread postPosted: Mon Jun 27, 2011 3:04 pm
by Kali
I don't think it matters, tbh, it's like the extra slots the other fx shaders have, it's just there to provide another texture pass.

Re: adding shadows

Unread postPosted: Mon Jun 27, 2011 5:15 pm
by SMMDigital
Textures really don't matter for the shadow model - for all intents and purposes, you could simply duplicate the finished and painted model parts and make them a bit smaller, and then apply the StencilShadow.fx shader. However, to avoid confusion if I have to go back to work on the original model in the modeling program, I usually paint the shadow models a dark gray or black.

Shadows can be tricky. The parts of a shadow model itself MUST be "complete" - a whole cube, cylinder, or sphere. The more complicated, or the more faces, a shadow model has, the less likely it will work. If your shadow model is open, or is missing a face, or if its a flat two-sided plane, it will artifact, causing your shadows to become distorted, jagged, or throw in weird ways. I guess the whole point to shadow making is the old KISS method.

Another issue that i've found with shadows in 3DCrafter is that you must make sure that if you move your shadow model or repaint it, be sure to re-apply your Shader in the RailSim properties box. I can't tell you how many times i've moved a shadow object in the 3DC, saved the object, exported the IGS file, and then pulled it up in the Asset Editor to find that the shadow shader had disappeared.

Re: adding shadows

Unread postPosted: Mon Jun 27, 2011 7:12 pm
by spec5sx
Here's a quick tutorial for everyone who needs to know how to make stencil shadows for their models. In order to stay brief, I will guide you through the steps of making a simple box shadow for a building.
This applies only to 3dsMax any version.

1. Create a new box shape in 3dsMax. Roughly the same size as your main model.
2. With your new box still selected right-click and select, Convert To -- Editable Poly. ( Special UV Mapping is not important for shadow objects. A standard box comes with a standard box UV Map.)
3. In the Modifier Tab, name your new box according to Railworks naming conventions. (this is a must!)

Image



4. Open the Material Editor.
5. Drag and drop a material copy into an empty sample slot.
6. Rename the material. (You can give it any name you want, but the name MUST begin with "shadow_" to be detected.)
7. Choose StencilShadow.fx from the Shader Name drop down list.
8. Click on the Slot Texture.

Image



9. Still in the Material Editor, (with your shadow model selected in the viewport) click, Assign Material To Selection.
10. Click, Show Standard Map In Viewport, to show/hide your texture.

Image



11. Close the Material Editor and open up Schematic View.
12. In Schematic View, click the Select and link button.
13. Select your shadow model and drag a link from it to your main model.



Image

Check to make sure all the faces of each of your model parts has a texture applied to it. Check that your all of the parts are properly named, and properly centered in the world view.
Then select all of your model parts and perform a Reset Transform and Reset Scale from the Hierarchy Tab.
Then export your model and cross your fingers. *!greengrin!*

This is how I do it in 3dsMax, but others may do it differently.

Hope this helps.

Re: adding shadows

Unread postPosted: Mon Jun 27, 2011 7:16 pm
by Trainguy76
I know in 3dCrafter, you must use a texture that is already used on the model.

Re: adding shadows

Unread postPosted: Mon Jun 27, 2011 8:35 pm
by Bananarama
Great tutorial, John! !!*ok*!!

Re: adding shadows

Unread postPosted: Mon Jun 27, 2011 9:24 pm
by ricksan
You don't need to link the shadow volume to the main object. It/they can be in the base level of the hierarchy. Exception: A shadow volume associated with an animated part must be linked to that part.

Other considerations.

The edge of each triangle comprising a shadow volume must be contiguous with the edge of one and only one other triangle, sharing the vertices at the two ends of that edge. That's a technical way of saying the volume's surfaces must be a continuum throughout: No gaps, discontinuities, duplicate triangles or "dangling" triangles having one or more unattached edges. Any shadow volume that's not a continuum will cause shadow artifacts in the game, those linear things that extend out from your model, sometimes canceling the "true" shadow. If you're seeing these, you can narrow down the location of the offending exposed edge(s) by looking at the model from different angles and tracing the artifact lines back to their origin. I've found that certain actions, such as snapping vertices together without welding them, will create linear triangles that are hidden inside an edge.

You can have as many shadow volumes as you want and they can intersect each other -- as long as each separate one follows the "continuum" rule.

The shadow volume can be as complex as you want, as long as...OK, you got it.

The RW developer docs recommend that each non-co-planar surface be assigned a separate smoothing group. I always do that, because that's what it says to do. However, my understanding is that the shadow-volume algorithm looks only at the XYZ coordinates of the shadow volume's vertices to find the outermost edge of it from the point of view of the light source. So I don't know what the smoothing group, which relates to the vertex normals, has to do with anything. But then, I haven't tried to mess with it.

Re: adding shadows

Unread postPosted: Mon Jun 27, 2011 10:14 pm
by arizonachris
I think this should be a sticky. Yes, nice work, john! !*salute*!

Re: adding shadows

Unread postPosted: Tue Jun 28, 2011 6:15 am
by Hawk
OK! It's stickyed. !*salute*!

Think it should go in the Scenery Design forum or stay here in the General Discussion forum?

Re: adding shadows

Unread postPosted: Tue Jun 28, 2011 6:55 am
by micaelcorleone
Hawk wrote:Think it should go in the Scenery Design forum or stay here in the General Discussion forum?

Thought the same.
I think it's better located in Scenery Design.

Re: adding shadows

Unread postPosted: Tue Jun 28, 2011 7:51 am
by Hawk
I think so too, so I moved it. *!greengrin!*