Advertisement Jump to content
  • Advertisement

Vystrax

Member
  • Content Count

    20
  • Joined

  • Last visited

Community Reputation

122 Neutral

About Vystrax

  • Rank
    Member
  1. Thank You! After switching to my wife's laptop (with a better 3d card, sadly), I got the example to work with the faster method. When I ran the first program on my PC, it rendered a nice, perfectly white square for me. Soo... I had to resort to the slower method to get the same results. But both worked beautifully.
  2. I've been banging my head against this one for too long and it's driving me nuts. The essence of my problem is just how to get alpha blending to work. In its most simple form, I want to blend between two textures based on per-vertex weights. I started by trying to modify existing multitexture programs, but to no avail. This is to blend between two landscape types. For example, given a triangle with corners A,B,C let's say: A.diffuse = D3DCOLOR_RGBA(255,255,255,255) (1.0f - grass) B.diffuse = D3DCOLOR_RGBA(128,128,128,128) (0.5f - blend grass/dirt) C.diffuse = D3DCOLOR_RGBA(0,0,0,0) (0.0f - dirt) struct s_Vertex { float x, y, z; D3DCOLOR dwDiffuse; D3DCOLOR dwSpecular; float tu1, tv1; float tu2, tv2; }; #define VERTEX_FVF=(D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_SPECULAR|D3DFVF_TEX2) I define all the vertices, and in the Render() step: if( SUCCEEDED(g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE)) ) { g_pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); g_pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); } ... // base layer = base texture g_pd3dDevice->SetTextureStageState(0,D3DTSS_TEXCOORDINDEX,0); g_pd3dDevice->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_SELECTARG1); g_pd3dDevice->SetTextureStageState(0,D3DTSS_COLORARG1,D3DTA_TEXTURE); // ???? Maybe want this to be diffuse color, which will blend away // ???? according to diffuse corner weights?? g_pd3dDevice->SetTextureStageState(0,D3DTSS_ALPHAOP,D3DTOP_SELECTARG1); g_pd3dDevice->SetTextureStageState(0,D3DTSS_ALPHAARG1,D3DTA_TEXTURE); ... // second layer = competing texture "poking through" // ???? THIS IS WHERE I BREAK DOWN g_pd3dDevice->SetTextureStageState(1,D3DTSS_TEXCOORDINDEX,1); g_pd3dDevice->SetTextureStageState(1,D3DTSS_COLOROP,D3DTOP_????); g_pd3dDevice->SetTextureStageState(1,D3DTSS_COLORARG1,D3DTA_TEXTURE); g_pd3dDevice->SetTextureStageState(1,D3DTSS_COLORARG1,D3DTA_CURRENT); // I assume the SRC_BLEND and DEST_BLEND will use DIFFUSE and 1-DIFFUSE? g_pd3dDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); g_pd3dDevice->SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE); I can get one or the other to render with a faded corner and overwrite one another in stage 0 or 1, but I'm at a loss for the appropriate colorop/alphaop for stage 1. HELP!!!
  3. Okay. I have the following scenario and I was hoping someone could help me with feedback. I have a tiled outdoor landscape generator working on my PIII 500 with an ancient Voodoo 3 card and DX8.0. For each tile I store the height-based tile type for each corner of the tile. I'm trying to figure the best way to blend the textures. Keep in mind I'm trying to get this thing to run on virtually any 3D card. The way I see it, I have a few options for tiles whose four corners are not identical: 1. Draw the same tile up to four times. If a corner were "grass", the "grass" texture would be drawn with its vertex slightly above the true land height. Risk artifacts(?) 2. Set up 3 or more texture passes with appropriate mask textures. Risk slowdowns and limitations for low-end graphics cards(?) 3. Manually (or using photoshop macros, or even generate code to procedurally) blend between two or three texture types for each scenario. Load many textures on startup. Risk running out of texture memory on low-end graphics cards(?) I'm a little lost as I've read about but never implemented texture blending before.
  4. Vystrax

    Perlin Noise Exposed

    Take any four uniformly distributed numbers and average them. You should indeed get a gaussian distribution. This is what you're basically doing with the 4 perlin corner vectors(uniform) and your DotGrad function. Consider it this way. Generate a random number in the range [0,1]. Say 0.7. You only have a 30.0% chance to land in the range [0.7,1] again. Multiply four 30.0% chances together. You only have a 0.81% chance that you'll land in the upper 30% for all four. Consider also that most of the time this is the desired result. You only want really really tall mountains or really really low valleys less than 1% of the time. If this is not the case and you want truly uniform values, try using a standard Psuedo-random number generator(PRNG) where you feed two input values and get back a predictable result each time. (I would recommend RANROT)
  5. Vystrax

    frustum culling frustration

    Calculating distance from point to plane--> // this only gives true distance if plane is normalized. // n is normal vector. d is distance. inline float plane3::DistPointToPlane( const point3& point ) const { return(point.x*n.x+point.y*n.y+point.z*n.z+d); } But my issue is that the point test never provides any points within the frustum. There's always something with a negative value, as though my camera were disjoint from my view frustum, the right size but in the wrong octant of world space? (especially after looking at the distances.) I'm about to just start randomly feeding coordinates to find out where in the world my frustum went. My matrices should be right because the landscape engine itself is working and I can fly through the world. My world matrix is Identity. View * Projection = Planes in World coordinates? Feed world coordinates to point testing and distance testing against the extracted planes?
  6. Okay, I'm missing something here. I'm TRYING to set up frustum culling for my landscape and having trouble. I have to be doing something wrong. I'm starting out with FOV=PI/3, NEAR=1.0 FAR=800.0 I extracted a projection matrix of: [1.30,0.00,0.00,0.00] [0.00,1.73,0.00,0.00] [0.00,0.00,1.00,1.00] [0.00,0.00,-1.00,0.00] My initial camera/view location is just translated out 5000(+x),5000(+z). Height above landscape is 50. [1.00,0.00,0.00,0.00] [0.00,1.00,0.00,0.00] [0.00,0.00,1.00,0.00] [5000.00,50.00,5000.00,1.00] To create a DirectX frustum, I'm setting Mcombo = Mview * Mprojection ==> [1.30,0.00,0.00,0.00] [0.00,1.73,0.00,0.00] [0.00,0.00,1.00,1.00] [6495.19,86.60,5005.26,5000.00] I extract my planes out of Mcombo: ExtractPlanes( const matrix4 &mat ) { sLeft.n.x=mat._14+mat._11; sLeft.n.y=mat._24+mat._21; sLeft.n.z=mat._34+mat._31; sLeft.d=mat._44+mat._41; sRight.n.x=mat._14-mat._11; sRight.n.y=mat._24-mat._21; sRight.n.z=mat._34-mat._31; sRight.d=mat._44-mat._41; sNear.n.x=mat._13; sNear.n.y=mat._23; sNear.n.z=mat._33; sNear.d=mat._43; sFar.n.x=mat._14-mat._13; sFar.n.y=mat._24-mat._23; sFar.n.z=mat._34-mat._33; sFar.d=mat._44-mat._43; sBottom.n.x=mat._14+mat._12; sBottom.n.y=mat._24+mat._22; sBottom.n.z=mat._34+mat._32; sBottom.d=mat._44+mat._42; sTop.n.x=mat._14-mat._12; sTop.n.y=mat._24-mat._22; sTop.n.z=mat._34-mat._32; sTop.d=mat._44-mat._42; } then I normalize my planes so distance calculations are accurate: void Normalize( ) { sLeft.NormalizePlane(); // divide sRight.NormalizePlane(); sNear.NormalizePlane(); sFar.NormalizePlane(); sBottom.NormalizePlane(); sTop.NormalizePlane(); } // the NormalizePlane function mentioned above. void plane3::NormalizePlane() { float mag; mag = sqrt(n.x * n.x + n.y * n.y + n.z * n.z); n.x = n.x / mag; n.y = n.y / mag; n.z = n.z / mag; d = d / mag; } Then I test to see if individual points are in/out of frustum: inline eLoc plane3::PointLoc( point3 const &point ) const { float fVal = (point * n) + d; if( fVal > EPSILON) { return LOC_FRONT; } if(dp < -EPSILON ) { return LOC_BACK; } return LOC_COPLANAR; // within epsilon of the plane } When I test points however, for some reason it seems horribly wrong. I've been staring at my code for far too long. Sample distances: (which seem FAR too large) point:[5056.00,4128.00] distance to left = 13536.46 distance to right =-2400.41 distance to top = 4151.21 distance to bottom= 4976.79 distance to near = 9127.00 distance to far =-8327.78 The distances between planes seems right, but it's as though I need to invert something? HELP! -Charlie
  • 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!