Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

122 Neutral

About w00

  • Rank
  1. I can't figure out how to change a value in my vertex shader. What i do in opengl is the following: //i bind my shader shader.bind(); // Then trying to set the value in my vertex shader like so: GLuint test = glGetUniformLocation(shader.id(), "Test"); glUniform1f(test, 6.0f); This is the value i want to change in my vertex shader: uniform float Test = 0.66; // Doesn't work //const float Test = 0.66; // Works But my shader doesn't work when i try that. If i comment the OpenGL part out and if use the float as a const instead of a uniform then my shader works fine. But i want to be able to change that value from my OpenGL game. Can someone tell me what i'm doing wrong..?
  2. I'm workking on the basics of my client/server game protocol. I'm currently sending an object from the client to the server. But i'm not sure if the method i'm currently using is right. Here's what i'm doing: My client uses a timer which is set to 50ms. So currently it sends a small object to the server at that rate (50 ms). The object that i'm sending looks like this: class Actions { public bool forward = false; public bool left = false; public bool backward = false; public bool right = false; public bool eulerX = 0f; public bool eulerY = 0f; public bool eulerZ = 0f; } So all it basically sends is wether or not a player is moving forward (or any other direction) and it's current rotation in the world. This is send every 50ms to the server. And the server seems to react well on it. But that's ofcourse because i'm testing it locally. What if the player has a ping of 100...?? That means that when the client sends 1 packet it takes 100ms before it arrives at the server. But in that time the client already sended 2 more packets to the server (once every 50ms remember?). Doesn't this mean that i will get huge problems this way when the client has a high ping? So basically my question is, is it okay to send a packet every 50 ms to the server? And what happends when a player has a high ping? How do i handle that? Just a side note. I just want to discuss about sending packets at a certain rate for movement only/rotation only. I know that when you take firing a gun and calculating the impact into account, that it becomes a bit more complex. But i know how to handle that.
  3. Quote:Original post by e3d_ALiVE depens on what project u moved from my guess[u still mapping texel to pixels and u don't have to or the inverse] for more info it would better if u past shader code and on what api it worked I'm working with XNA 3.1. Here's the shader code i'm using for th edge detection: I've already tried to play with the Threshold settings, it does optimize it a bit, but that only gives me a bery thin, light edge around my character and on other areas a normal thick one. BTW, not sure what you mean with 'texel mapping'. So i can't tell if that's the problem. float4x4 World; float4x4 View; float4x4 Projection; float EdgeWidth = 0.8f; float EdgeIntensity = 1; // How sensitive should the edge detection be to tiny variations in the input data? // Smaller settings will make it pick up more subtle edges, while larger values get // rid of unwanted noise. float NormalThreshold = 0.5; float DepthThreshold = 0.1; // How dark should the edges get in response to changes in the input data? float NormalSensitivity = 1; float DepthSensitivity = 10; // Pass in the current screen resolution. float2 ScreenResolution; texture SceneTexture; //---------------------------- // Structures //---------------------------- sampler SceneSampler : register(s0) = sampler_state { Texture = (SceneTexture); MinFilter = Linear; MagFilter = Linear; AddressU = Clamp; AddressV = Clamp; }; // This texture contains normals (in the color channels) and depth (in alpha) // for the main scene image. Differences in the normal and depth data are used // to detect where the edges of the model are. texture NormalDepthTexture; sampler NormalDepthSampler : register(s1) = sampler_state { Texture = (NormalDepthTexture); MinFilter = Linear; MagFilter = Linear; AddressU = Clamp; AddressV = Clamp; }; //---------------------------- // Pixel Shader //---------------------------- float4 PixelShader(float2 texCoord : TEXCOORD0) : COLOR0 { // Look up the original color from the main scene. float3 scene = tex2D(SceneSampler, texCoord); // Apply the edge detection filter? // Look up four values from the normal/depth texture, offset along the // four diagonals from the pixel we are currently shading. float2 edgeOffset = EdgeWidth / ScreenResolution; float4 n1 = tex2D(NormalDepthSampler, texCoord + float2(-1, -1) * edgeOffset); float4 n2 = tex2D(NormalDepthSampler, texCoord + float2( 1, 1) * edgeOffset); float4 n3 = tex2D(NormalDepthSampler, texCoord + float2(-1, 1) * edgeOffset); float4 n4 = tex2D(NormalDepthSampler, texCoord + float2( 1, -1) * edgeOffset); // Work out how much the normal and depth values are changing. float4 diagonalDelta = abs(n1 - n2) + abs(n3 - n4); float normalDelta = dot(diagonalDelta.xyz, 1); float depthDelta = diagonalDelta.w; // Filter out very small changes, in order to produce nice clean results. normalDelta = saturate((normalDelta - NormalThreshold) * NormalSensitivity); depthDelta = saturate((depthDelta - DepthThreshold) * DepthSensitivity); // Does this pixel lie on an edge? float edgeAmount = saturate(normalDelta + depthDelta) * EdgeIntensity; // Apply the edge detection result to the main scene color. scene *= (1 - edgeAmount); return float4(scene, 1); } //---------------------------- // Technique //---------------------------- technique EdgeDetect { pass P0 { PixelShader = compile ps_2_0 PixelShader(); } }
  4. I have a toon + edge detection shader in my game project. I used the example from this website for that. But for some reason the edge detection doesn't always render the edge properly. I was hoping anyone here had an idea of what the problem could be. Take a look at the following screenshots. You can clearly see that the right image renders WITH edge detection, while the left image does it without. I all depends on where the camera is rotated around the character. I just have no idea why it sometimes doesn't render the edge and sometimes it does. Screenshot: http://i44.tinypic.com/11c9or4.png
  5. Is it possible, in XNA, to include/combine shaders?? I have 2 shader files which i want to combine as one big shader file when i compile my project. Is anything like that possible??
  6. Yeh, i don't get it either. I removed all the Clear() but i still get the same result. I also tried the shader fromt his site. It only uses one different RenderTarget instead of two like in the other example: http://digierr.spaces.live.com/blog/cns!2B7007E9EC2AE37B!420.entry But i still get the same problem. Only one mesh is drawn. I really don't get what the problem is and why it's doing that. It's probably got something to do with switching between rendertargets. Just don't know how to fix it... :(
  7. Ofcourse i googled... That code is also availible on the XNA site in a complete solution. The problem with that code however, is that its made for the GS 2.0 framework. This code doesn't work anymore in the GS3.0 framework. Well, it still works, but it only draws the last mesh, so if you have more meshes then you'll only see the last one you try to draw. But i'm still wondering what the problem is with the code that i found... I just want try to implement that...
  8. Yes, i know. I am using that site occasionally for information. Learning HLSL is on my task list, but just now right now... All i want right now is to implement a basic toon shader. And it seems to be a good basic one. I think it shouldn't be to difficult to use this in a XNA game right?? I'm just not sure how to implement it. Would be great if anyone could get me started with this first.
  9. Hey, i've found a toon shader: float4x4 mWorldViewProj; float3 mLightPos; float3 mCamPos; struct VS_OUTPUT { float4 Position: POSITION0; float2 TexCoord: TEXCOORD0; float3 Normal: TEXCOORD1; float3 LightDir: TEXCOORD2; float3 EyeDir: TEXCOORD3; }; VS_OUTPUT vertexMain( float4 Position: POSITION0, float2 TexCoord: TEXCOORD0, float2 diffuse: TEXCOORD1, float3 Normal: NORMAL0) { VS_OUTPUT Output; Output.Position = mul(Position, mWorldViewProj); Output.Normal = normalize(Normal); Output.LightDir = normalize(mLightPos - Position.xyz); Output.EyeDir = normalize(mCamPos - Position.xyz); Output.TexCoord = TexCoord; return(Output); } sampler2D tex0 : register(s0); sampler1D diffuseRamp : register(s1); float4 pixelMain ( float2 TexCoord: TEXCOORD0, float3 Normal: TEXCOORD1, float3 LightDir: TEXCOORD2, float3 EyeDir: TEXCOORD3 ) : COLOR0 { float4 texCol = tex2D(tex0, TexCoord); float diffuse = clamp(dot(Normal, LightDir), 0.0, 1.0); float4 lightColor = tex1D(diffuseRamp, diffuse); float fresnal = dot(Normal, EyeDir); fresnal = clamp((fresnal - 0.2) * 1000.0, 0.0, 1.0); lightColor *= fresnal; float3 reflect = (2.0 * diffuse * Normal) - LightDir; float specular = pow(clamp(dot(reflect, EyeDir), 0.0, 1.0), 8.0); specular = clamp((specular - 0.5) * 1000.0, 0.0, 1.0); float4 specular4 = specular * float4(1.0, 1.0, 1.0, 1.0); return(saturate(lightColor * texCol + specular4)); } source: http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=18281&sid=784b3ff1f5fd3b9c03729737589d32cf I was wondering how i can use this in XNA... Can someone please help me out with that?? Thanks for any help.
  10. I've tried playing around with the velocity settings. That does seems to be working but the downside is that i can climb any mountain, even if its almost vertically up... Guess i'll just stick with that method for now. But i'm also wondering how other games do it in general. Like a game as Call Of Duty. It also has physics on their characters. Do they also play with the velocity settings to move them around??
  11. I have a spaceship in my game with physics applied to it. When i want to move the ship forward (by pressing the W key) i simply apply a force to the ship. The problem here is that the ship keeps accelerating aslong as i press and hold the forward button. My question is, how to set a maximum limit to the speed/velocity?? So that it accelerates up to a certain speed, no matter how big the velocity is i applied to the ship.
  12. I don't think i can set a bool in my struct with SSE. I use the instrinct to check if SSE is availible, but to set a boolean value in my struct i really think i need ASM for that. But fortunately i already have the answer. To set the contents of ebx, edx and ecx directly in my char i have to use lea instead of mov. lea esi, [info.cpuName] and for the boolean i have to use byte ptr. mov byte ptr [info.bSSE], 1 This works perfectly.
  13. hmm, i don't get it. Because i'm using ASM to set the boolean, not SSE... Also, putting the value 1 in a register doesn't work either. Then i get an error 'operand size conflict' xor esi, esi mov esi, 1 mov [info.bSSE], esi
  14. I'm actually not sure what edx contains, but it must be some sort of string. I'll try to explain it a bit more. I'm trying to find out if the CPU supports the SSE (SIMD technology). When i call CPUID it automatically checks what number is stored in eax, then it returns new data about the CPU which is stored in other registers. If you check my code below you'll see that i'm getting the vendorname of the CPU first. The name of the vendor is always 12 letters long. So this means it's stored in three different registers; ebx, edx and ecx. I already knew how to put the result back into my struct. I'm declaring a char* which points to the char in my struct. But i was hoping that there was a direct way to set the value. But that part isn't important right now, cause it does work. What doesn't is setting the boolean. When i print out the boolean value i get '204' in console... Any idea why that is?? This is my code: typedef struct CPUINFO_TYP { char cpuName[48]; bool bSSE; } CPUINFO; CPUINFO GetCPUInfo ( ) { CPUINFO info; char* pStr = info.cpuName; //address to vendor name __asm { xor eax, eax mov eax, 0 CPUID //Get vendor name mov esi, pStr mov [esi], ebx mov [esi+4], edx mov [esi+8], ecx //Check if the CPU supports SSE mov eax, 1 test edx, 02000000h jz __NOSSE //if negative jump mov info.bSSE, 0 //else, set bool in struct to TRUE __NOSSE: } pStr[12] = '\0'; return info; } int main () { CPUINFO info = GetCPUInfo ( ); cout << info.cpuName << endl; if ( info.bSSE ) cout << info.bSSE << endl; system("pause"); return 0; }
  15. visual studio 2008 professional
  • 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!