Jump to content

  • Log In with Google      Sign In   
  • Create Account


dr4cula

Member Since 24 Jul 2013
Offline Last Active Today, 01:13 PM
-----

Posts I've Made

In Topic: MSAA artifacts

23 July 2014 - 07:57 AM

Try max(dot(H, normalVS), 0.0001f) and/or max(Ns, 0.0001f)? IIRC if both are zero you get NaN.

 

Didn't have time to test this out until now: unfortunately this didn't fix the issue...


In Topic: MSAA artifacts

18 July 2014 - 09:23 AM

In the 1x MSAA case, do you get flickering/crawling specular artifacts on the mesh when you move the camera around? If that's the case, then you're probably just experiencing run-of-the-mill shader aliasing. Shader aliasing occurs when you have high-frequency detail in the geometry or normal maps combined with high-frequency specular in the pixel shader, there's not enough pixels to sample the specular without noticable artifacts. 

 

Thanks for replying.

 

There's no flickering what-so-ever with 1x MSAA. That part of the speaker model doesn't even have a texture - it's all just color shaded. Odd, to say the least...


In Topic: MSAA artifacts

17 July 2014 - 09:22 AM

It appears the 3 pix are also of different resolutions. If you do lighting calcs in a pixel shader, are you sure it's not a specular (or other) lighting artifact? If you turn off lighting do you still have the problem?

 

Thanks for the suggestion! Looks like you are right. If I comment out the specular term then the artifact disappears. I really don't know where I've gone wrong with the equation though:

float3 V = normalize(-positionVS);
float3 H = normalize(L + V);
result += lightSpecular.rgb * Ks.rgb * pow(max(dot(H, normalVS), 0.0f), Ns);

Would it be safe to assume that the model itself has a bit funky normals? Thanks again!

 

EDIT: it seems that other models exhibit the same sort of behavior on very thin mesh parts: for example the legs of a chair, but not all of them, have these artifacts as well.


In Topic: Dual Paraboloid Environment Mapping

23 March 2014 - 06:41 AM

From the image it looks like you're rendering a very small number of polygons.
 
For dual paraboloid mapping that won't work well - you need lots of polys if you want it to look correct as the spherical transform is done on the vertices, and not per pixel.


Thanks for your reply!

-- edited --

I had a massive typo in my shaders earlier, should be fixed now. I've created a completely new scene with a higher res poly model to use for reflection. However, there's still a problem with it: http://postimg.org/image/ehiu32s81/ (scene setup (sphere is the reflective object): http://postimg.org/image/gy01i39jb/)

Since the projection remains constant (http://postimg.org/image/v57uibnpb/), I'm assuming something is off in my sampling, so here's my pixel shader:
 
// input description
struct PSInput {
	float4 position : SV_POSITION;
	float2 texCoord : TEXCOORD0;
	float3 normal : NORMAL;
	float3 incidentVector : INCIDENT_VECTOR;
};

cbuffer ParaboloidMatrices : register(b0) {
	matrix paraboloidWorldMatrix;
	matrix paraboloidViewMatrix;
};

// use the sampler bound to slot 0
SamplerState texSampler_;

// texture bound for rendering
Texture2DArray texture_ : register(t0);

/*
  =====================
  PSMain
  =====================
*/

float4 PSMain(PSInput input) : SV_TARGET {
	// normalize the necessary input vectors
	float3 normal = normalize(input.normal);
	float3 incident = normalize(input.incidentVector);

	// find the reflection vector in paraboloid space
	float3 ref = reflect(incident, normal);
	ref = mul(ref, (float3x3)paraboloidViewMatrix);

	// find the forward facing paraboloid texture coordinates, z specifies which texture from the array to use
	float3 forward;
	forward.x = ref.x / (ref.z + 1.0f);
	forward.y = ref.y / (ref.z + 1.0f);
	// convert to the appropriate range from [-1,1] to [0,1]
	forward.x = (forward.x + 1.0f) / 2.0f;
	forward.y = 1.0f - (forward.y + 1.0f) / 2.0f;
	forward.z = 0.0f;

	// find the backward facing paraboloid texture coordinates, z specifies which texture from the array to use
	float3 backward;
	backward.x = ref.x / (1.0f - ref.z);
	backward.y = ref.y / (1.0f - ref.z);
	// convert to the appropriate range from [-1,1] to [0,1]
	backward.x = (backward.x + 1.0f) / 2.0f;
	backward.y = 1.0f - (backward.y + 1.0f) / 2.0f;
	backward.z = 1.0f;

	float4 color;
	if(ref.z > 0.0f) {
		color = texture_.Sample(texSampler_, forward);
	}
	else {
		color = texture_.Sample(texSampler_, backward);
	}

	return color;
}
Thanks in advance once more!

In Topic: Smart Pointers Confusion

22 February 2014 - 11:11 AM

Calling a member function on a deleted object is undefined behavior, which often means a crash, but can really do anything at all including succeeding. In this case I'm guessing that your member function doesn't actually use any member variables so doesn't actually access any deleted memory.

 

Ah, of course. Indeed, as soon as I added a member variable, the function returned junk values. Just to be certain though, I allocated memory for an int in the constructor, then in the destructor deleted it and set the pointer to NULL and then had the original pointer query that member function that returned the variable's value and the application crashed as expected. Thanks for the quick reply!


PARTNERS