Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 18 May 2001
Offline Last Active Jul 20 2014 11:06 PM

Topics I've Started

How to monitor video card memory

30 June 2014 - 11:46 AM

How can I see the contents and allocations of my video card memory, either in real time or in Pix or any other (free) diag program?  How can I poll the available video memory from a program before making allocations?  What is the best way to fine tune allocations to video memory?  I just realized that allocating beyond the available memory seems to crash the computer with no warning.  How do I avoid this while still taking advantage of the full available memory?  I'm using XNA at the moment but am porting to Sharp DX.  



HLSL Camera view angle to object with object rotation

07 June 2014 - 06:06 PM

How do I determine camera view angle to an object with the object's rotation factored in, to display a 2d "imposter" based on the actual view angle of the object?


I can get the camera angle to the object with:

half3 center = mul(input.inPos, xWorld);
half3 EyeVector = normalize(center-CameraPosition); 
float lookYaw = atan2(EyeVector.x, EyeVector.z);

But I'm not having any luck determining the view angle with object rotation factored in either by adding or subtracting the EyeVector with the ObjectRotation vector or by atan2'ing the ObjectRotation vector and adding or subtracting the result with lookYaw.  All vectors in question are normalized.  


Hope this makes sense.  Thanks!



Vertex Shader unexpected results, bizarre

08 May 2014 - 09:09 PM



I have a version 3.0 vertex shader for (what I call) Static Imposters that essentially decides which image in a texture atlas should be used and sends that info to the pixel shader.  


I am confident that the shader is written correctly but it always displays the wrong image!  If I run the shader through a debugger, the numbers are all correct, but the wrong image displays.  I have isolated this to a single variable, whose value is assigned from the program with Effect.Parameters["ImagesPerView"].SetValue(ImagesPerView);  


Running the shader through the Pix debugger, the value of ImagesPerView is always set correctly to 12, but the program displays the image as if the value of ImagesPerView is set to 11.  If I hardcode the value of ImagesPerView in the vertex shader to 12, overriding the program assignment, the program displays the correct image!  WHY am I getting different results even though the value of ImagesPerView is always 12?  


The program is assigning the value of 12 to ImagesPerView on every draw call.  I don't think this is due to any sort of  implicit conversions as I have checked the code thoroughly, and even did an (int)ImagesPerView conversion on every operation to make sure.  All of the other variable assignments in the shader appear to be correct and functioning correctly.  Stared at it until I was crosseyed.....What The Heck am I doing wrong?  

Any ideas welcome.



hlsl spherical billboard y rotation? math question

16 February 2014 - 06:36 PM



I'm implementing a spherical billboard system for overhead views.  When the camera is directly overhead I don't want the billboard to rotate on it's Y axis but instead want to assign an arbitrary y rotation to the billboard, for example trees with varying y axis rotations.  


I'm forcing the billboard to face upward with these statements:  


sideVector=float3(1,0,0) //right
upVector=float3(0,0,-1)   //forward
How do I rotate this an x amount on the Y axis?  

Static Imposter Pixel Shader?

04 February 2014 - 12:01 AM

I'm trying to implement Static Imposters and am having a hard time finding info or samples on how to create a pixel shader....can anybody point me to any resources?  I'm finding lots of theoretical discussions but no solid code, and I'm thinking my math isn't strong enough to write an efficient shader.  


Specifically, I have spherical billboards that will draw images from texture atlases of different angles based on the camera angle to the object, always lerping between two images that describe the nearest angle, with images for every 45 degrees, including top-down angles.  Everything works except the final mechanism to decide which images to use.  So I THINK I need a pixel shader that determines the camera angle to the object on the Y axis and picks the two closest images to the angle, lerping between them as the camera angle changes, and determines the camera angle to the object on the X axis to decide if top-down images should be used.  IE if I have 24 images in my atlas, the first have a 0 degree rotation on the X axis with 45 degree intervals on the Y axis, the next 8 have a 45 degree rotation on the X axis with 45 degree intervals on the Y axis, and the final 8 have a 90 degree rotation on the X axis (straight down) at 45 degree intervals on the Y axis.  SO if the camera is above the object add 8 to the image index to get a down-angle image and add 16 to the index to get a straight-down angle.  Hope this makes sense.  


I'm trying to add trees to my world that will allow for a top-down view, using deferred rendering to create lighting, shadows, and reflections.  This will be my final step if it works!