virtual void initEvent()
  {
    vl::Log::print(appletInfo());

    trackball()->setTransform(rendering()->as<vl::Rendering>()->transform());

    mMipmappingOn = true;
    mLodBias = 0.0;

    multitexturing();
    textureRectangle();
    texture3D();
    texture2DArray();
    texture1DArray();
    sphericalMapping();
    cubeMapping();
  }
Example #2
0
void IterateVoxel(inout vec3 voxel, Ray ray, inout vec4 colorAccum)
{
	float maxX = 0.0;
	float maxY = 0.0;
	float maxZ = 0.0;
	
		
	if(ray.Direction.x != 0.0)
	{
		maxX = max((voxel.x - ray.Origin.x) / ray.Direction.x, (voxel.x + 1.0 - ray.Origin.x) / ray.Direction.x);
	}
	if(ray.Direction.y != 0.0)
	{
		maxY = max((voxel.y - ray.Origin.y) / ray.Direction.y, (voxel.y + 1.0 - ray.Origin.y) / ray.Direction.y);
	}
	if(ray.Direction.z != 0.0)
	{
		maxZ = max((voxel.z - ray.Origin.z) / ray.Direction.z, (voxel.z + 1.0 - ray.Origin.z) / ray.Direction.z);
	}

	vec2 hitPoint;
	float texture;
	if(maxX <= min(maxY, maxZ))
	{
		voxel.x += sign(ray.Direction.x);
		int block = GetVoxel(voxel);

		if(block != 0)
		{
			texture = (ray.Direction.x > 0) ? textureFaces[block*6 + 0] : textureFaces[block*6 + 1];
			hitPoint = fract(ray.Origin + ray.Direction * maxX).zy;
			colorAccum = texture2DArray(textures, vec3(1.0 - abs(hitPoint), texture));
			colorAccum.xyz *= 0.9;
		}
	}
	if(maxY <= min(maxX, maxZ))
	{
		voxel.y += sign(ray.Direction.y);
		int block = GetVoxel(voxel);

		if(block != 0)
		{
			texture = (ray.Direction.y > 0) ? textureFaces[block*6 + 3] : textureFaces[block*6 + 2];
			hitPoint = fract(ray.Origin + ray.Direction * maxY).xz;
			colorAccum = texture2DArray(textures, vec3(1.0 - abs(hitPoint), texture));
			colorAccum.xyz *= 1.0;
		}
	}
	if(maxZ <= min(maxX, maxY))
	{
		voxel.z += sign(ray.Direction.z);
		int block = GetVoxel(voxel);

		if(block != 0)
		{
			texture = (ray.Direction.z > 0) ? textureFaces[block*6 + 4] : textureFaces[block*6 + 5];
			hitPoint = fract(ray.Origin + ray.Direction * maxZ).xy;
			colorAccum = texture2DArray(textures, vec3(1.0 - abs(hitPoint), texture));
			colorAccum.xyz *= 0.8;
		}
	}
}