Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Help, help, my brain's gone numb

This topic is 6011 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

It''s been a long week immersed in DirectX and I think my brain''s trying to escape through my ears, so my appologies for the following: My ongoing project is to create a fairly decent terrain rendering program that uses the brute-force approach to the terrain and then overlays models for detail. With that said... 1) Because we need a lot of texture detail I can''t use a single VB for the terrain. So what I''ve done is split the map up into 2x2 VB''s that can be assigned individual textures. The VB''s get rendered as Triangle strips. This works great, but all that texture swapping gets a little clunky and the view depth is seriously limited. The other problem is that the 2x2 matrix is too big and the terrain looks pretty angular. Now, I can''t sort out the texturing (because the game uses a lot of unique textures per map unit), but I figure I could try and get rid of the angular problem by making each VB 4x4 but covering the same surface area... effectively doubling the terrain geometry while keeping the texture swaps and view depth the same. Can anyone tell me how seriously this will impact performance before I go through the trauma of modifying my map file layouts, my map editor and the game rendering code? 2) Applying lighting to the landscape is seriously getting me down. Perhaps lighting is the wrong word. I want to be able to draw a high-lighted circular area around the main character and the rest of the terrain and objects darker (giving the effect of the character carrying a torch into a dark place). The DX lights look terrible because of the low triangulation of the terrain. I''ve tried using a decal technique, and that sort of works for the terrain (except for when the decal''s vertices straddle a high/low point on the map), but completely misses the point on the detail models. I figure that the only thing really left is using some kind of custom shader, but I''ve got no idea where to even start (having started at the Samples and got lost pretty early on). The maths is really simple (if 2dDistanceFromLight>x, Color=0 else Color=1... basically). 3) For detecting what the mouse is pointing at, I''m running a function that converts the cursor pos to world-space, creates a ray from the camera through the cursor''s world space pos and then checks every polygon in the scene for an intersection with that ray. This works great, but it''s incredibly slow (takes upto a second to figure out what it''s looking at... 0fps is very bad). Is there a better way to do this, or should I just be looking at optimising the existing function? And that''s a lot of cross-purpose questions. Sorry for that. Any help on any of the above would be great.

Share this post

Link to post
Share on other sites
1)There''s actually no need to multiply vertex buffers, you can use a unique vertex buffer (better with an index buffer) with any user defined structures to determine wich texture to load.
In some manner you have to implement some kind of attribute order like D3DXMesh (olso with materials).

2)Here you can implement a struct representing an abstract sphere (with centre and radio), so you can calculate the circunference affected by lighting, then you can choose various ways to do this:
a- To update the texture applied to the vertices in the calculated circunference by adding the same value to the rgb values of the pixel, so it increases its ilumination.
b- To add a directional light from a certain space point, pointing to the abstract sphere centre, and its umbra equal to the calculated circunference.etc.

3)Here you have to learn a little of math so you can optimize the code. Play with formulas, test it and reject it, in order to find a mathematical reduced form of formula to this type of tranformations. Do you know some of Algebra''s linear transformations? If so, use it.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!