Advertisement Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

130 Neutral

About kajjait

  • Rank
  1. ahh yes, It's been a while since i've used SDL but i would assume that the void pointer to your pixels is the actual image data. its void because of varrying pixel formats, 8 bit 16 bit , whatever. i would reccomend casting it to a data type of that size. for example if 8bit, you could just use an unsigned char to represent each pixel. if its 16 bits per pixel, you could do typedef struct MyPixel { unsigned short r; unsigned short g; unsigned short b; //unsigned short a; //alpha component if needed; } for 32 bits per pixel, use an unsigned int. and i'm unsigned because i'm assuming these will never be negative. it probably doesnt matter if signed or unsigned. this way you can use a for loop, and indices to iterate through your pixel data. just cast to your new type MyPixel* pixelData= (pixelData *) (memory address of your pixel data loaded from file); and you will know the length of this array by the width/height values in the image info struct i hope that helps sorry im kinda in a rush right now
  2. Spirrwell, what you are going to want to do is save all of the file information (width, height, pixel format, etc.) that is needed for passing it along to various subsystems for loading that data type, such as glTexImage2D( GL_TEXTURE_2D, 0, nOfColors, surface->w, surface->h, 0, texture_format, GL_UNSIGNED_BYTE, surface->pixels ); the way i have done this in the past is simply by writing a struct that contained this information right before the pixel or sound data itself. so the file would look something like [number of items : 5] [item1 image info] [item1 image data] [item2 image info] [item2 image data] [item3 image info] [item3 image data] [item4 image info] [item4 image data] [item5 image info] [item5 image data] [end of file] obviously this is not the optimal solution, nor would it be beneficial to a complex development environment. but i have a feeling you dont need some kind of crazy impressive over thought out solution. pack the files like this, and run compression afterwords if you want. then you can figure out how to improve on it if you so desire. theres nothing wrong with doing this by the way. some people are way too by the book. and as a side note. if you store textures of the same size (file size not JUST dimensions) in their own pak files, you can improve performance by keeping track of a textures index in this file format and seek right to it in memory by using something like (image index * textureSize)
  3. kajjait

    HLSL Render To Texture

    Quote:Original post by Demirug Just as guess. It looks like that your Z-Buffer is still active when you render to your texture. As you don’t clear it before you draw it still contain the values from the last primary render target call. Therefore it could be possible that the Z-test kills your pixel. I disabled ZWRITEENABLE, and ZENABLE render states, cleared the z buffer, and added ZEnable = false in the effect just to be extra extra sure, but its still not working BUT! i was missing a clear at the top of my render which fixed that problem in pix where the old values were showing up... but the part that still confuses me is why the initial framebuffer value in pix is the color that my pixel shader returns, shouldnt it have been the clear color which was rendered on the quad?? **fixed it** sigh... it was bad texture coordinates all along, i had changed a few of the texture coordinates earlier on trying to fix this and forgot to set them back. when i fixed that clear problem it was probably working the whole time, just had bad tex coords. DOH!! [Edited by - kajjait on May 21, 2007 4:22:42 PM]
  4. kajjait

    HLSL Render To Texture

    PIX is showing some funky stuff going on, my pixel color is getting overwritten somehow, i guess this is a good clue as to what is going on... PIX Screenshot (yes my clear color for the texture surface is white)
  5. Right now im simply trying to clear a texture color using a pixel shader using shader model 2.0. i can get the render to texture to work using clear i can clear it to whatever color i want, but my pixel shader isnt doing anything. what its doing is rendering both passes with the same world / view / proj matrices, and the pixel shader is returning 1.0 green for the color, but all i get is the quad with my clear color. here is my code, i would greatly appreciate any help or links to a good sample. thanks surface / texture creation m_pDevice->CreateTexture(m_nWindowWidth, m_nWindowHeight, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A16B16G16R16F, D3DPOOL_DEFAULT, &m_pTexRender, NULL); m_pTexRender->GetSurfaceLevel(0, &m_pTexSurface); Rendering m_pDevice->SetVertexDeclaration(m_pCubeDecl); m_pDevice->SetStreamSource(0, m_pCubeVB, 0, sizeof(tCubeVert)); //snag the old color buffer IDirect3DSurface9 *oldColorBuffer = 0; m_pDevice->GetRenderTarget(0, &oldColorBuffer); unsigned int nPasses = 0; m_pEffect->SetTechnique("Pong"); m_pEffect->Begin(&nPasses, 0); //render to texture pass m_pEffect->SetMatrix("World", &matWorld); m_pEffect->SetMatrix("View", &matView); m_pEffect->SetMatrix("Projection", &matProj); //set texture surface as render target m_pDevice->SetRenderTarget(0, m_pTexSurface); m_pDevice->BeginScene(); m_pDevice->Clear(0,NULL,D3DCLEAR_TARGET,D3DCOLOR_XRGB(255,255,255),1.0f,0); m_pEffect->BeginPass(0); m_pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2); m_pEffect->EndPass(); m_pDevice->EndScene(); m_pEffect->SetMatrix("World", &matWorld); m_pEffect->SetMatrix("View", &matView); m_pEffect->SetMatrix("Projection", &matProj); m_pDevice->SetTransform(D3DTS_VIEW, &matView); m_pDevice->SetTransform(D3DTS_WORLD, &matWorld); m_pDevice->SetTransform(D3DTS_PROJECTION, &matProj ); m_pDevice->SetRenderTarget(0, oldColorBuffer); m_pDevice->BeginScene(); m_pDevice->Clear ( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL, m_dwClearColor, 1.0f, 0); m_pEffect->SetTexture("baseMap", m_pTexRender); m_pEffect->BeginPass(1); m_pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2); m_pEffect->EndPass(); m_pEffect->End(); m_pDevice->EndScene(); //Flip Back Buffer m_pDevice->Present( NULL, NULL, NULL, NULL ); } hlsl shader //calculate this outside later... matrix World : WORLD; matrix Projection : PROJECTION; matrix View : VIEW; matrix WorldView : WORLDVIEW; matrix WorldViewProject : WORLDVIEWPROJECT; texture baseMap; sampler BaseMap = sampler_state { Texture = (baseMap); magfilter = linear; minfilter = linear; mipfilter = linear; AddressU = wrap; AddressV = wrap; }; struct VS_INPUT { float4 pos : POSITION; float2 texCoord : TEXCOORD0; }; struct VS_OUTPUT { float4 pos : POSITION; float2 texCoord : TEXCOORD0; }; VS_OUTPUT VSRenderToTexture( VS_INPUT vs_in) { VS_OUTPUT Out = (VS_OUTPUT)0; //move this to outside the shader later... WorldView = mul(World, View); WorldViewProject = mul(WorldView, Projection); Out.pos = mul(vs_in.pos, WorldViewProject); return Out; } float4 PSRenderToTexture( VS_OUTPUT ps_in) : COLOR { return float4(0.0f, 1.0f, 0.0f, 1.0f); } VS_OUTPUT VSCube( VS_INPUT vs_in) { VS_OUTPUT Out = (VS_OUTPUT)0; WorldView = mul(World, View); WorldViewProject = mul(WorldView, Projection); Out.pos = mul(vs_in.pos, WorldViewProject); Out.texCoord = vs_in.texCoord; return Out; } float4 PSCube( VS_OUTPUT ps_in) : COLOR { return tex2D(BaseMap, ps_in.texCoord); } technique Pong { pass RenderToTex { VertexShader = compile vs_2_0 VSRenderToTexture(); PixelShader = compile ps_2_0 PSRenderToTexture(); } pass RenderCube { VertexShader = compile vs_2_0 VSCube(); PixelShader = compile ps_2_0 PSCube(); } } [Edited by - kajjait on May 21, 2007 2:10:27 PM]
  6. kajjait

    GPU skinning artifacts

    Right now i changed it to run the good animations on the GPU, and the busted ones on the CPU, but i really dont understand why this is happening, the only thing i can think of is to have an artist go over the models and re-rig and animate them?
  7. I just moved my skinning animation function onto the GPU and im getting a few artifacts with 2 of my models. both of them seem to have one part of the model that is translating and rotating improperly. the only things that were changed with the model are that i used the ConvertToIndexedBlendedMesh, and am using my own skinning on the GPU instead of UpdateSkinnedMesh. I dont think it could be a problem updating the frame matrices because it works fine for other models, and it was never a problem before i moved the skinning onto the gpu. does anyone know what could be causing these artifacts?
  8. I'm trying to render a circle representing an objects movement radius value in my level / terrain editor and im trying to figure out the best way to handle this. I've been thinking about using the stencil buffer to cut out an outline of a sphere at the objects position and then render my circle there, but im not exactly sure if this is the best way to do it. Does anyone know a good way of doing this?
  9. kajjait

    .X animation?

    this is one tutorial i found on skinned animation with x files
  10. im wondering if its possible at all to export an x file that has multiple animations in it using maya 7. i've seen x files with multiple animations in them and i wrote my animation system to use them, but i cant figure out how to get more than one animation exported in an x file. if i cant export it like that right out of maya is there a tool that will work with the newer x files that would take care of this for me? i noticed the old DX9.0b mesh viewer had the option to add animations to an x file but that functionality was removed for some reason, and that tool will not load certain models out of maya. if i could get it to load my x files out of maya i think it would work, but for some reason it doesnt work with certain x files i export and i dont really have any idea why that is.
  11. ok i figured out the problem... its that damn maya exporter! my friend just sent me an x file and it loaded right up, textured and all! the only problem is that i dont know what im doing wrong with this exporter. the exporter im using is the one that comes with the DX SDK. you mentioned you had problems getting it to work right? what did you do to fix them? oh and also the model that is "broken" works perfectly fine in the DX model viewer, which is what caused me to believe my problem was code related, and not the actual model >:|
  12. I am trying to render a .x file in my engine and there is a problem that i cant seem to nail down. when i render the mesh and it goes through the rendering pipeline the result is an all black mesh. i ran it through PIX and it seems like all of my diffuse values are 0 which i suspect is the problem. whats confusing the hell out of me is that the materials diffuse is not 0, its actually 0.8. i have no idea whats going on, is there some other diffuse value that the D3DXMesh could be grabbing? if anyone has any information or suggestions please let me know! here are some debugging screenshots PIX Screenshot material values Black model rendering here is all my x model loading / rendering code #include "XModel.h" bool CXModel::LoadData(ILoad * pLoadData) { if (!static_cast<CXLoadModel *>(pLoadData)->m_szFileName) return false; //buffer for loading materials LPD3DXBUFFER pMatBuffer; D3DXMATERIAL *pMatPtr; HRESULT res; res = D3DXLoadMeshFromX(static_cast<CXLoadModel *>(pLoadData)->m_szFileName, D3DXMESH_MANAGED, GEAR_RENDER_DEVICE, 0, &pMatBuffer, 0, &m_nNumMaterials, &m_pMesh); if (res == S_OK) { //get material pointer pMatPtr = (D3DXMATERIAL *)pMatBuffer->GetBufferPointer(); //create material array m_pMaterials = new D3DMATERIAL9[m_nNumMaterials]; //create tex array m_ppTexArray = new LPDIRECT3DTEXTURE9[m_nNumMaterials]; //fill out material array for (DWORD i = 0; i < m_nNumMaterials; i++) { m_pMaterials = pMatPtr.MatD3D; m_pMaterials.Ambient = m_pMaterials.Diffuse; m_ppTexArray = 0; if (pMatPtr.pTextureFilename) D3DXCreateTextureFromFile(GEAR_RENDER_DEVICE, pMatPtr.pTextureFilename, &m_ppTexArray); } pMatBuffer->Release(); return true; } else return false; } void CXModel::ReleaseData() { m_pMesh->Release(); for (DWORD i = 0; i < m_nNumMaterials; i++) { if (m_ppTexArray) m_ppTexArray->Release(); } delete[] m_ppTexArray; delete[] m_pMaterials; } void CXModel::Draw(CAppearance *pAppearance) { int stage = 0; for (DWORD i = 0; i < m_nNumMaterials; i++) { GEAR_RENDER_DEVICE->SetMaterial(&m_pMaterials); GEAR_RENDER_DEVICE->SetTexture(0, m_ppTexArray); //pAppearance->BindData(0, stage); m_pMesh->DrawSubset(i); } }
  13. kajjait

    GL_LINE_LOOP closes early

    just curious, do you have an ATI card? i've witnessed some weird opengl bugs like this on my ati mobile x600. though none of them were directly related to line loop.
  14. kajjait

    Animating basic shapes..

    it looks like its working fine on my machine, is this not how its supposed to look? i have the latest opengl/glut/video card drivers but i dont know if that would really make a difference or not... this was also run on windows xp
  15. kajjait

    Need Help With fading

    enable blending for quad a, and then just change its alpha value over time. its been a while since ive used opengl blending but it think this is all you have to do //setup the blend func to use glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //render quadB behind quadA quadB.draw() //turn on blending glEnable(GL_BLEND); //render quadA infront of quadb //if you're doing glcolor to set quadA you can easily change the alpha glcolor4f(0.0f, 0.0f, 0.0f, quadA.transparancy); quadA.draw(); just remember that when doing blending you always have to render objects from back to front, or else it wont look right.
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. 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!