Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

103 Neutral

About rouncED

  • Rank
  1. thats really cool, you should keep going with this!!! add some simple combat system and chat!
  2. This is how I have been doing it for a few years now. void inverse_project(MAT view, MAT proj, float x, float y, float width, float height, VEC &orig, VEC &dir) { D3DXVECTOR3 vPickRayDir; D3DXVECTOR3 vPickRayOrig; D3DXMATRIX matProj; matProj=proj; // Compute the vector of the pick ray in screen space // this is the magic bit. D3DXVECTOR3 v; v.x = ( ( ( 2.0f * x ) / width) - 1 ) / matProj._11; v.y = -( ( ( 2.0f * y ) / height) - 1 ) / matProj._22; v.z = 1.0f; // Get the inverse view matrix D3DXMATRIX matView, m; matView=view; D3DXMatrixInverse( &m, NULL, &matView ); // Transform the screen space pick ray into 3D space //then this is simply converting it to world space. vPickRayDir.x = v.x*m._11 + v.y*m._21 + v.z*m._31; vPickRayDir.y = v.x*m._12 + v.y*m._22 + v.z*m._32; vPickRayDir.z = v.x*m._13 + v.y*m._23 + v.z*m._33; vPickRayOrig.x = m._41; vPickRayOrig.y = m._42; vPickRayOrig.z = m._43; orig=vPickRayOrig; dir=vPickRayDir; }
  3. rouncED

    dx11 and screen coordinates

    Ah I know what it was! I was making my d3d window slightly bigger than the screen, so it was actually reporting back correct coordinates for how big the actual window was.
  4. rouncED

    dx11 and screen coordinates

    //heres the code that draws the sprite supposedly to the 4 corners of the screen D3D11_MAPPED_SUBRESOURCE mr; dc->Map(screenv,0,D3D11_MAP_WRITE_DISCARD,NULL,&mr); SimpleVertex* v=(SimpleVertex*)mr.pData; v[0].pos=XMFLOAT3(-1,1,z);//((x/scw)*2-1, -((y/sch)*2-1), z); v[1].pos=XMFLOAT3(1,1,z);//(((x+w)/scw)*2-1, -((y/sch)*2-1), z); v[2].pos=XMFLOAT3(1,-1,z);//(((x+w)/scw)*2-1, -(((y+h)/sch)*2-1), z); v[3].pos=XMFLOAT3(-1,-1,z);//((x/scw)*2-1, -(((y+h)/sch)*2-1), z); v[0].Tex=XMFLOAT2(0.0f, 0.0f); v[1].Tex=XMFLOAT2(1.0f, 0.0f); v[2].Tex=XMFLOAT2(1.0f, 1.0f); v[3].Tex=XMFLOAT2(0.0f, 1.0f); dc->Unmap(screenv,0); CB0 cb; cb.wvp=XMMatrixIdentity(); dc->VSSetShader(vs2, NULL, 0); dc->PSSetShader(ps2, NULL, 0); dc->HSSetShader(NULL, NULL, 0); dc->GSSetShader(NULL, NULL, 0); dc->DSSetShader(NULL, NULL, 0); dc->CSSetShader(NULL, NULL, 0); dc->UpdateSubresource(cb0, 0, NULL, &cb, 0, 0 ); dc->VSSetConstantBuffers(0, 1, &cb0); dc->PSSetConstantBuffers(0, 1, &cb0); dc->HSSetConstantBuffers(0, 1, &cb0); dc->DSSetConstantBuffers(0, 1, &cb0); dc->VSSetSamplers(0,1,&sl); dc->PSSetSamplers(0,1,&sl); dc->HSSetSamplers(0,1,&sl); dc->DSSetSamplers(0,1,&sl); dc->PSSetShaderResources(0,1,&t); dc->IASetInputLayout(vl); dc->RSSetState(rstate); // Set index buffer UINT stride = sizeof( SimpleVertex ); UINT offset = 0; dc->IASetVertexBuffers( 0, 1, &screenv, &stride, &offset ); dc->IASetIndexBuffer(screeni, DXGI_FORMAT_R16_UINT, 0); dc->IASetPrimitiveTopology( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST ); dc->DrawIndexed(6,0,0); //and the shader Texture2D txDiffuse : register( t0 ); SamplerState samLinear : register( s0 ); cbuffer cb0 : register( b0 ) { matrix wvp; }; struct VS_INPUT { float4 pos : POSITION; float2 uv : TEXCOORD0; }; struct PS_INPUT { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; }; PS_INPUT VS2(VS_INPUT Input ) { PS_INPUT Output; Output.pos = mul(Input.pos,wvp); Output.uv= Input.uv; return Output; } float4 PS2(PS_INPUT Input ) : SV_TARGET { return txDiffuse.Sample(samLinear, Input.uv).rgba; } what actually happens is it draws a little over horizontally and it draws about 40 pixels over vertically! Ive got no idea why its doing this...
  5. Im trying to draw sprites with direct x 11 right, but for some reason its hanging sprites over the edge of the screen even when their coordinate is exactly (1,-1) or (1,1) shouldnt these 2 coordinates be the corners of the screen exactly?!!? It hangs about a good centimetre over the edge of the screen... If I do the exact same thing in direct x 9 it works, so whats the difference?
  6. Your pretty confused, if you call an x rotation then a y rotation, its not gonna tilt the y rotation by the x rotation, they will both be in world space! What you NEED to do is actually TILT the rotation! Have you tried using general axis rotations? To do that, make an up right and front vector, then if you want to do an x rotation, rotate the model by the up, but also rotate the up right and front vectors at the same time. then if you want to do a y rotation now, use the "rotated right" as the next axis rotation, and i think this will give you something more to what you would desire. Im actually guessing your saying what you want wrong, you dont want to rotate around the world axi, cause thats what your getting now, what you want to do is rotate inside "object space axi" I think you better trust me that rotating an object on the x axis, then rotating it on the y axis WONT tilt the y axis rotation. (in fact im trying to tell you to actually tilt it, because I think its what you want.) And its actually because its NOT tilted that you are finding it in error. [Edited by - rouncED on October 25, 2010 9:35:33 PM]
  7. more info please, ive got no idea.
  8. rouncED

    Generating a Normal Map

    I dont get it, how does it get the blurry light around the outside of the planet?!?!?
  9. rouncED

    Generating a Normal Map

    im on vista with direct x 11, direct x 11 is definitely more stable than it used to be, and it seems to back support well. My video card is a gtx480. To do atmospheric scattering, you colour the black in (the space) with blue depending on how far away it is from the planet surface... its sorta like particles in the air reflecting light that give it its colour. you could quickly do it with a translucent billboard, maybe. I could think of a really slow way to do it, by doing an image space pass, but it would be too slow, might look nice tho. try doing it with a translucent billboard, scale the billboard so it fits exactly around the planet, it gets bigger when its closer to the planet than further away, but the billboard sprite should look like a translucent blue ring, most opaque at the inside ring, totally see through at the outside ring.
  10. rouncED

    Generating a Normal Map

    It worked fine, it was cool! :) I couldnt tell you how to do atmospheric scattering, you need to make it so you can actually go "into" the atmosphere of the planets, so ive got no idea... its sorta like fog you can see through looking into it, but you cant glimpsing it off an angle - And when you go into it, it becomes the sky colour, who the hell knows.
  11. rouncED

    Generating a Normal Map

    I wanna have a go on your demo now, its awesome! It actually looks a lot like the doom3 titlescreen. Now youve got to normal map the ship, need any help? hehe
  12. rouncED

    Generating a Normal Map

    Ah you fixed it! Looks great man! Yeh sometimes I flipped a matrix mul around here and there to get it to work I remember too! Let me see if I can explain object space normals to you. Object space normals are when you literally point in all directions out of the sphere on the normal map instead of plain flat forwards so instead of it being a pale blue it would morph to red and green. Object space normal mapping needs no tangent space, but instead you literally rotate every single normal in the pixel shader when the planet spins instead of rotating the tangent space. The advantage of using tangent space is you could wrap any generic normal map you wanted on the planet and it would twist into a sphere, if you used object space normal mapping you couldnt use any normal map except the custom designed spherical one. [Edited by - rouncED on October 22, 2010 1:03:09 AM]
  13. rouncED

    Generating a Normal Map

    ok np... see u tomorrow?
  14. rouncED

    Generating a Normal Map

    Im not sure, try mucking around with the cross products when it makes the tangent vectors (up, right and normal) I think im about out of ideas now, im not sure what could be going wrong!
  15. rouncED

    Generating a Normal Map

    I consider myself an experienced hobbyest, maybe i could have had a job sometime and still might, but I only ever figured out stuff myself for fun... If you could only render a movie, then id have a better idea! public void CreateSphere(ref VertexPositionNormalUpRightTexture[] vpnt, ref int[] indices, int m_NumSlices, int m_NumStacks, float m_Radius) { int tDiv = m_NumSlices; int pDiv = m_NumStacks; float dt = ((float)Math.PI * 2) / tDiv; float dp = (float)Math.PI / pDiv; int vertex = 0; for (int pi = 0; pi <= pDiv; pi++) { float phi = pi * dp; for (int ti = 0; ti <= tDiv; ti++) { // we want to start the mesh on the x axis float theta = ti * dt; vpnt[vertex].Position = GetPosition(theta, phi, m_Radius); vpnt[vertex].Normal = GetNormal(theta, phi); vpnt[vertex].Texture = GetTextureCoordinate(theta, phi); vertex++; } } int index = 0; for (int pi = 0; pi < pDiv; pi++) { for (int ti = 0; ti < tDiv; ti++) { int x0 = ti; int x1 = (ti + 1); int y0 = pi * (tDiv + 1); int y1 = (pi + 1) * (tDiv + 1); indices[index] = x0 + y0; indices[index + 1] = x0 + y1; indices[index + 2] = x1 + y0; indices[index + 3] = x1 + y0; indices[index + 4] = x0 + y1; indices[index + 5] = x1 + y1; index += 6; } } for (int i = 0; i < vertex; i++) { Vector3.Normalize(ref vpnt.Position, out vpnt.Normal); vpnt.Up = new Vector3(0, 1, 0); if(acosf(Vector3.Dot(vpnt.Up,vpnt.Normal))<0.1f) { vpnt.Up = new Vector3(0, 0, 1); } if(acosf(Vector3.Dot(-vpnt.Up,vpnt.Normal))<0.1f) { vpnt.Up = new Vector3(0, 0, 1); } Vector3 cross = Vector3.Cross(vpnt.Normal, vpnt.Up); Vector3.Normalize(ref cross, out vpnt.Right); vpnt.Up = Vector3.Cross(vpnt.Normal, vpnt.Right); } }
  • 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!