Ebola0001

Members
  • Content count

    107
  • Joined

  • Last visited

Community Reputation

138 Neutral

About Ebola0001

  • Rank
    Member
  1. Graphics loading problem

    maybe this has to do with "losing" the adapter and needing to release it and reaquire it, I have not played with that code, but i think it might be something to look into
  2. this is the best I could do tonight, I will see if i can refine it later if I feel like it. Time1 advances 0.005f per frame in the program float a = (sin(Time1)+1)/6+0.05; // Semimajor Axis float b = (cos(Time1)+1)/6+0.05; // Semiminor Axis float h = 0.5; // Center X coordinate float k = 0.5; // Center Y coordinate float x = texCoord.x; float y = texCoord.y; float theta = acos((x-h)/a); if (y < k) theta = Pi - theta + Pi; float x2 = h + a * cos(theta); float y2 = k + b * sin(theta); float fEllipse = pow(x-h,2) / (a*a) + pow(y-k,2) / (b*b); float fDistance = abs(1-fEllipse); float fDistance2 = sqrt((x2 - x)*(x2 - x) + (y2-y)*(y2-y)); float4 color; if (fDistance2 <= fOutlineWidth/10) color.x = circleColor.x; else if (fDistance <= fOutlineWidth) color.y = circleColor2.y; else color = cBlack; return color; the green color is your original function, the red addition is my new function, both of them overlapping make a fairly decent ellipse, but the smoothing function as you wrote it doesn't work on my addition because the coordinates go screwy on the left and right extremes of the ellipse. program and fx file anyway hope this helps
  3. Float to pixel - Width

    well if the point sprite is 0.6f wide in world space, just generate a point in the upper left and lower right in world space, then transform those points as discussed in the other thread
  4. Perlin Noise

    if you are not or can not use any vertex or pixel shaders, your options are blending several textures together with noise at varying resolutions. sorry but without the shaders that is all you got i think
  5. Float to pixel

    1) In testing, Yes the project function will return the same value with NULL as with an identity matrix. 2) Yes the first call is only to figure out if the point is in front of the camera, if you don't care then you can use the second call only oh and your earlier question about an identity matrix. an identity matrix of "4x4" size is 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 what this means is ------Inputs------Output-- 1x + 0y + 0z + 0w = 1x 0x + 1y + 0z + 0w = 1y 0x + 0y + 1z + 0w = 1z 0x + 0y + 0z + 1w = 1w so no matter what the input it is just copied to the output [Edited by - Ebola0001 on August 17, 2008 4:41:01 PM]
  6. vertex and pixel shader question

    that is what the sample did, they set the view and projection with the fixed pipeline, then when they set the matrix in the .fx file they did this float4x4 matViewProjection : ViewProjection; they never explicitly setmatrix for it so I assume the :ViewProjection copies the value in automatically however I have found something else peculiar. I have another sample from code sampler, called Dx9_hlsl_fx_simple the precompiled .exe runs fine and shows the effect.. but when I compile their code unchanged it complains that 1_x is no longer supported and to change to 2_0 or 3_0. in doing that is spits out a black render with no changes to their code other than the 1_1 compile target here is their zipfile with the sample http://www.woodrell.com/joe/dx9_hlsl_fx_simple.zip
  7. Float to pixel

    well it takes A point in 3d and transforms it into screen space. so for a mesh, if you want the position of each vertex, you would have to pass each position separately, if you wanted the center of the mesh, well that is just a single point to transform
  8. Float to pixel

    The same way you transform the 3d points into screen space for rendering, but with a twist. bool IsVisible = false; D3DXVECTOR3 ScreenPos; D3DVIEWPORT9 VP; D3DXMATRIX V; D3DXMATRIX P; D3DXMATRIX Ident; d3ddev->GetViewport(&VP); d3ddev->GetTransform(D3DTS_VIEW,&V); d3ddev->GetTransform(D3DTS_PROJECTION,&P); D3DXMatrixIdentity( &Ident ); D3DXVec3Project( &ScreenPos, &D3DXVECTOR3 (Position.x,Position.y,Position.z), &VP, &Ident, &V, &Ident ); if ( ScreenPos.z > 0) IsVisible = true; else IsVisible = false; D3DXVec3Project( &ScreenPos, &D3DXVECTOR3 (Position.x,Position.y,Position.z), &VP, &P, &V, &Ident ); The first call transforms the the 3D point into the Viewport using ONLY the view matrix. This output position's 'Z' value will tell you if the point is in front of the camera or behind it. Greater than 1 and the point is in front of the camera This is important because the screen position returned by the projection will return a point on the screen even if the point is behind the camera, because it is working with the ray to the point. The second call transforms the 3D point into the Viewport using the View AND Projection matrices, but NOT the world matrix. this will return the screen position of that point in pixels. Now remember, the 0,0 point is in the upper left of the screen. hope this was usefull
  9. vertex and pixel shader question

    well in looking up hoe to setup an D3DXEffect interface. I believe i have mimicked every call from the sample code, but i still just get a black render Here is the sample code from the tutorial void render( void ) { g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_COLORVALUE(0.0f,0.0f,0.0f,1.0f), 1.0f, 0 ); g_pd3dDevice->BeginScene(); D3DXMATRIX matTrans; D3DXMATRIX matRot; D3DXMatrixTranslation( &matTrans, 0.0f, 0.0f, 4.0f ); D3DXMatrixRotationYawPitchRoll( &matRot, D3DXToRadian(g_fSpinX), D3DXToRadian(g_fSpinY), 0.0f ); g_matWorld = matRot * matTrans; g_pd3dDevice->SetTransform( D3DTS_WORLD, &g_matWorld ); g_pEffect->SetTechnique( "TwoPassTextureBlend" ); g_pEffect->SetTexture( "texture0", g_pTexture_0 ); g_pEffect->SetTexture( "texture1", g_pTexture_1 ); UINT uPasses; g_pEffect->Begin( &uPasses, 0 ); g_pEffect->BeginPass( 0 ); g_pd3dDevice->SetStreamSource( 0, g_pVertexBuffer, 0, sizeof(Vertex) ); g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX ); g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 ); g_pEffect->EndPass(); g_pEffect->End(); g_pd3dDevice->EndScene(); g_pd3dDevice->Present( NULL, NULL, NULL, NULL ); } so the steps they do. 1)Call Device->Begin Scene 2)Set Matrices using Device->SetTransform 3)Set the Technique 4)Set the Textures with Effect->SetTexture 5)Call Effect->Begin 6)Call Effect->Begin Pass ('pass number') 7)Render using Device->Render code 8)Call Effect->End Pass 9)Call Effect->End 10)Call Device->EndScene 11)Call Device->Present here is my code, all I get is a black render. d3ddev->BeginScene(); d3ddev->SetTransform(D3DTS_VIEW, &(matView)); d3ddev->SetTransform(D3DTS_PROJECTION, &matProjection); d3ddev->SetTransform(D3DTS_WORLD, &(matScale*matRotateX*matRotateY*matRotateZ*matTranslate)); g_pEffect->SetTechnique( "Sun" ); g_pEffect->SetTexture( "base_Tex", texture[16] ); UINT Passes; g_pEffect->Begin( &Passes, 0 ); g_pEffect->BeginPass( 0 ); Galaxy->DrawSubset(0); g_pEffect->EndPass( ); g_pEffect->End( ); d3ddev->EndScene(); d3ddev->Present(NULL, NULL, NULL, NULL); here is my .fx file, minimal required, built with rendermonkey using their base "textured" setup and modified a tiny bit //--------------------------------------------------------------// // Textured //--------------------------------------------------------------// //--------------------------------------------------------------// // Pass 0 //--------------------------------------------------------------// float4x4 matViewProjection : ViewProjection; struct VS_INPUT { float4 Position : POSITION0; float2 Texcoord : TEXCOORD0; }; struct VS_OUTPUT { float4 Position : POSITION0; float2 Texcoord : TEXCOORD0; }; VS_OUTPUT Textured_Pass_0_Vertex_Shader_vs_main( VS_INPUT Input ) { VS_OUTPUT Output; Output.Position = mul( Input.Position, matViewProjection ); Output.Texcoord = Input.Texcoord; return( Output ); } texture base_Tex; sampler2D baseMap = sampler_state { Texture = (base_Tex); ADDRESSU = WRAP; ADDRESSV = WRAP; MINFILTER = LINEAR; MAGFILTER = LINEAR; }; struct PS_INPUT { float2 Texcoord : TEXCOORD0; }; float4 Textured_Pass_0_Pixel_Shader_ps_main( PS_INPUT Input ) : COLOR0 { return tex2D( baseMap, Input.Texcoord ); } //--------------------------------------------------------------// // Technique Section for Textured //--------------------------------------------------------------// technique Sun { pass Pass_0 { VertexShader = compile vs_2_0 Textured_Pass_0_Vertex_Shader_vs_main(); PixelShader = compile ps_2_0 Textured_Pass_0_Pixel_Shader_ps_main(); } } thanks again guys for putting up with me
  10. vertex and pixel shader question

    ok, now i can't get anything to render, this is frustrating. ANYWAY. here is the rendering code from the tutorial (link) app.getDevice()->BeginScene(); // communicate with shaders (NEW) D3DXMATRIXA16 matWorld, matView, matProj; app.getDevice()->GetTransform(D3DTS_WORLD, &matWorld); app.getDevice()->GetTransform(D3DTS_VIEW, &matView); app.getDevice()->GetTransform(D3DTS_PROJECTION, &matProj); D3DXMATRIXA16 matWorldViewProj = matWorld * matView * matProj; constantTable->SetMatrix(app.getDevice(), "WorldViewProj", &matWorldViewProj); // render scene with shaders (NEW) app.getDevice()->SetVertexDeclaration(vertexDecl); app.getDevice()->SetVertexShader(vertexShader); app.getDevice()->SetPixelShader(pixelShader); app.getDevice()->SetStreamSource(0, quadVB, 0, sizeof(D3DVERTEX)); app.getDevice()->SetTexture(0, quadTexture); app.getDevice()->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); app.getDevice()->EndScene(); app.getDevice()->Present(0, 0, 0, 0); the code as written in their sample does compile and run, so I know it works. however they never set anything to the matrices, so i think they are not doing any transforms. I have tried to mimic this code copying my matrices in, and not calling "SetTransform" for view, projection, and world, instead copying those matrices as they would have been called without the shaders. but all I get is a black render no matter what I do now. ViewportInfo.Width = SCREEN_WIDTH; ViewportInfo.Height = SCREEN_HEIGHT; ViewportInfo.X = 0; ViewportInfo.Y = 0; d3ddev->SetViewport(&ViewportInfo); d3ddev->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB( 212, 208, 200), 1.0f, 0); d3ddev->BeginScene(); D3DXQuaternionRotationMatrix(&matViewQuatIn,&matView); //Step 1 D3DXQuaternionRotationYawPitchRoll(&matViewQuat,CamYaw,CamPitch,CamRoll); //Step 2 D3DXMatrixRotationQuaternion(&matViewChange,&matViewQuat); D3DXQuaternionMultiply(&matViewQuatOut,&matViewQuatIn,&matViewQuat); //Step 3 D3DXQuaternionNormalize(&matViewQuatOut, &matViewQuatOut); //Step 4 D3DXMatrixRotationQuaternion(&matViewOut,&matViewQuatOut); //Step 5 D3DXMatrixTranslation(&matView, //Step 6 CameraPosition.x, CameraPosition.y, CameraPosition.z); matView = matView * matViewOut; //Step 7 //d3ddev->SetTransform(D3DTS_VIEW, &(matView)); //Step 8 matView2 = matView; CameraFront = D3DXVECTOR3 (0.0f,0.0f,1.0f); CameraRight = D3DXVECTOR3 (1.0f,0.0f,0.0f); CameraUp = D3DXVECTOR3 (0.0f,-1.0f,0.0f); TempDeterminant = D3DXMatrixDeterminant(&matViewOut); D3DXMatrixInverse(&TempCameraMat, &TempDeterminant, &matViewOut); D3DXVec3Transform(&TempCameraVec, &CameraFront, &TempCameraMat); CameraFront = D3DXVECTOR3 (TempCameraVec.x,TempCameraVec.y,TempCameraVec.z); D3DXVec3Transform(&TempCameraVec, &CameraRight, &TempCameraMat); CameraRight = D3DXVECTOR3 (TempCameraVec.x,TempCameraVec.y,TempCameraVec.z); D3DXVec3Transform(&TempCameraVec, &CameraUp, &TempCameraMat); CameraUp = D3DXVECTOR3 (TempCameraVec.x,TempCameraVec.y,TempCameraVec.z); D3DXMATRIX matProjection; // the projection transform matrix D3DXMatrixPerspectiveFovLH(&matProjection, D3DXToRadian(CamFOV), // the horizontal field of view (SCREEN_HEIGHT/.75)/SCREEN_HEIGHT, // the aspect ratio 0.001f, // the near view-plane 3000.0f); // the far view-plane //d3ddev->SetTransform(D3DTS_PROJECTION, &matProjection); // set the projection matProj2 = matProjection; D3DXMatrixScaling(&matScale, 10, 10, 10); D3DXMatrixTranslation(&matTranslate, -CameraPosition.x, -CameraPosition.y, -CameraPosition.z); D3DXMatrixRotationX(&matRotateX, GalaxyXAxis); // the rotation matrix D3DXMatrixRotationY(&matRotateY, GalaxyYAxis); // the rotation matrix D3DXMatrixRotationZ(&matRotateZ, 0); // the rotation matrix //d3ddev->SetTransform(D3DTS_WORLD, &(matScale*matRotateX*matRotateY*matRotateZ*matTranslate)); // set the world transform; matWorld2 = matScale*matRotateX*matRotateY*matRotateZ*matTranslate; d3ddev->SetMaterial(&material[0]); // set the material for the subset d3ddev->SetRenderState(D3DRS_LIGHTING, FALSE); // turn off the 3D lighting for the background Blend = 255; GalaxyBlend=D3DCOLOR_ARGB(Blend,Blend,Blend,Blend); d3ddev->SetRenderState(D3DRS_BLENDFACTOR, GalaxyBlend); d3ddev->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_BLENDFACTOR); d3ddev->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVBLENDFACTOR); ViewportInfo.Width = 1019; ViewportInfo.Height = 768; ViewportInfo.X = 256; ViewportInfo.Y = 5; d3ddev->SetViewport(&ViewportInfo); d3ddev->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB( 0, 0, 0), 1.0f, 0); CamFOV = 60; d3ddev->GetTransform(D3DTS_WORLD, &matWorld2); d3ddev->GetTransform(D3DTS_VIEW, &matView2); d3ddev->GetTransform(D3DTS_PROJECTION, &matProj2); D3DXMATRIXA16 matWorldViewProj = matWorld2 * matView2 * matProj2; constantTable->SetMatrix(d3ddev, "WorldViewProj", &matWorldViewProj); constantTable->SetFloat(d3ddev,"ColorIn1", ShaderColor.w); constantTable->SetFloat(d3ddev,"ColorIn2", ShaderColor.x); constantTable->SetFloat(d3ddev,"ColorIn3", ShaderColor.y); constantTable->SetFloat(d3ddev,"AlphaIn1", ShaderColor.z); d3ddev->SetVertexDeclaration(vertexDecl); d3ddev->SetVertexShader(vertexShader); d3ddev->SetPixelShader(pixelShader); d3ddev->SetTexture(0, texture[1]); Galaxy->DrawSubset(0); //draw Galaxy what it should look like without the shader modifications I set the viewport 4 times to render the 3 sections and the background, although the last two sections are commented out in the code right now link to the unmodified render function anyway any help would be appreciated, I would like to get shaders working at some time :) thanks
  11. OK so after looking at several tutorials, I have gotten my little simulation rendering with them. however the problem I am having is that not everything rendering when they are enabled the render calls buried in my class are not drawing to the screen..., would there be a reason that the SetPixelShader, and SetVertexShader would not get carried into the class when I pass it the render device?, or how would I have to pass them in and set them in the class manually?
  12. best way to make something orbit

    the planets will have ships traveling to and from them
  13. ok here is my question... I have a starfield that has 300 or so stars put in random positions within a cube of space. I want to place planets orbiting those stars. I see two ways of doing this, 1) Modifying the world matrix Normal world matrix for stars Scale*Rotate*Position Planet Matrix Scale*Rotate*OrbitDistance*OrbitRotation*Position 2) Calculating the position externally and just updating its position manually Planet Position X = (Cos(OrbitRotation)*OrbitDistance)+StarPositionX Planet Position Y = (Sin(OrbitRotation)*OrbitDistance)+StarPositionY Planet Position Z = (Sin(OrbitRotation)*OffPlane)+StarPositionZ or somesuch both of these should yield an orbit, would there be an atvantage to one over the other? oh I should also say I have experimented with dynamic orbit with gravity but it takes alot of tuning to get a stable orbit. [Edited by - Ebola0001 on August 10, 2008 4:43:54 PM]
  14. I should know this

    geex. I should have been able to see that, my mind got locked into trying to figure out the square root thing... thank you Sneftel :)
  15. Amplitude of Sine wave combinations

    specifically it never touches 3 anyway if you can precalculate the number outside the program, look into http://www.graphcalc.com/ its free and has decent graphing capability (what I used to make the graphs for the picture, and has the ability to calculate the min / max of a function anyway, just the information I have