@David, thank you! There is a lot of stuff in there that I can try out, especially I didn't know that the world position is .5 at the fragment level, that is awesome (I think for me it will be multiples of 8 since I scale by 16)
I seriously hate that there is absolutely no way for me to figure out what is wrong with my CG programs. The only way I know it is totally broken is if it is all white, but if it compiles, that does not mean that it works as intended, and figuring out what values are where and why they aren't doing what I want them to is seriously fking tiring... makes me get derailed so much faster - but I need picking to work before I can add anything to a real game, so it's pretty much a must have.
right now I'm, trying to just color on the distance and that doesn't even work....
EDIT: I tried some new stuff and I now have this:
Attachment:
picking.jpg [ 47.51 KiB | Viewed 3490 times ]
sadly this is not really what I want (clearly the fragments have their own positions by this point. here is my code:
Code:
void PickerVP(
float4 inPosition : POSITION,
float2 inMaterial : TEXCOORD0,
out float4 outClipPosition : POSITION,
out float4 outWorldPosition : TEXCOORD0,
out float2 outMaterial : TEXCOORD1,
out float4 outCameraPos : TEXCOORD2,
out float4 tmp : TEXCOORD3,
uniform float4x4 world,
uniform float4x4 viewProj,
uniform float4 cameraPos
)
{
//Compute the world space position
outWorldPosition = mul(world, inPosition);
//Compute the clip space position
outClipPosition = mul(viewProj, outWorldPosition);
//Pass through the material
outMaterial = inMaterial;
outCameraPos = cameraPos;
tmp = outClipPosition;
}
void PickerFP(
float4 inPosition : POSITION,
float4 inWorldPosition : TEXCOORD0,
float4 inMaterial : TEXCOORD1,
float4 inCameraPos : TEXCOORD2,
float4 tmp : TEXCOORD3,
out float4 result : COLOR)
{
float3 worldNormal = cross(ddy(inWorldPosition.xyz), ddx(inWorldPosition.xyz));
worldNormal = normalize(worldNormal);
result = float4(1,0,0,1);
if (distance(tmp.xyz, float3(0,0,0)) < 512){
result = float4(tmp.x/512,tmp.y/512,tmp.z/512,1);
}
}
obviously I'm just testing the concept right now, but it seems I have a lot of work to do still
EDIT2:
Quote:
5) Fragment world space positions are always ending with '.5'. You need to work out which integer position this corresponds to (i.e. the actual voxel position). You will probably want to take acount of the normal to do this.
this is clearly the piece of the puzzle I need to understand better to make this work. Which variable is the world space position that my fs is getting? Do I need to do all the transforms in my fs instead of my vs? Overall I just don't think I understand this quite well enough to pull it off myself : /