Jump to content

  • Log In with Google      Sign In   
  • Create Account


OzgurEra

Member Since 22 Jun 2012
Offline Last Active Yesterday, 10:38 AM
-----

Posts I've Made

In Topic: Vertex Buffers in OpenGL

19 January 2013 - 08:46 PM

Actually I won't need DirectX codes. I'm just writing a renderer, I will implement it using OpenGL, but I want it to become flexible. So I just want things to be correct, and won't be a problem when I decide to write a DirectX renderer.
 

My VertexBuffer class keeps the system pointers, and it seems that I can use them both in OpenGL and DirectX..

Thank you so much mhagain.


In Topic: UDP Clients

07 December 2012 - 06:35 PM

Often, you will have a handshake protocol when a client wants to connect to a server. Then the server can assign a number (ticket) to each client. The ticket can be a simple index into a table that you can quickly look up by reading that number off the client packet. You can also do a sanity check on the address, for example making sure the ticket is not getting 'spoofed' by another client.


Wow thanks,, that was what is on my mind :)

In Topic: Ortho Shadow Problem.

22 June 2012 - 04:13 PM

No there is no problem Posted Image ( -1 into ortho is possible.)
But I solved.. with a new shader code Posted Image


uniform sampler2D ShadowMap;
uniform sampler2D textureSampler;
uniform vec4 LightColor;
varying vec4 ShadowCoord;
varying vec2 TexCoord0;
varying vec3 WorldNormal;
varying vec3 LightDir;
vec4 DividedShadowCoord;
float xPixelOffset = 1.0 / (1366.0 * 1.0);
float yPixelOffset = 1.0 / (768.0 * 1.0);
float lookup(vec2 offSet)
{
return texture2D(ShadowMap, DividedShadowCoord + vec4(offSet.x * xPixelOffset , offSet.y * yPixelOffset, 0.0, 0.0) ).z;
}
void main()
{
vec3 FinalDiffuse = vec3(0.0, 0.0, 0.0);
vec3 AmbientLight = vec3(0.0, 0.1, 0.1);
vec4 TexColor = vec4(texture2D(textureSampler, TexCoord0));
float shadow;
float attenuation;
DividedShadowCoord = ShadowCoord;
DividedShadowCoord = DividedShadowCoord / DividedShadowCoord.w;
DividedShadowCoord.z += 0.00005;
float LenSq = length(LightDir);
vec3 N = normalize(WorldNormal);
vec3 L = normalize(LightDir);
float lambertTerm = max(dot(N, L), 0.0);
attenuation = min((LightColor.w * LightColor.w) / (LenSq * LenSq), 1.0);
FinalDiffuse += LightColor * lambertTerm;// * attenuation;
if (DividedShadowCoord.w > 0.0)
{
  float x,y;
  for (y = -1.5 ; y <=1.5 ; y+=1.0)
   for (x = -1.5 ; x <=1.5 ; x+=1.0)
	shadow +=  lookup(vec2(x,y)) < DividedShadowCoord.z ? 0.0 : 1.0 ;
  shadow /= 16.0 ;
}
FinalDiffuse *= shadow;
vec4 outColor = vec4(vec3(/*TexColor.xyz **/ (FinalDiffuse + AmbientLight.xyz)) , TexColor.a);
gl_FragColor = outColor;
}

Now working perfectly..

PARTNERS