Ebola0001

Member

107

Community Reputation

138 Neutral

• Rank
Member

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. Drawing an Ellipse via its implicit equation in a PIxel Shader

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

11. vertex and pixel shader question

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. best way to make something orbit

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