Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your feedback on a survey! Each completed response supports our community and gives you a chance to win a $25 Amazon gift card!


elurahu

Member Since 23 Jan 2006
Offline Last Active Dec 07 2013 12:40 PM

Posts I've Made

In Topic: GPU voxelization - Conservative rasterization issue.

27 December 2012 - 04:44 PM

First of all - Thank you for your answer.

 

I agree that having orthographic projects makes alot of stuff easiere as I can just extend the clipspace vertices directly. The problem lies in HOW much to extend. The article outlines that you'll need to extend along the worst-case semidiagonal. The author uses the fact that a line in clipspace can be represented as a plane through the camera (0,0,0) in projected space and then dilutes along the plane normal - Then to find the new vertex positions they do a plane - plane intersection using a cross product.

 

I just don't think this works for orthographic projects as all points on a direction vector from the origin doesn't project to a single point.

 

For reference here my geometry code for the impl.

 

	// Triangle bounding box.
	vec4 f4AABB;

	// Compute v0.
	vec4 f4CSV0 = m4ViewProj * RF_WORLD * gl_in[0].gl_Position;
	f4AABB.xy = f4CSV0.xy;
	f4AABB.zw = f4CSV0.xy;
	
	// Compute v1.
	vec4 f4CSV1 = m4ViewProj * RF_WORLD * gl_in[1].gl_Position;
	f4AABB.xy = min(f4AABB.xy, f4CSV1.xy);
	f4AABB.zw = max(f4AABB.zw, f4CSV1.xy);

	// Compute v2.
	vec4 f4CSV2 = m4ViewProj * RF_WORLD * gl_in[2].gl_Position;
	f4AABB.xy = min(f4AABB.xy, f4CSV2.xy);
	f4AABB.zw = max(f4AABB.zw, f4CSV2.xy);

	// Extend and set AABB.
	f4AABB.xy -= vec2(fHalfPixel);
	f4AABB.zw += vec2(fHalfPixel);
	OUT.f4AABB = f4AABB;
	
	// Compute dialated edges.
	vec3 f3Plane[3];
	f3Plane[0] = cross(f4CSV0.xyw - f4CSV2.xyw, f4CSV2.xyw);
	f3Plane[1] = cross(f4CSV1.xyw - f4CSV0.xyw, f4CSV0.xyw);
	f3Plane[2] = cross(f4CSV2.xyw - f4CSV1.xyw, f4CSV1.xyw);
	f3Plane[0].z -= dot(vec2(fHalfPixel), abs(f3Plane[0].xy));
	f3Plane[1].z -= dot(vec2(fHalfPixel), abs(f3Plane[1].xy));
	f3Plane[2].z -= dot(vec2(fHalfPixel), abs(f3Plane[2].xy));
	
	// Compute plane intersections.
	f4CSV0.xyw = cross(f3Plane[0], f3Plane[1]);
	f4CSV1.xyw = cross(f3Plane[1], f3Plane[2]);
	f4CSV2.xyw = cross(f3Plane[2], f3Plane[0]);
	
	// Emit vertex data.
	OUT.f3CSPosition = m3Rotation * (f4CSV0.xyz / f4CSV0.w);
	OUT.f3Color = f3Color;
	gl_Position = f4CSV0;
	EmitVertex();
	
	OUT.f3CSPosition = m3Rotation * (f4CSV1.xyz / f4CSV1.w);
	OUT.f3Color = f3Color;
	gl_Position = f4CSV1;
	EmitVertex();
	
	OUT.f3CSPosition = m3Rotation * (f4CSV2.xyz / f4CSV2.w);
	OUT.f3Color = f3Color;
	gl_Position = f4CSV2;
	EmitVertex();

	EndPrimitive();

In Topic: Event handling - Lifetime management

18 November 2012 - 04:50 PM

struct A
{
RFDelegate1<int> m_kDelegate;
A()
{
  std::cout << "A" << std::endl;
}
~A()
{
  std::cout << "~A" << std::endl;
}
void DoWork()
{
  if (!m_kDelegate.empty())
   m_kDelegate(69);
}
};
struct B
{
std::weak_ptr<A> m_wpA;
int m_i;
B(const std::shared_ptr<A>&amp; spA)
{
  std::cout << "B" << std::endl;
  m_wpA = std::weak_ptr<A>(spA);
  spA->m_kDelegate = RFMakeDelegate(this, &amp;B::Handler);
}
~B()
{
  std::cout << "~B" << std::endl;
  if (!m_wpA.expired())
  {
   m_wpA.lock()->m_kDelegate.clear();
  }
  std::cout << "Deleted" << std::endl;
}
void Handler(int i)
{
  m_i = i;
  std::cout << "Handled " << m_i << std::endl;
}
};

// Usage
{
std::shared_ptr<A> spA = std::make_shared<A>();
B* pkB = new B(spA);
spA.reset();
delete pkB;
}

Well this is what I was doing now - But it's hardly a "pretty" solution. But I guess that's just C++ for you.

In Topic: Event handling - Lifetime management

18 November 2012 - 04:24 PM

C++

In Topic: GLSL C7507 warning

29 December 2011 - 03:44 AM

My guess would be to change the shader version to something newer than 120. I don't believe it supports ints.

In Topic: Choices for Texture Loading

20 October 2011 - 01:33 AM

On this I very much side with L. Spiro.

Writing a loader yourself will be a very good experience. PNG / JPG loaders are not as hard as you might think. Most (sane) people will tell you to use the jpeglib for loading compressed JPG and libpng / zlib for loading PNGs.

The TGA format is a very good format to start with. Try and write a loader for non-compressed TGA and RLE compression. You should be able to have that running after a few hours starting from scratch.

If you need help - Just ask :)

PARTNERS