XNA Tutorials, Samples and Thoughts
Welcome!
I just moved my blog from its previous location to this one. And because no change comes alone, I’ve decided to set a theme for my site:
12 month, 12 samples
What this means is that my goal is to release at least one sample or tutorial each month. And if time and inspiration allows it, there will be more than one. As a beginning, I’ve just added a new sample, for February: Drawing Wireframes without Z-Fighting. This, together with my last sample, in January (Pie2D Sample) hopefully sets me on the right track.
If you have any requests for tutorials or samples, please let me know, and I’ll try to make them.
| Print article | This entry was posted by Catalin Zima on February 9, 2008 at 2:40 am, and is filed under Uncategorized. Follow any responses to this post through RSS 2.0. You can skip to the end and leave a response. Pinging is currently not allowed. |

about 3 years ago
Congrats for the new site. Looking forward to your next entries.
about 3 years ago
I love the new site, Catalin, especially the option of switching from Green to Red. It looks organized, clean, and modern. Nice choice!
Like everyone else, I am very excited about future samples. You are a great contributor to the XNA and gaming community!
about 3 years ago
You’re doing amazing job Catalin!
Following my personal interest
I would like to remind you not to forget about 2d-oriented samples/tutorials!
about 3 years ago
Thanks for your words.
Don’t worry, Alexander. I have at least two samples planned which will deal with 2D stuff.
Surprisingly, I’ve decided to make my next project a 2D game. So that means I’ll be experimenting with 2D effects and techniques more in the following weeks.
about 3 years ago
Cool! Do you plan a top-down view or a side view? Or maybe isometric? (And I wonder if it’s possible at all to use advanced shader effects in esometric 2d mode!)
about 3 years ago
Top-down only for a while. In fact, it might be applicable in both types of views. I’ll just have to see what comes out.
about 3 years ago
Catalin, I’ve got one 2d top-down view related topic I can’t find any interesting examples of. Let’s say we’ve got a terrain sprite with a height map. We’ve got a character sprite. The problem is to draw a character’s shadow over terrain. Let’s review the basic case: we draw a shadow of character using the same texture just with color rgb = 0 and alpha *= 0.5, with some offset of course, so we’ll have nice semi-transparent shadow.
The point is how to add a “distortion” to the shadow sprite according to the terrain height map? This would add some pretty nice effect of feeling of terrain relief. Do you have any thoughts on how can this effect be done?
The next step is harder. We fill height map for the whole scene, so it will have normals both for terrain and character. The next thing that adds complexity is that character sprite can be rotated. And the final thing is that the shadow sprite offset depends on the vector light->character, and so all these things must be taken in count in the pixel shader that will do shadow distortion.
The whole thing become pretty complex and I wonder if it’s solvable at all.
about 3 years ago
that’s an interesting idea.
But I have one question: is the character supposed to be walking on the terrain, or only flying over it? Do you have a picture of the current state of the game?
It would be really helpful to know this, since it may affect the question in various ways. Depending on how your characters look / move in the world, the problem may or may not be solvable. So a screenshot would really help me visualize the problem.
about 3 years ago
Well, all I have is a photoshop mockup in which I emulated the needed result.
Here is it:
http://www.vsbgames.com/tmp/shadowtest1.png
First, notice that it’s strict top-down. And the main thing to look at is the shadow that is being cast on the stone from the character. The point is that stone pixels will be higher in the height map, and so when character’s shadow is drawn on the stone – it is, mm, shifted.
The point is that I seek for universal solution: where the whole height map render target is filled and then the shadows render target is filled, so when the shadow-drawing pixel shader is called, it doesn’t know if the current pixel is over the terrain or stone – all he knows is the shadow texture, light vector and the current pixel height.
about 3 years ago
I understand what you want. I’ll give it some thought later, and I’ll get back to you.
about 3 years ago
Ok, cool! And I’ll post here if I’ll have any new ideas.
about 3 years ago
Ok. I’ve studied you problem, and I believe the best way would be to use an approach similar to Relief Mapping.
Actually, deferred rendering and some techniques used in Relief Mapping seem to be a very good fit for your game / engine. Because you keep your view strictly top-down, you don’t actually need all relief mapping, but reading the article and looking at the code should help you understand the techniques. You’d be interested mainly in the part about adding shadows to relief mapped objects, because this technique is exactly what you could use for your design.
You should check Fabio Policarpo’s webiste for more info on relief mapping. I especially recommend the following: Relief Mapping Paper – here Fabio talks about shadows in relief mapping, at page 4. But you should read the whole paper, in order to understand why relief mapping has so many in common to your design.
about 3 years ago
Thanks, Catalin! This technique is really promising (and the result renders looks pretty exactly what I’m heading to!), I’ll take time to research it! I believe it will need some serious porting to be usable in 2d with multiple light sources.