This week (I only started on Tuesday) was about getting the base of the XNA engine down, and while I'm not quite there yet, the week is not over until Tuesday! But you don't want to hear about that, so let's get right to the end and show the first new component and feature:
GPU animated (on two axis) non-billboard grass with dual pass rendering! Actually, it looks more like a collection of bushels and now I'm curious how such a scene would look with very dense short grass textures and a few high such bushels sticking out here and there. Maybe next video :). The idea is to have a general component that I can drop anywhere, like on top of the terrain or in an underground cave, that accepts a vector of points and one or more textures and creates a grassy patch. In the video I am using 4 textures and demonstrate two coloring schemes: one random but quite tame, trying to spit out more natural colors, and out off its rockers! The later could be used in more alien looking scenes.
Before you ask, the textures are just placeholder. One came from a sample on grass I found on the net, another is random search and the rest are from Skyrim. I needed some good textures to weigh correctly the advantages and disadvantages of different grass techniques and public demos will have original grass textures. A rule of my new committed development style is to stick to what I know best: I'm a coder, not a painter (although I was not a too good but passable non-digital painter). So using this rule for test during development I'll use any picture I can get my hands on from any source as long as it benefits my development process and then let an artist replace it. I'll even use the face of Hitler as a bump map or something if my shader benefits from that! So the look of that grass patch is not even concept art, because concept art generally has something to do with the final look, while in my case I picked randomly textures so I can demo the shaders.
And speaking about the shaders, I'll describe how I came up with this implementation in the tutorial posts, but in retrospective I'll probably should have used billboard grass like everybody does. My grass technique is pretty slow (but I did not optimize it one bit), especially with dual pass. Single pass it is a lot faster, but looks darker and the textures have harder and uglier edges. But with good (and brighter) texture work these problems can be reduced in severity, and since you can switch between single and dual pass on the fly, single pass could be an option for low end machines. And of course, I need to render such densities of grass in patches close to camera. Patches farther away can be rendered with lower density, probably even without animation.
And fog! In the last engine I worked hard on making as close as possible to perfect LOD switching with unlimited view distance and never really considered fog a solution. With my new approach I don't have time for such endeavors, so once I figure out how to do fog with custom shaders, I'll start using light fog to blur everything that is distant.
This technique has the same disadvantage as most: it looks ugly and it is obvious where the polygons are when you look straight down. Billboarding also has this disadvantage, though the visual artifacts are quite different. Especially if you spin the camera around with billboarding while looking right down. You can do this test in 2 minutes in Unity. Such a weird trip. So if both techniques have different but jarring quirks when it comes to looking straight down, in the future I'll add a switch to the grass class to generate billboards if the user/engine desires so. Adding this will be easy and billboard perform a lot better: you need half as many polygons and you can only animate in on dimension.
But I won't add it now. In took me two days of fooling around to get this grass class and shaders done and it is time to move on to a new element of the engine. Let's see what the base engine knows by now and thus things I am starting to master using XNA:
- Device creation under specific parameters.
- Device setting management and on the fly changing.
- Raster and blend state changes.
- Shader loading and using for rendering, with a few basic shaders written.
- Created new grass component with GPU accelerated animation in two dimensions and dual pass rending capable of using any number of grass textures and specific coloring per grass "blade".
- Integrated Dhpoware basic debugging grid component. Probably won't be used in the future a lot, but until I have terrain it is good to see things rooted on a surface.
- Integrated Dhpoware first person camera with acceleration, mouse smoothing, crunch, jump, run and weapon position support. I need to add collision detection to it and it will be pretty much feature full.
Until Tuesday I hope to get also mesh loading done and rendering with one pixel light, so I can see all the meshes I have in game, but I'll make sure not to overwork myself.
PS: I'd love to make the video smaller so it fits nice in the window, but Blogger spazzed out and won't let me.
No comments:
Post a Comment