Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

137 Neutral

About relaxok

  • Rank

Personal Information

  • Interests

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. I am trying to debug D3D11 shader bytecode without source. According to this page: https://docs.nvidia.com/nsight-visual-studio-edition/Content/Shader_Debugger.htm This should be possible, under 'Byte Code Debugging' However it doesn't actually say how to start debugging them. I Ctrl-Z the app and hit Space to capture a frame. Then in Windows->Shaders I choose the pixel shader to debug (while having the draw call that uses that shader selected in the scrubber). The next step it says to choose Windows -> Choose Graphics Focus, but that doesn't exist in the latest version(?) I can set breakpoints in the shader bytecode file that comes up when clicking through to the shader, however they are never hit. What am I missing? Has anyone successfully done this? Is there any software you can debug/breakpoint shader bytecode and see registers after each instruction etc?
  2. relaxok

    HLSL - Billboarding a mesh

      I'm not quite following your description, sorry... but maybe this is going back to what you're referring to.. this and showing both sides of the mesh, I do get fairly close.. // billboard? if( flags & PER_MESH_FLAG_BILLBOARD ) { matrix worldViewMat = mul( worldMatrixInstance, viewMatrix ); output.position = skinnedPos + float4( worldViewMat._41, worldViewMat._42, worldViewMat._43, 1.0f ); } output.position = mul( output.position, projectionMatrix ); But as you can see, while the distance of the camera is accounted for fine.. the proper translation doesn't happen when the camera rotates on axes..   http://bh.polpo.org/billboard_rotate_issue.wmv   What's the reason for this?
  3. relaxok

    HLSL - Billboarding a mesh

    Because it undoes the rotation applied by the camera…   Why don’t you just quickly make the WBP (world-billboard-projection) matrix and be done with all that ridiculous math?   XMMATRIX mBillboard; XMMatrixInverse( &mBillboard, m_matView ); // m_matView is the inverse of another matrix, so instead of inverting it again you could just copy that matrix. // Only keep the upper-left 3×3. mBillboard._41 = mBillboard._42 = mBillboard._43 = 0.0f; // Billboard matrix complete. XMMATRIX mBillboardView = mBillboard * m_matView; // Can be used instead of the view matrix. XMMATRIX mBillboardViewProjection = mBillboardView * m_matProj; // Can be used instead of the view-projection matrix. Why make it so complicated? L. Spiro     The reason it's all spread out is that it's not working yet, and this way I can experiment with changing individual elements.   I have tried everything suggested in this thread and it's still not working.  Using your suggested method in the above quote, the mesh simply doesn't appear at all, the same as most other attempts..   Still the closest I've gotten is using the inverses of the rotation matrices, but the vertices translate all over the place in this case.. as shown in the video i linked.
  4. relaxok

    HLSL - Billboarding a mesh

    My new idea was to try making a billboarding view matrix which does the translation based on the real camera rotations, but for the rotation part of the view matrix, uses the inverse matrices.   This results in ALMOST the correct result.. the mesh now stays 'camera facing' no matter what the camera is doing, however the translation seems to put it all over the place.  I'm wondering how this can be when the translation is the same as when not billboarding:   http://bh.polpo.org/quad_no_rot1.avi   What adjustment can I make to keep the translation correct? void CCamera::transform( float x, float y, float z, float fOrientation ) { XMMATRIX matRotationX = XMMatrixRotationX( m_Pitch ); XMMATRIX matRotationY = XMMatrixRotationY( XMConvertToRadians( fOrientation * 360.0f ) + m_Yaw ); XMVECTOR unitVec = XMVectorSet( 0.0f, m_Height, -m_Distance, 0.0f ); XMVECTOR transVec = XMVector3TransformCoord( unitVec, matRotationX * matRotationY ); m_posX = x + XMVectorGetX( transVec ); m_posY = y + XMVectorGetY( transVec ); m_posZ = z + XMVectorGetZ( transVec ); XMMATRIX matTranslation = XMMatrixTranslation( m_posX, m_posY, m_posZ ); XMVECTOR matInvDeter; XMMATRIX matInverse = XMMatrixInverse( &matInvDeter, matRotationX * matRotationY ); XMMATRIX matTransInverse = XMMatrixInverse( &matInvDeter, matTranslation ); // Billboard version XMVECTOR matRotBillboardDeter; XMMATRIX matRotationXBillboard = XMMatrixInverse( &matRotBillboardDeter, matRotationX ); XMMATRIX matRotationYBillboard = XMMatrixInverse( &matRotBillboardDeter, matRotationY ); XMMATRIX matInverseBillboard = XMMatrixInverse( &matInvDeterBillboard, matRotationXBillboard * matRotationYBillboard ); XMStoreFloat4x4( &m_matView, matTransInverse * matInverse ); XMStoreFloat4x4( &m_matBillboard, matTransInverse * matInverseBillboard ); XMStoreFloat4x4( &m_matRotationX, matRotationX ); XMStoreFloat4x4( &m_matRotationY, matRotationY ); XMStoreFloat4x4( &m_matTranslation, matTranslation ); calculateViewFrustum(); }
  5. relaxok

    HLSL - Billboarding a mesh

      Why would that accomplish not rotating it?
  6. relaxok

    HLSL - Billboarding a mesh

    Isn't the line:   float3 position = input.position + float3( boneWorldViewMatrix._41, boneWorldViewMatrix._42, boneWorldViewMatrix._43 );   supposed to do exactly that?  adjust by the translation only..
  7. relaxok

    HLSL - Billboarding a mesh

      It seems like that's what I'm doing?   Latest attempt: // billboard? if( flags & PER_MESH_FLAG_BILLBOARD ) { matrix boneWorldMatrix = mul( bonematrix, worldMatrixInstance ); matrix boneWorldViewMatrix = mul( boneWorldMatrix, viewMatrix ); float3 position = input.position + float3( boneWorldViewMatrix._41, boneWorldViewMatrix._42, boneWorldViewMatrix._43 ); output.position = mul( float4( position, 1.0f ), projectionMatrix ); } else { output.position = mul(output.position, projectionMatrix); }
  8. Guys:   I have a vertex shader that I use for all my non-terrain models.  My per-mesh structure has a flags uint where i can set things like billboard, unlit, etc.  Some models have single meshes that need to be billboarded, like a light halo that looks the same from any angle.  However, I can't figure out how to successfully billboard the mesh.   Below is my vertex shader.. in the billboard section I've tried various combinations of matrices as you can see.. based on MJP's response in this topic:     http://www.gamedev.net/topic/507808-hlsl-billboard/ PixelInputType VS(VertexInputType input, uint InstanceID : SV_InstanceID ) { PixelInputType output; // Fix w input.position.w = 1.0f; // Calculate animation matrices matrix bonematrix = ( float( input.boneweight0 ) / 255.0f ) * BoneMatrices[ input.boneindex0 ]; bonematrix += ( float( input.boneweight1 ) / 255.0f ) * BoneMatrices[ input.boneindex1 ]; bonematrix += ( float( input.boneweight2 ) / 255.0f ) * BoneMatrices[ input.boneindex2 ]; bonematrix += ( float( input.boneweight3 ) / 255.0f ) * BoneMatrices[ input.boneindex3 ]; // World matrix from instance buffer matrix worldMatrixInstance = InstanceLocations[ InstanceID ]; // Transform via combined bones + world matrix output.position = mul(input.position, bonematrix); output.position = mul(output.position, worldMatrixInstance ); // Animate normal the same way output.normal = mul(input.normal, bonematrix); output.normal = mul(output.normal, worldMatrixInstance ); // Camera view output.position = mul(output.position, viewMatrix); float4 cameraPosition = output.position; // vertex color output.vertex_color = input.vertex_color; // billboard? if( flags & PER_MESH_FLAG_BILLBOARD ) { matrix boneWorldMat = mul( bonematrix, worldMatrixInstance ); matrix boneWorldViewMat = mul( boneWorldMat, viewMatrix ); //output.position = input.position + float4( boneWorldMat._41, boneWorldMat._42, boneWorldMat._43, 1.0f ); output.position = input.position + float4( boneWorldViewMat._41, boneWorldViewMat._42, boneWorldViewMat._43, 1.0f ); //output.position = input.position + float4( viewMatrix._41, viewMatrix._42, viewMatrix._43, 1.0f ); } output.position = mul(output.position, projectionMatrix); output.tex = input.tex; // Fog calc output.fogFactor = saturate((fogEnd - cameraPosition.z) / (fogEnd - fogStart)); output.instance = InstanceID; return output; } I am using a y-up system, if it matters.   Please note there are no issues with the shader outside of the billboarding so please no recommendations on other things I can do differently.  I just want to know how to billboard within the context of what you see here.   Thanks..
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!