Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


BlackJoker

Member Since 28 Feb 2013
Offline Last Active Nov 26 2014 11:55 AM

Posts I've Made

In Topic: Corrupting of the view if far from world center

14 November 2014 - 06:31 AM

Thanks to all.

I guess that I will stop at keep camera in center suggestion. This seems to be the easiest and cleanest way to workaround such issues.


In Topic: Corrupting of the view if far from world center

13 November 2014 - 11:57 PM

My vertex shader code is:

struct VertexInputType
{
    float4 position : SV_POSITION;
	float3 normal : NORMAL;
	float2 tex : TEXCOORD0;
	
};

struct PixelInputType
{
    float4 position : SV_POSITION;
 	float3 normal : NORMAL;
	float2 tex : TEXCOORD0;
	float3 viewDirection: TEXCOORD1;
};


////////////////////////////////////////////////////////////////////////////////
// Vertex Shader
////////////////////////////////////////////////////////////////////////////////
PixelInputType LightVertexShader(VertexInputType input)
{
    PixelInputType output;
	
	// Change the position vector to be 4 units for proper matrix calculations.
    input.position.w = 1.0f;
	// Calculate the position of the vertex against the world, view, and projection matrices.
    output.position = mul(input.position, worldMatrix);
    output.position = mul(output.position, viewMatrix); 
    output.position = mul(output.position, projectionMatrix); 
	
	output.position.z = log(zNear*output.position.z + 1) / log(zNear*zFar + 1) * output.position.w;

	// Store the texture coordinates for the pixel shader.
	output.tex = input.tex;
    
	// Calculate the normal vector against the world matrix only.
	  
	output.normal = mul(input.normal, (float3x3)worldMatrix);
	// Normalize the normal vector.
    output.normal = normalize(output.normal);

	float4 posWorld = mul(input.position, worldMatrix);
	output.viewDirection = float4(cameraPosition,0) - posWorld;
    

    return output;
}

In Topic: Corrupting of the view if far from world center

13 November 2014 - 05:17 PM

How to use doubles to get more precesion? Could you write about this more detail?

 

How translating the whole world to fixed distance could cause bugs? Dos it not the same as moving the whole world?

 

BTW, I susprect, that game logic gets more complicated if I need to move the whole world with many objects instead of one camera. What if I want to move not only camera. but also binded object? I need to move everything except 1 model and camera? Did I undertand you correctly?


In Topic: Corrupting of the view if far from world center

13 November 2014 - 04:22 PM

But does it not expensive to move a lot of objects instead of just one camera? ALso, logic become more complicated in that case, I think


In Topic: Corrupting of the view if far from world center

13 November 2014 - 04:12 PM

kauna

Thanks.

But is 1.2*10^5-6 is so big number that it will lead to such errors?

Could be this issue be fixed somehow? Or is there maybe some workaround?


PARTNERS