# BenjaminSergent

Member

45

133 Neutral

• Rank
Member
1. ## Problems with Normal Mapping

Almost immediately after posting, I found a solution; however, I don't understand why I works.   I changed the line:   normalMap = normalMap * 2 - 1; // Normalize to [-1, 1] To normalMap.xy = normalMap.xy * 2 - 1; // Normalize to [-1, 1] So that the z value would stay in the range [0,1]. Now it looks like this:   If someone knows why that change worked and if it while cause problems later, I would be grateful for the insight.
2. ## Problems with Normal Mapping

Thank you for the replies.   Inverting the g channel first was definitely an issue. It led me to realising my light positions z-values were also too small, so I increased those and adjusted the falloff.   Now I have something much closer to my goal, but there is one more issue. Now I have a problem where only normals that are facing almost directly ahead seem to get lit:     I tried encircling one of the spots that isn't lighting, and it didn't change:     Then I tried moving the z- value of the light around and got a confusing result. If the z-value is very small (the background is effectively at z = 0), then some of the spots that were dark becomes lit to the up and right of the light while the normals facing the screen become darker in that area.     I'd be grateful for any ideas or suggestions.
3. ## Problems with Normal Mapping

Hello,   I'm trying to implement lighting with normal maps in my 2D prototype. I'm stuck on a strange issue where the lighting fades out below my lights. It looks like the dot product between the light direction and the normal must be negative below the light, but I can't get a grasp on why that's happening.   Here is an image of the problem:   No matter where I place the light(s), the area below each light stays dark. This is the code for my frag shader. I've simplified it to try and narrow the problem down: #version 130 in vec2 texCoords; in vec4 color; uniform float numPointLights; uniform sampler2D texture; uniform sampler2D textureN; uniform vec4 ambient; uniform vec4 pointLightInfo[100]; uniform vec2 resolution; void main() { vec4 diffuseColor = texture2D(texture, texCoords) * color; vec3 normalMap = texture2D(textureN, texCoords).rgb; normalMap.g = -normalMap.g; // Our normal map program produces an inverted y axis. normalMap = normalMap * 2 - 1; // Normalize to [-1, 1] vec2 screenPos = gl_FragCoord.xy; screenPos.x /= resolution.x; screenPos.y /= resolution.y; screenPos = screenPos * 2 - 1; // Convert to NDC vec3 finalColor = (ambient.rgb * ambient.a) * diffuseColor.rgb; for(int index = 0; index < numPointLights; index++) { vec4 lightScreenPos = pointLightInfo[2*index]; // Pre-transformed to NDC vec3 lightVector = vec3(lightScreenPos.xy - screenPos.xy, lightScreenPos.z); lightVector.x *= resolution.x / resolution.y; float lightDist = length(lightVector); vec3 normal = normalize(normalMap); vec3 lightDir = lightVector / lightDist; vec4 lightColor = pointLightInfo[2*index+1]; float normalIntensity = max(dot(normal, lightDir), 0.0); vec3 diffuse = (lightColor.rgb * lightColor.a) * normalIntensity; vec3 falloff = vec3(0.009,0.09,0.5); float attenuation = 1.0 / ( falloff.x + (falloff.y*lightDist) + (falloff.z*lightDist*lightDist) ); vec3 intensity = diffuse * attenuation; finalColor += diffuseColor.rgb * intensity; } gl_FragColor = vec4(finalColor, diffuseColor.a); } In case it's relevant, here is the level's normal map: I'm at a bit of a loss for how to proceed. I'm hoping I made a silly error that will be quickly obvious to someone. Thanks in advance for any help.
4. ## Direction Vector not working correctly

I think I understand your problem. Try normalizing the direction vector and multiplying it by the desired speed. [source lang="csharp"]Vector2 direction = target - position; direction.normalize( ); missleVelocity = missle_speed * direction[/source]
5. ## Can someone PLEASE test my game?

Edit: Opps, forgot to check the date.
6. ## Generating Large Maps Using Libnoise (Limits?)

