Jump to content

  • Log In with Google      Sign In   
  • Create Account

harveypekar

Member Since 18 Dec 2006
Offline Last Active Dec 21 2011 08:38 AM

Topics I've Started

Inspecting Visual C++ exe size

13 December 2011 - 11:20 AM

Hey everyone,

I want to reduce my exe size. My project pulls in a large lib (LLVM). Before I start amputating at random, I would like to have an idea what takes up the most space. Is there any tool/script that can get some meaningful numbers for me? I know I can generate a .MAP file, but it can't seem to relate it to footprint.

EDIT
already got it
http://aras-p.info/projSizer.html
http://code.google.com/p/mapfile/

Questions about multiple viewports

10 April 2011 - 05:54 PM

Hey everyone,

sorry about asking a question that should be clear from documentation, but right now I'm tired of banging my head against the wall.

Anyway, I'm implementing a GUi app that uses GL for multiple widgets, using windows but looking forward for crossplatform. I use QT, but decided to prototype further using my own widget as Qt borks as soon as I try to implement global resources (shaders et al) and right now, I'm just trying to understand what's going on.

From digging through the anecdotal evidence online, I realize I have two options:

Either use only one context (created on the main window handle) and call glViewport on rendering.
Or, use multiple contexts, and use wglShareLists to share shaders, textures, and VBO's.

I''m very unexperienced in GL, so I'm unable to judge the pro's and cons of either way. Can anyone tell me what the standard way of doing this would be?

OSS shader generator?

25 June 2009 - 03:56 AM

I was wondering if somebody knows about a library that can generate hardware shader code. I know blender does it internally, at least it was a summer of code, but I was looking for something generic. As an aside, does CUDA support linear/anisothropic filtering? I remember it didn't, but that's a while ago.

General FXC error and questions about Strauss

24 February 2009 - 04:50 AM

I've been trying to get the Strauss BRDF model to work on directx, but I've encountered a problem I can't seem to solve. Fxc is throwing me error X4579: NaN and infinity literals not allowed by shader model on a line where I have
specular *= pow (-dVH, 3.0 / smoothness );


The problem goes away when I use a constant (eg 0.5). Strange enough, it also goes away when leave the minus out of the first term. I have no idea why. I'm following the code from the DirectX10 book on gamedev wiki, and besdides the previous problems, which I can work around for now, I still see some more problems. It seems to me the specular values are all incorrect, and I get 2 nasty circles without specular in the middle [headshake]. They stem from the shadowing term from the model. Red is diffuse colour, green is specular. These are the shadowing terms multiplied: Effect code for reference

Vertex_output mainVS
(
	float3 pos : POSITION,
	float3 normal : NORMAL
) 
{
	Vertex_output output = (Vertex_output) 0;
	
	output.normal = mul(normal,world_inverse_transpose);
	output.position = mul(float4(pos.xyz, 1.0), world_view_proj);
	
	float4 position_ws = mul(float4(pos.xyz, 1.0), world);
	
	output.light_direction = light_pos_0 - position_ws;
	output.eye_direction = view_inverse[3].xyz - position_ws;
	
	return output;	
}

float strauss_fresnel
(
	float x, 
	float k_fresnel = 1.12f
)
{
	float nominator =   1 / pow(x  - k_fresnel,2)  - 1 / pow(k_fresnel,2);
	float denominator = 1 / pow(1 - k_fresnel,2) - 1 / pow(k_fresnel,2);

	return (nominator / denominator);
}

float strauss_shadow
(
	float x,
	float k_shadow = 1.01f
)
{
	float nominator = 1 / pow(1 - k_shadow,2) - 1 / pow(x - k_shadow,2);
	float denominator = 1 / pow(1 - k_shadow,2) - 1 / pow(k_shadow,2);
	
	return nominator / denominator;
}

float3 strauss
(
	float3 diffuse_color,
	float3 specular_color,
	float dNL,
	float dNV,
	float dVH,
	float roughness,
	float metalness,
	float transparency,
	float strauss_fresnel_constant = 1.12f,
	float strauss_shadow_constant = 1.01f,
	float strauss_specular_peak_constant = 0.1f
)
{
	float smoothness = 1 - roughness;
	float smoothness_cubed = pow(smoothness, 3);
	
	float d  = (1.0 - metalness * smoothness);
	float Rd =  (1.0 - smoothness_cubed) * (1.0 - transparency);
	float3 diffuse = dNL * d * Rd * diffuse_color;
	
	float fDNL = strauss_fresnel(dNL,strauss_fresnel_constant);
	
	
	float Rs = (1.0 - transparency) - Rd;
	float j = fDNL * strauss_shadow(dNL,strauss_shadow_constant) 
				   * strauss_shadow(dNV,strauss_shadow_constant); 
			   
	float reflect = min( 1.0, Rs + j * (Rs + strauss_specular_peak_constant) );

	float3 C1 = float3(1.0,1.0,1.0);
	float3 CS = C1 + metalness * ( 1.0 - fDNL) * (diffuse_color - C1);

	float3 specular = specular_color  * reflect;
	specular *= pow (-dVH, 3.0 / smoothness );
	
	diffuse = max(0.0, diffuse);
	specular = max(0.0,specular);

	//return specular * 10;
	return diffuse + specular;
}

float4 mainPS(Vertex_output input) : COLOR 
{
	float3 N = normalize(input.normal);
	float3 L = normalize(input.light_direction);
	float3 V = normalize(input.eye_direction);
	float3 H = normalize(V + L);
	float3 R = reflect(L,N);
	float dNL = saturate(dot(N,L));
	float dNH = saturate(dot(N,H));
	float dNV = saturate(dot(N,V));
	float dVH = saturate(dot(V,H));
	
	float4 shaded_colour = float4(0,0,0,1);
	shaded_colour.rgb = k_strauss * strauss
	(
	color_diffuse.rgb,
	color_specular.rgb, 
	dNL, 
	dNV, 
	dVH, 
	smoothness, 
	strauss_metalness, 
	transparency,
	k_strauss_fresnel,
	k_strauss_shadow,
	k_strauss_specular_peak
        );

        shaded_colour.a = transparency;
	return shaded_colour;
}

technique technique0 
{
	pass p0 
	{
		CullMode = None;
		VertexShader = compile vs_3_0 mainVS();
		PixelShader = compile ps_3_0 mainPS();
	}
}


Oh, I'm using FX Composer 2.5 and have a 9800GT

Lights, loops, and tangent space

09 February 2008 - 08:01 AM

Hey everyone, I have hit a wall when trying to implement bump mapping for a small amount of lights. I would like to take advantage of the loop instruction in later shader models, but when I use bump mapping I naturally have to pass the light information between VS and FS. Is there a way to combine looping and accessing the lights info from TEXCOORDS?

PARTNERS