Jump to content

  • Log In with Google      Sign In   
  • Create Account


mgoss

Member Since 28 Apr 2012
Offline Last Active Oct 24 2013 01:17 PM
-----

#5041020 God Rays + Alpha ( is it possible )?

Posted by mgoss on 08 March 2013 - 07:16 PM

Edit: Never mind I got it working. 




#4971169 Lighting in caves

Posted by mgoss on 19 August 2012 - 12:01 PM

I think the best and fastest way is this. We already have light propagating for each block. In the GBuffer, I can pass those lighting values to a channel. Then in the Directional Lighting, apply the ambient lighting according to whats in the channel.


#4963896 Obscuring the game code

Posted by mgoss on 28 July 2012 - 03:28 AM

I've tried both of those and they don't seem to like our code. :/


#4958681 Reconstruct position from log depth

Posted by mgoss on 13 July 2012 - 01:15 AM

Here how I'm applying the logarithmic depth in the vertex shader.
output.Position.z = log(output.Position.z / 0.001) / log(FarPlane / 0.001) * output.Position.w; //log(z/zn)/log(zf/zn)

Reconstructing in pixel shader. Not sure if i'm doing this correctly.

//read depth
float depthVal = DepthMap.Sample(depthSampler, texCoord).r;

//Compute screen-space position
float4 position = float4(input.ScreenPosition.xy, depthVal, 1.0f);
position.z = exp(depthVal * log(FarPlane / 0.001)) * 0.001; //(exp(z*log(zf/zn))*zn : z = depth value

//transform to world space
position = mul(position, InvertViewProjection);
position /= position.w;


#4939723 Voxel traversal problem

Posted by mgoss on 13 May 2012 - 12:17 AM

There a much easier way of finding blocks. If you have an 3 dimensional array. For instance, a Blocks[16, 128, 16] for a chunk.


float x = position.X;
float y = position.Y;
float z = position.Z;
int x = ((int)x / SCALE) % 16;
int y = ((int)y / SCALE) % 128;
int z = ((int)z / SCALE) % 16;

scale is how big your blocks are. Then you can say Block b = Blocks[x, y, z];

If you want to pick what blocks you clicked on. Then do this


const int range = SCALE * 10; //10 = Distance in radius
for(int x = playerX - range; x <= playerX + range; x += SCALE)
{
	 for(int z = playerZ - range; z <= playerZ + range; z += SCALE)
	 {
		  for(int y = playerY - range; y <= playerY + range; y += SCALE)
		  {
			   SignedVector3i xyz = GetBlockIndex(new Vector3(x, y, z));
			   Block b = Block[xyz.x, xyz.y, xyz.z];
			   //Create a bounding box around that block and it's 6 bounding boxes for each face. Then use a ray to see which side it intersected at.
		  }
	 }
}



PARTNERS