Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


montify

Member Since 07 Nov 2012
Offline Last Active Nov 17 2014 04:07 AM

Posts I've Made

In Topic: Use 64bit precision (GPU)

21 April 2014 - 11:14 AM

Update:

 

Now i do the Relative to the Eye transformation in the VertexShader
 

VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
{
    VertexShaderOutput output;

	float3 worldPosition = mul(input.Position, World).xyz;


		float3 normalized = normalize(worldPosition);  // Normalize all Vertex to get a Sphere

		float4 scaled = float4(normalized * SeaLevel, 1);  // Scale all Vertex with SeaLevel = 6000

		scaled -= float4(camPosition, 1); //All geometry relative to the Eye 
		

	output.Position = mul(scaled, ViewProj);
	output.Position.z = log(C*output.Position.z + 1) / log(C*Far + 1) * output.Position.w; //Logarithmic Depth Buffer
    return output;
}

It works, no Jittering, but i have some odd  "stairs"

 

So whats going on here?

treppen.png


In Topic: Use 64bit precision (GPU)

19 April 2014 - 10:40 AM

So i have it .

 

I Set the Camera Posititon to Vector3.Zero and "hack" the worldMatrix
 

  //new View Matrix
                var View = Matrix.CreateLookAt(Vector3.Zero, cam.Forward, cam.Up);


                Vector3 cameraSpacePosition = (position - cam.Position);

                //Relative to the Camera
                world.M41 = cameraSpacePosition.X;
                world.M42 = cameraSpacePosition.Y;
                world.M43 = cameraSpacePosition.Z;

But i scale/normalize each vertex (the entire Planet) in the Shader like ( with *6000):

VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
{
    VertexShaderOutput output;

	float3 worldPosition = mul(input.Position, World).xyz;
	
	float3 normalized = normalize(worldPosition);
	float4 scaled = float4(worldPosition * 6000, 1);

	output.Position = mul(scaled, ViewProj);

	output.Position.z = log(C*output.Position.z + 1) / log(C*Far + 1) * output.Position.w; //Logarithmic Depth Buffer
	
    return output;
}

The Scale and Normalize don't work anymore...

 

anybody out there who have a Solution for this Problem?


In Topic: Use 64bit precision (GPU)

17 April 2014 - 11:32 AM

nono the worldmesh created like:

 

 

I have one VertexBuffer 33x33 vertices. ( a flat Plane )

 

Now i made 6 of this Planet (Rotatet, Translate) to get a Cube.

 

Now i normalize the Input.Position in the Shader = A perfect Sphere.

 

---------------------

 

Is it possible and have it the same effect to translate the Position ( Position - cameraPosition) NOT in the WorldSpace but rather in ViewSpace?


In Topic: Use 64bit precision (GPU)

17 April 2014 - 09:32 AM

Oh Sorry, so :

 

Im working on a Procedural Planet with ChunkedLOD in earth Size.

 

To get a Sphere out of 6 Planes, i normalize each Vertex.

 

But the requirement is, the center of the cube (out of 6 planes) must be 0,0,0 (world-origin) like:

 

http://britonia.wordpress.com/2010/05/20/planet-geometry/

 

 

But here do the Vector3.normalize on the CPU, but i do it on the GPU:

VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
{
    VertexShaderOutput output;

	
	float3 worldPosition = mul(input.Position, World).xyz;


		float3 normalized = normalize(worldPosition);
		float4 scaled = float4(normalized * SeaLevel, 1);

		output.Position = mul(mul(scaled, View), Projection);

		output.UV = input.UV;

    return output;
}

So, when i subtract the Camera Position from the QuadTree-Patch Position the Center of my Sphere/Cube is not 0,0,0 .


In Topic: Use 64bit precision (GPU)

17 April 2014 - 01:49 AM

Thank you for reply

Ok i should use relative to the eye

So i have one vertexbuffer for each childnode and rootnode.
Only the worldmatrix is changing.

My problem is i use cube2sphere mapping which require that the cubecenter is 0,0,0

With relative to the eye the camera position is at 0,0,0?
So whats my line? When i substract the camera position from the patch position the cube is out of the origin in worldspace

PARTNERS