Sign in to follow this  

Terrain Ground Cursor Problem - solved

This topic is 3372 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I am working on a terrain editor that allows the mouse to move a cursor on the terrian through ray intersection. I have the ray intersection working perfectly but need the cursor to be rendered on the terrain. (In C++, DirectX, HLSL) I found a project in c# here : http://www.gameprojects.com/project/?id=8fc946fc5f This does what I want to do, the code for rendering the cursor in the shader is as so : float4 cursorColour = tex2D(GroundCursorSampler, (texCoord * (cursorScale / groundCursorSize)) - (groundCursorPosition.xz * (cursorScale / groundCursorSize)) + 0.5f); This code is in the pixel shader (HLSL) and the resulting cursorColour is added to the final pixel colour. However I am having trouble understanding how this is meant to work. I have tried putting this into my shader, but the cursor isn't drawn in the right place, to the right scale, or sometimes drawn at all. If anyone has any ideas, or can explain how the above code works so that mabe I can see what might be going wrong that would be great. Thanks! EDIT : The above code for the shader works, I was just forgetting to convert the texture position to between 0 and 1, and also needed to invert the z position. [Edited by - p0is0n on September 18, 2008 6:39:02 AM]

Share this post


Link to post
Share on other sites

This topic is 3372 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this