I'm looking at the sample code's file "complexplanet.cpp". Here's some code around line 128 [source lang="cpp"] // Southernmost coordinate of elevation grid. const double SOUTH_COORD = -90; // Northernmost coordinate of elevation grid. const double NORTH_COORD = 90; // Westernmost coordinate of elevation grid. const double WEST_COORD = -180; // Easternmost coordinate of elevation grid. const double EAST_COORD = 180; // Width of elevation grid, in points. const int GRID_WIDTH = 4096; // Height of elevation grid, in points. const int GRID_HEIGHT = 2048;[/source] Then around line 1843 [source lang="cpp"] planet.SetBounds (SOUTH_COORD, NORTH_COORD, WEST_COORD, EAST_COORD); planet.SetDestSize (GRID_WIDTH, GRID_HEIGHT);[/source] Here is the 4096 by 2048 height map the site uses for the terrain sample pictures: http://libnoise.sour...ages/planet.jpg So it's only about twice as large as what you found as your maximum, the sample just looks like it needs a much larger map because of the way Terragen renders it. Still, it seems you don't have as much memory as they expect people running the sample to have. Your main options are: 1. Find a way to make due with fewer points. 2. Get more memory. Note, this option will make the minumum system requirements for your game higher. 3. Make multiple smaller height maps and save them to disk, probably after compressing. Then, make your program try to anticipate which ones will be needed soon so it can decompress and load them before they need to be show.
7. ## BenjaminSergent

I have a website now: http://www.beyondbits.net/
8. ## Problem with Visual c++

Does this only happen in a certain project or does it happen with all new projects (like simple "hello world" programs) as well? Edit: Either way, check Tools->Options->Projects->VC++ Directories to see if everything is in order there. Having your directories set incorrectly can do this.

10. ## XNA - Trapping the Mouse in Windowed Mode

Perfect, that does exactally what I want. For anyone who's curious: //<Mouse handler class> [DllImport("user32.dll")] static extern bool ClipCursor(ref System.Drawing.Rectangle lpRect); //<In the relevant method> Mouse.SetPosition( gameWindow.ClientBounds.Width/2, gameWindow.ClientBounds.Height/2); System.Drawing.Rectangle window = new System.Drawing.Rectangle( gameWindow.ClientBounds.Left, gameWindow.ClientBounds.Top, gameWindow.ClientBounds.Right, gameWindow.ClientBounds.Bottom ); ClipCursor( ref window ); Obviously, this code only runs when the player is using the mouse for the camera. The mouse is unclipped with no position reseting in every other input state. Thanks for the help.
11. ## XNA - Trapping the Mouse in Windowed Mode

To imagine the camera controls, think of Minecraft, Skyrim or Counter-Strike. Those games all trap the mouse because they would be unplayable in windowed mode otherwise; in fact, such games can be unplayable full screen with dual monitors if they don't trap the mouse. The player would still be able to quickly switch out by tapping TAB, Alt-TAB or ESC (opening the menu, removing focus from the game window or pausing the game). blackbook: Unless I'm doing this wrong, changing the window handle doesn't seem to trap the mouse in that window.
12. ## XNA - Trapping the Mouse in Windowed Mode

I'm using XNA to make a game in which mouse movement controls the rotation of the camera. When running in windowed mode, I wanted to ensure that the cursor doesn't leave the screen if the game's not paused. I tried using Mouse.SetPosition, but the mouse still leaves the screen when moved quickly. This semi-frequently results in clicking off the screen, losing focus at undesirable times. What can I do to prevent this?
13. ## Controversial Policy Choices in Games

Thanks for your thoughts. The game is somewhat mature in tone; I don't think it would stick out as an unnecessary add-on. Prototypically putting in a social policy system and ensuring that other parts of the game don't rely on it until I've experimented is a good idea. The question of whether players who don't like it can ignore it somehow didn't occur to me. I think I might allow the player to abstain for making a stance and let the relevant citizens make personal decisions when the issues arise. Thanks again.
14. ## Controversial Policy Choices in Games

In games where you are the leader of an independent state (a civilization, city state, ect), do you think controversial policy issues should be avoided when possible? I'm asking because I was thinking about population control methods in the game I'm making and thought about the possibility of choosing to ban or promote birth control as a way the player could control growth. There are a number of other potential policy choices like this which would affect gameplay such as capital punishment policies and treatment of POWs; further, I'm already giving individual citizens enough personality to reasonably cause them to like or dislike your policies ( resistance to change, conscientiousness, ect ). The game's main focus is managing the expansion of a small young civilization, but not necessarily politics. That said, do you think those choices should be included in the game or would including such issues from the real world distract too much from the core content?