Direct3D Lightning on DDraw Surfaces

Started by
8 comments, last by Spiff 24 years, 5 months ago
You can't use Direct3D lighting for this.

The Direct3D lighting module lights vertices. These lit vertices are then sent to the rasterizer. It does _not_ generate shadow-map textures that are then applied across triangles.

You could use D3D lighting if you were to implement your tiles as 3D quads, but this would probably require you to revamp your entire system.

Also, Direct3D lighting (or to be more correct, the Lambertian Light Model with Gouraud shading) is unsatisfactory in most situations.

Generating the shadow-maps yourself may be the best option.

Advertisement
Can I use 3D hardware to just lay a surface over a 2D screen and change the level of alpha blending of the one from the front to the back? Blend the background (the tile sets) with the foreground (Dark blue) and change the level of blending?
That is exactly how you should do it. Direct3D can (and in my opinion should) be used to render 2D tiles and sprites by splitting them into 2 triangles, and using screen coordinates (Transformed and Lit triangles).

You can then create "lightmap" textures and blend do either a multipass or multitexture render to create lights, and other visual effects (fog, etc..)

Funny... I just wrote something similar to that as a test. It really looks very good just with vertex lighting (and is pretty impressively fast, too). What surprised me was how easy it was to do.... with the size of most tiles in isometric/tile-based games, texture sizes are sufficiently small that Direct3D's default texture manager seems to cope pretty well. (I'm getting 60+fps in 800x600x16 in my barely optimized test stuff on my PII-450, TNT2. It runs at a solid 35-40 fps on a PII-233, Voodoo 1.)

Mixing sprites into the rendering loop is proving challenging; I'm relying on an isometric view for hidden-object culling, and since I render my entire landscape in one BeginScene/EndScene pairing, its just not practical to repeatedly lock/unlock and paste sprites. I'm currently going down the road of using a quad (2 triangles) with a sprite on it.... any other ideas?

What about some billboarding f/x like fog/smoke and fire/flames?

I'd like to see how it turns out, do you mind sending me the .exe? (since I'm working on a similar thing myself)

============================Daniel Netz, Sentinel Design"I'm not stupid, I'm from Sweden" - Unknown
You guys should check out this URL. Follow the link to the Enhanced2D v1.1
http://members.xoom.com/dxfaq/

It supports vertex lighting, lightmaps, hardware alpha blending, etc.. All done in D3D.

Source is included, so you can see about converting it to VB, if you need to.

Billboarding effects are something I plan to include, but haven't yet. (I've only been working on this project for about 24 hours!!!). I'm also wondering if I can come up with a procedural texture system (a la Unreal's) for some effects.

The project currently displays an 800x600x16bpp screen covered in identical tiles each of which is independently lit on all 4 vertices.... its an ugly test (except of technology concept), but if you really want it my email address is bracket@unforgettable.com - let me know, and I'll send it to you.

I took a look at the Enhanced2D stuff - it looks very good..... but I'll probably end up using stuff I write; not because Tobias's stuff is bad, but because I feel I learn more by going through it and implementing it myself!

Is there anyone know how can I use D3D lights in isometric Diablo like scene?
To add a little more feeling to a tilebased game engine programmed in VB6 and DirectX7 I want to enable lightning of the surfaces to create night/day and shadow fx.

Note: if you don't know VB, just try explaining without code since I don't know much C/C++ (sorry)

============================Daniel Netz, Sentinel Design"I'm not stupid, I'm from Sweden" - Unknown
You could either:
a) Setup the scene in Direct3D and set the camera position to be a relatively typical isometric view. This would let you use Direct3D's lighting and similar. I've never tried this, but I'm pretty sure others have. The upside is that you get perspective correction, and can use 3D models relatively easily (ie. you can render from lots of angles easily, although you have to control your poly count which is what kept me from going down this road - my pet artist isn't into low poly anything!). The downside is that you pretty much need a full-scale 3D engine to do Diablo-like psuedo 3D.

b) Render the game like you would a regular isometric view, calculate the lighting by hand and use DrawPrimitive to render the tiles with either a lightmap or vertex lighting. This is actually a LOT easier than it sounds, and can give really good frame rates. The downside is that you don't get perspective correction, you have to write enough lighting calculation code to figure out how bright each vertex is (actually not that hard, especially if you can include basic lighting information in the map structure rather than calculating at run time). The upside is... its fast, lets you use a lot of Direct3D effects (including lighting that is substantially smoother than that in Diablo 1).

I am in the process of developing an engine (eventually for an RPG, but it could equally well be for an RTS with the frame rates I'm getting!) that uses option b. Email me (my address is bracket@unforgettable.com) if you want me to send you a sample and some basic code examples. (My target machine is a Pentium-II 233 Mhz with a Voodoo 1 (4 Mb) or better, so anything much less than that may look pretty bad/slow.)

[This message has been edited by Bracket (edited November 10, 1999).]

This topic is closed to new replies.

Advertisement