Jump to content
  • Advertisement

terrysworkstations

Member
  • Content Count

    29
  • Joined

  • Last visited

Everything posted by terrysworkstations

  1. terrysworkstations

    Projecting a texture

    Update! Everything is almost working. Getting weird effect when getting camera close to sphere. As in the picture. Why would this be happinging? Any ideas? The only thing I can think of is the depth map is messed up.??????? Here is my code. DrawGeoSphere() { md3dImmediateContext->IASetInputLayout(InputLayouts::Basic32); md3dImmediateContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); UINT stride = sizeof(Vertex::Basic32); UINT offset = 0; XMMATRIX view = XMLoadFloat4x4(&mView); XMMATRIX proj = XMLoadFloat4x4(&mProj); XMMATRIX viewProj = view*proj; ID3DX11EffectTechnique* activeTech = Effects::BasicFX->NormalScene; D3DX11_TECHNIQUE_DESC techDesc; activeTech->GetDesc( &techDesc ); for(UINT p = 0; p < techDesc.Passes; ++p) { md3dImmediateContext->IASetVertexBuffers(0, 1, &mBoxVB2, &stride, &offset); md3dImmediateContext->IASetIndexBuffer(mBoxIB2, DXGI_FORMAT_R32_UINT, 0); // Draw the box. XMMATRIX world = XMLoadFloat4x4(&mBoxWorld); XMMATRIX Correction( 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, -0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.5f, 0.5f, 0.0f, 1.0f); XMMATRIX worldInvTranspose = MathHelper::InverseTranspose(world); XMMATRIX worldViewProj = world*view*proj; XMMATRIX projectiveTextureMatrix = world * Projector->view() * Projector->proj() * Correction; Effects::BasicFX->SetWorld(world); Effects::BasicFX->SetWorldInvTranspose(worldInvTranspose); Effects::BasicFX->SetWorldViewProj(worldViewProj); Effects::BasicFX->SetTexTransform(XMLoadFloat4x4(&mTexTransform)); Effects::BasicFX->SetMaterial(mBoxMat); Effects::BasicFX->SetDiffuseMap(mDiffuseMapSRV); Effects::BasicFX->SetProjMap(mDiffuseMapSRV2); Effects::BasicFX->SetprojectiveTextureMatrix(projectiveTextureMatrix); Effects::BasicFX->SetDepthMap(mOutputTexture2); activeTech->GetPassByIndex(p)->Apply(0, md3dImmediateContext); md3dImmediateContext->DrawIndexed(mBoxIndexCount, mBoxIndexOffset, mBoxVertexOffset); } } Thnx for helping
  2. terrysworkstations

    Projecting a texture

    *My Solution, Crazy cdn The near plane adjustment fixed it. A near plane of 0.1.Now no intersecting the sphere.
  3. terrysworkstations

    Projecting a texture

    As the camera gets close to the sphere, the projection does not get occluded by the sphere. There should remain a occlusion but there is a projection on the back.
  4. terrysworkstations

    Projecting a texture

    Updated! Has anyone ever had this problem?
  5. terrysworkstations

    Post Processing on quads

    Im doing post processing which involves drawing on quads. Im doing distortion. Like a haze from a fire. First, draw a distortion map to a quad. Next draw a normal scene to a quad. Then composite them together in the shader. Code is below the picture to see what im talking about. As in the picture, I turned the box so it would be in front of the haze. Shouldn't see the haze. but it is still poking through. How should I solve this problem? //CUT OUT MASK md3dImmediateContext->OMSetRenderTargets(1, &first.mRenderTargetView, first.GetDSV()); md3dImmediateContext->ClearRenderTargetView( first.GetRTV(), reinterpret_cast<const float*>(&Colors::Black)); md3dImmediateContext->ClearDepthStencilView(first.GetDSV(), D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0); md3dImmediateContext->IASetInputLayout(InputLayouts::Basic32); md3dImmediateContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); UINT stride = sizeof(Vertex::Basic32); UINT offset = 0; XMMATRIX view = XMLoadFloat4x4(&mView); XMMATRIX proj = XMLoadFloat4x4(&mProj); XMMATRIX viewProj = view*proj; // Set per frame constants. Effects::BasicFX->SetDirLights(mDirLights); Effects::BasicFX->SetEyePosW(mEyePosW); ID3DX11EffectTechnique* activeTech = Effects::DistortionFX->cutout; D3DX11_TECHNIQUE_DESC techDesc; activeTech->GetDesc( &techDesc ); for(UINT p = 0; p < techDesc.Passes; ++p) { md3dImmediateContext->IASetVertexBuffers(0, 1, &mBoxVB, &stride, &offset); md3dImmediateContext->IASetIndexBuffer(mBoxIB, DXGI_FORMAT_R32_UINT, 0); // Draw the box. XMMATRIX world = XMLoadFloat4x4(&mBoxWorld); XMMATRIX worldInvTranspose = MathHelper::InverseTranspose(world); XMMATRIX worldViewProj = world*view*proj; Effects::DistortionFX->SetWorldViewProj(worldViewProj); Effects::DistortionFX->SetDiffuseMap2(mDiffuseMapSRV2); activeTech->GetPassByIndex(p)->Apply(0, md3dImmediateContext); md3dImmediateContext->DrawIndexed(mBoxIndexCount, mBoxIndexOffset, mBoxVertexOffset); } md3dImmediateContext->OMSetRenderTargets(1, &mRenderTargetView, mDepthStencilView); md3dImmediateContext->ClearRenderTargetView( mRenderTargetView, reinterpret_cast<const float*>(&Colors::Black)); md3dImmediateContext->ClearDepthStencilView(mDepthStencilView, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0); md3dImmediateContext->OMSetRenderTargets(1, &second.mRenderTargetView, second.GetDSV()); md3dImmediateContext->ClearRenderTargetView( second.GetRTV(), reinterpret_cast<const float*>(&Colors::LightSteelBlue)); md3dImmediateContext->ClearDepthStencilView(second.GetDSV(), D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0); //NORMAL SCENE TO QUAD md3dImmediateContext->IASetInputLayout(InputLayouts::Basic32); md3dImmediateContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); stride = sizeof(Vertex::Basic32); offset = 0; view = XMLoadFloat4x4(&mView); proj = XMLoadFloat4x4(&mProj); viewProj = view*proj; // Set per frame constants. Effects::BasicFX->SetDirLights(mDirLights); Effects::BasicFX->SetEyePosW(mEyePosW); activeTech = Effects::BasicFX->Light2TexTech; activeTech->GetDesc( &techDesc ); for(UINT p = 0; p < techDesc.Passes; ++p) { md3dImmediateContext->IASetVertexBuffers(0, 1, &mBoxVB2, &stride, &offset); md3dImmediateContext->IASetIndexBuffer(mBoxIB2, DXGI_FORMAT_R32_UINT, 0); // Draw the box. XMMATRIX world = XMLoadFloat4x4(&mBoxWorld); world *= XMMatrixTranslation(-2,0,0); XMMATRIX worldInvTranspose = MathHelper::InverseTranspose(world); XMMATRIX worldViewProj = world*view*proj; Effects::BasicFX->SetWorld(world); Effects::BasicFX->SetWorldInvTranspose(worldInvTranspose); Effects::BasicFX->SetWorldViewProj(worldViewProj); Effects::BasicFX->SetTexTransform(XMLoadFloat4x4(&mTexTransform)); Effects::BasicFX->SetMaterial(mBoxMat); Effects::BasicFX->SetDiffuseMap(mDiffuseMapSRV); activeTech->GetPassByIndex(p)->Apply(0, md3dImmediateContext); md3dImmediateContext->DrawIndexed(mBoxIndexCount, mBoxIndexOffset, mBoxVertexOffset); } md3dImmediateContext->OMSetRenderTargets(1, &mRenderTargetView, mDepthStencilView); md3dImmediateContext->ClearRenderTargetView( mRenderTargetView, reinterpret_cast<const float*>(&Colors::Black)); md3dImmediateContext->ClearDepthStencilView(mDepthStencilView, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0); //COMPOSITE TEH QUADS TOGETHING FILTERING OUT THE HAZE AND NORMAL IMAGE DrawCompositeQuad(); HR(mSwapChain->Present(0, 0)); And the shader /************* Resources *************/ static const float ZeroCorrection = 0.5f / 255.0f; float4x4 gWorldViewProj; cbuffer CBufferPerObjectComposite { float DisplacementScale = 3.0f; float haze = 0.0f; } Texture2D SceneTexture; Texture2D DistortionMap; SamplerState TrilinearSampler { Filter = MIN_MAG_MIP_LINEAR; AddressU = CLAMP; AddressV = CLAMP; }; struct VertexIn { float3 PosL : POSITION; float3 NormalL : NORMAL; float2 Tex : TEXCOORD; }; struct VertexOut { float4 PosH : SV_POSITION; float2 Tex : TEXCOORD; }; /************* Cutout *************/ VertexOut VS(VertexIn vin) { VertexOut vout; vout.PosH = mul(float4(vin.PosL, 1.0f), gWorldViewProj); vout.Tex = vin.Tex; return vout; } float4 PS(VertexOut pin) : SV_Target { float2 displacement = DistortionMap.Sample(TrilinearSampler, pin.Tex).xy; return float4(displacement.xy, 0, 1); } /************* Compositing *************/ VertexOut VS2(VertexIn vin) { VertexOut vout; vout.PosH = mul(float4(vin.PosL, 1.0f), gWorldViewProj); vout.Tex = vin.Tex; return vout; } float4 PS2(VertexOut pin) : SV_Target { float4 OUT = (float4)0; float2 displacement = DistortionMap.Sample(TrilinearSampler, pin.Tex).xy; if (displacement.x == 0 && displacement.y == 0) { OUT = SceneTexture.Sample(TrilinearSampler, pin.Tex); } else { displacement -= 0.5f + ZeroCorrection; OUT = SceneTexture.Sample(TrilinearSampler, pin.Tex + (cos(haze) * displacement)); } return OUT; } /************* Techniques *************/ technique11 displacement_cutout { pass p0 { SetVertexShader(CompileShader(vs_5_0, VS())); SetGeometryShader(NULL); SetPixelShader(CompileShader(ps_5_0, PS())); } } technique11 distortion_composite { pass p0 { SetVertexShader(CompileShader(vs_5_0, VS2())); SetGeometryShader(NULL); SetPixelShader(CompileShader(ps_5_0, PS2())); } } -do=add#.url
  6. terrysworkstations

    Post Processing on quads

    Alright, running good.
  7. terrysworkstations

    Post Processing on quads

    Ok, so depth is needed. I need something specific. Anyone? I tried OMSetDepthStencilState with DepthEnable to true but still the haze is in front of box. here is my composite function if needed. DrawCompositeQuad() { md3dImmediateContext->RSSetViewports(1, &mScreenViewport); UINT stride = sizeof(Vertex::Basic32); UINT offset = 0; md3dImmediateContext->IASetInputLayout(InputLayouts::Basic32); md3dImmediateContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); md3dImmediateContext->IASetVertexBuffers(0, 1, &mScreenQuadVB, &stride, &offset); md3dImmediateContext->IASetIndexBuffer(mScreenQuadIB, DXGI_FORMAT_R32_UINT, 0); // Scale and shift quad to lower-right corner. XMMATRIX world( 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f); ID3DX11EffectTechnique* tech = Effects::DistortionFX->composite; D3DX11_TECHNIQUE_DESC techDesc; tech->GetDesc( &techDesc ); for(UINT p = 0; p < techDesc.Passes; ++p) { Effects::DistortionFX->SetWorldViewProj(world); Effects::DistortionFX->SetDiffuseMap(second.GetSRV()); //normal scene quad Effects::DistortionFX->SetDiffuseMap2(first.GetSRV()); //cutout quad Effects::DistortionFX->SetHaze(mTimer.TotalTime()); tech->GetPassByIndex(p)->Apply(p, md3dImmediateContext); md3dImmediateContext->DrawIndexed(6, 0, 0); } }
  8. terrysworkstations

    Camera on Vehicle

    I want to attach a camera on a vehicle like so that it will be in the cockpit of the car. I tried messing around with the target position of the view camera. I know there is a current position and target in a view matrix. So I multiplied x and z components of target(view matrix) by 100 to give farther viewing capabilities. This did not work so I was wondering how to attach a a view camera to a vehicle. I just need a general idea on how to do it. | / | / | / CurrentPosition --*100--->target position View Matrix thank you
  9. terrysworkstations

    Shader Resource Binding

    Hello, I am trying to set some shader values in a cbuffer. Im not getting any response or values. My code is: cbuffer MatrixBuffer : register(b0) { float4 test; }; ------------------------------------------------- #pragma pack(push,1) struct CB_GBUFFER_UNPACK { D3DXVECTOR4 test; }; #pragma pack(pop) ------------------------------------------------- D3D11_BUFFER_DESC cbDesc; ZeroMemory( &cbDesc, sizeof(cbDesc) ); cbDesc.Usage = D3D11_USAGE_DYNAMIC; cbDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; cbDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; cbDesc.ByteWidth = sizeof( CB_GBUFFER_UNPACK ); device->CreateBuffer( &cbDesc, NULL, &m_pGBufferUnpackCB ); D3D11_MAPPED_SUBRESOURCE MappedResource; ic->Map( m_pGBufferUnpackCB, 0, D3D11_MAP_WRITE_DISCARD, 0, &MappedResource ); CB_GBUFFER_UNPACK* pGBufferUnpackCB = ( CB_GBUFFER_UNPACK* )MappedResource.pData; pGBufferUnpackCB->test.x = 10.0f; pGBufferUnpackCB->test.y = 10.0f; pGBufferUnpackCB->test.z = 10.0f; pGBufferUnpackCB->test.w = 0.0f; ic->Unmap( m_pGBufferUnpackCB, 0 ); ic->PSSetConstantBuffers( 0, 1, &m_pGBufferUnpackCB ); What is wrong?
  10. terrysworkstations

    Assimp Object

    Ok seem to get the distortion working now. No stretching. Is there a way to invert indices on assimp?
  11. terrysworkstations

    Assimp Object

    I switched to Assimp for loading models in directx 11. The image seems to strectch and stuff for some reason.In the picture , the tail like gets real big and the front of the image gets smaller when it gets closer to the camera than it should be. Does anyone know why this Is happening. Also I can see through the fish on certain angles. Does this have to do with left/right handed coordinate systems?
  12. terrysworkstations

    Bone offsets Matrix

    Trying to get Bone Offsets. I have blend weights and indices. How can I get bone offsets.
  13. Im downloading .obj to put in a game. I have to rotate and flip the texture for it to look right on the object! So when there is text on the object, it will be backwards. Im in Blender. How can I fix this issue? Im in directx 11 also
  14. terrysworkstations

    Have to rotate 180 and flip horizontal to work

    I solved it. Thx
  15. terrysworkstations

    Textures in Directx 11

    Im in DirectX 11 using the D3DX11CreateShaderResourceViewFromFile for textures. I have to rotate texture file 180 and flip horizontal in Mspaint for the texture to fit on the object. SO when I have a .obj object with text, it will be backwards like in the image. I have to rotate and flip with all objects that have textures.Does anyone know how to fix the issue?
  16. terrysworkstations

    Textures in Directx 11

    Alright h8cplusplusGuru, got it. thx
  17. terrysworkstations

    Textures in Directx 11

    I still cannot get it to work even after the steps above. BTW, im using blender.
  18. terrysworkstations

    Textures in Directx 11

    I use the regular image now(not rotated or flipped), and negated the x. Did not work though. I negated the y uv and almost works accept as seen, the text is backwards.
  19. terrysworkstations

    System memory copy of vertices/mesh

    I needed a system memory copy of the vertices for AABB Collision so I can update there min/max because I only have static vertices access. How can I do this. Im in directx 11. c++. As my object translates, I need to calculale the new AABB min/max and I cant get to the vertices. void IvAABB::Set( const IvPoint3* points, unsigned int numPoints) { ASSERT( points); // compute minimal and maximal bounds mMinima.Set(points[0]); mMaxima.Set(points[0]); for (unsigned int i = 1; i < numPoints; ++i) { if (points.x < mMinima.x) mMinima.x = points.x; else if (points.x > mMaxima.x) mMaxima.x = points.x; if (points.y < mMinima.y) mMinima.y = points.y; else if (points.y > mMaxima.y) mMaxima.y = points.y; if (points.z < mMinima.z) mMinima.z = points.z; else if (points.z > mMaxima.z) mMaxima.z = points.z; } }
  20. I tried to make two spheres with bounding sphere to detect collision so they stop when they collide. But it seems that im having a precision issue. They stey stuck together because of small decimal keeping it stuck. Is there a way around this? Since they are in a 3d space, adding or subtracting a little off seems impossible and expensive. How can I solve these precision issues? The code I used. oldleftright = leftright, oldupdown = updown; if(GetAsyncKeyState(VK_RIGHT)) leftright += 0.0001; if(GetAsyncKeyState(VK_LEFT)) leftright -= 0.0001; if(GetAsyncKeyState(VK_DOWN)) updown -= 0.0001; if(GetAsyncKeyState(VK_UP)) updown += 0.0001; collide = test.Intersect(test2); if (collide) { leftright = oldleftright; updown = oldupdown; } collide = false;
  21. terrysworkstations

    Precision Problems with bouding sphere

    Alright, I got to work. thx
  22. terrysworkstations

    Bounding Sphere for collision Detection

    Alright _Silence_,MarcusASeth, got it to collide right. Thx
  23. I want to know the steps so I can create a bounding sphere on a object so when I get close, it will collide and will not intersect the object. I think my main question is..Will I get the distance of the radius and the center of my object to detect this? Second, do I run this function below on all the vertices of the object? I just need the steps. The code snippet I got is: void IvBoundingSphere::Set( const IvVector3* points, unsigned int numPoints ) { ASSERT( points ); // compute minimal and maximal bounds IvVector3 min(points[0]), max(points[0]); unsigned int i; for ( i = 1; i < numPoints; ++i ) { if (points.x < min.x) min.x = points.x; else if (points.x > max.x ) max.x = points.x; if (points.y < min.y) min.y = points.y; else if (points.y > max.y ) max.y = points.y; if (points.z < min.z) min.z = points.z; else if (points.z > max.z ) max.z = points.z; } // compute center and radius mCenter = 0.5f*(min + max); float maxDistance = ::DistanceSquared( mCenter, points[0] ); for ( i = 1; i < numPoints; ++i ) { float dist = ::DistanceSquared( mCenter, points ); if (dist > maxDistance) maxDistance = dist; } mRadius = ::IvSqrt( maxDistance ); } Just need a basic idea on how to do this. Thank you
  24. terrysworkstations

    Particle system

    Im trying to do some particle like system of a disc like shape. More of a cube shape comes out though. Vertex vertices[1500]; for (unsigned int i = 0; i < 1500; ++i) { vertices.Color = (const float*)&Colors::Red; vertices.Pos.x = GenSpherePointCorrect().x; vertices.Pos.y = GenSpherePointCorrect().y; vertices.Pos.z = GenSpherePointCorrect().z; } s GenSpherePointCorrect() { float r = IvSqrt(rng.RandomFloat()); float theta = kTwoPI*rng.RandomFloat(); float sintheta, costheta; IvSinCos(theta, sintheta, costheta); Vector3 randomPos(2.0f*r*costheta, 2.0f*r*sintheta, 0.0f); return randomPos; }
  25. terrysworkstations

    Particle system

    Alright KburtHard84,Zao, I seem to get it working now. Thx
  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!