jakussano

Member
  • Content count

    41
  • Joined

  • Last visited

Community Reputation

132 Neutral

About jakussano

  • Rank
    Member
  1. how can i make an efficient parallel code from: for(i=0;i<n;i++) { for(j=0;j<n;j++) { for(k=0;k<n;k++) { for(o=k;o<n;o++) { //here i have 4 if conditions }}}} until now i made: //#pragma omp parallel { //#pragma omp for schedule(dynamic,2) private(i,j,l,o,CostIJ,CostResIJ,aux) for(i=0;i<n;i++) { for(j=0;j<n;j++) { for(k=0;k<n;k++) { for(o=k;o<n;o++) { //here i have 4 if conditions }}}} another ideea for better optimization?
  2. I want to create a shader manager class and i have a q: I should keep the ID3D10Blob objects from which i create the shaders or i keep the shaders and deallocate the ID3D10Blob objects? Now i use only a shader : ID3D10Blob *VS=NULL, *PS=NULL; ID3D10Blob *err=NULL; HRESULT h; h = D3DX11CompileFromFile(L"shaders.hlsl", 0, 0, "VShader", "vs_4_0", 0, 0, 0, &VS, &err, 0); h = D3DX11CompileFromFile(L"shaders.hlsl", 0, 0, "PShader", "ps_4_0", 0, 0, 0, &PS, &err, 0); device->CreateVertexShader(VS->GetBufferPointer(), VS->GetBufferSize(), NULL, &pVS); device->CreatePixelShader(PS->GetBufferPointer(), PS->GetBufferSize(), NULL, &pPS); or i need to keep them both, because pVS and pPS will keep pointer to the data from PS and VS? [SOLVED] http://www.gamedev.net/topic/630097-save-shader-as-id3d10blob-pointer/
  3. backgammon

    Hello guys! i need a solution to the next problem : given two states,how cand i know, which state is more favorable for WHITE (for example ), where a state is something like [url="http://www.google.ro/imgres?um=1&hl=ro&client=opera&sa=N&rls=en&channel=suggest&biw=1280&bih=862&tbm=isch&tbnid=zfFig2rrrJ1oBM:&imgrefurl=http://games.yahoo.com/game/backgammon-quick-play&docid=q0msprTT8vRAyM&imgurl=http://l.yimg.com/a/i/us/ga/gameart2/backgammon-quick-play/backgammon-quick-play-screenshot3.jpg&w=400&h=300&ei=_PyPT4rnDY7MswbrxKC6BA&zoom=1&iact=hc&vpx=191&vpy=568&dur=716&hovh=194&hovw=259&tx=151&ty=142&sig=106373016601609375056&page=1&tbnh=154&tbnw=205&start=0&ndsp=20&ved=1t:429,r:15,s:0,i:96"]this[/url], is the state of the pieces on the table. I use a minimax algorithm to get the states.
  4. Strange multiple target render

    i fixed it when i changed Motor::Video::getDevice(1)->CreateTexture(1024,748,0, .... to Motor::Video::getDevice(1)->CreateTexture(1024,748,1, .... Good thing is working but i didn't understand why... :-? EDIT: the error was on the second Screen->Draw(Device,NULL);
  5. I try to render to a surface1 with a blur effect and then i r try to render surface1 to surface2 again with blurr effect but it doesn't work :Direct3D9: (WARN) :Can not render to a render target that is also used as a texture... If i render to a surface whit a blur and then to backbuffer it works Here is the code: Device->GetRenderTarget(0,&pBackBuffer); Device->SetRenderTarget(0,pScreenSurface); Device->Clear(0,NULL,D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0),1.0f,0); Device->BeginScene(); Device->SetFVF(CUSTOMFVF); Obj->setPositionTo(50,50); Obj2->setPositionTo(300,320); ObjectManager->Draw(); Device->EndScene(); Device->SetRenderTarget(0,pBackBuffer); Device->BeginScene(); if (SUCCEEDED(g_pEffect->SetTechnique("Blur"))) { UINT numPasses; g_pEffect->Begin(&numPasses,0); g_pEffect->SetFloat("wave",wave); g_pEffect->SetFloat("glow",glow); g_pEffect->SetFloat("blur",blur); g_pEffect->SetFloat("blurstrenght",blurstrenght); g_pEffect->SetTexture("MarbleSplineSampler",pScreenTexture); for (UINT i=0;i<numPasses;i++) { g_pEffect->BeginPass(i); Screen->Draw(Device,NULL); g_pEffect->EndPass(); } g_pEffect->End(); } Device->EndScene(); Device->Present(0,0,0,0); If i try to rener the serface again to another surface it doesn't. Device->GetRenderTarget(0,&pBackBuffer); Device->SetRenderTarget(0,pScreenSurface); Device->Clear(0,NULL,D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0),1.0f,0); Device->BeginScene(); Device->SetFVF(CUSTOMFVF); Obj->setPositionTo(50,50); Obj2->setPositionTo(300,320); ObjectManager->Draw(); Device->EndScene(); Device->SetRenderTarget(1,pScreenSurface1); // even if is 0 it doesn't work Device->BeginScene(); if (SUCCEEDED(g_pEffect->SetTechnique("Blur"))) { UINT numPasses; g_pEffect->Begin(&numPasses,0); g_pEffect->SetFloat("wave",wave); g_pEffect->SetFloat("glow",glow); g_pEffect->SetFloat("blur",blur); g_pEffect->SetFloat("blurstrenght",blurstrenght); g_pEffect->SetTexture("MarbleSplineSampler",pScreenTexture); for (UINT i=0;i<numPasses;i++) { g_pEffect->BeginPass(i); Screen->Draw(Device,NULL); g_pEffect->EndPass(); } g_pEffect->End(); } Device->EndScene(); Device->SetRenderTarget(0,pBackBuffer); Device->BeginScene(); if (SUCCEEDED(g_pEffect->SetTechnique("Blur"))) { UINT numPasses; g_pEffect->Begin(&numPasses,0); g_pEffect->SetFloat("wave",wave); g_pEffect->SetFloat("glow",glow); g_pEffect->SetFloat("blur",blur); g_pEffect->SetFloat("blurstrenght",blurstrenght); g_pEffect->SetTexture("MarbleSplineSampler",pScreenTexture1); for (UINT i=0;i<numPasses;i++) { g_pEffect->BeginPass(i); Screen->Draw(Device,NULL); g_pEffect->EndPass(); } g_pEffect->End(); } Device->EndScene(); Device->Present(0,0,0,0); Any ideea why it doesn't work?
  6. Directx Memory Unfreed

    Problem solved: If you reuse pointers, make sure you release or delete the object And yes it was a texture:P Thanks!
  7. Direct3D9: (ERROR) :Memory still allocated! Alloc count = 501 Direct3D9: (ERROR) :Current Process (pid) = 000009fc Direct3D9: (ERROR) :Total Memory Unfreed From Current Process = 2884039 bytes I release every single device and i delete all dynamic memory; What shall i delete? Maybe if i delete the windows...
  8. MULTIPLE RENDER TARGETS

    i can't get it; i can't understand because i don't know how those things should work so.. i want to draw the poligons, triangles to a texture or sprite ( i don't know ) and then blur it (all scene to be blur not only the texture in the poligons); IDirect3DSurface9 * Sample1 =NULL; IDirect3DTexture9* Texture1 =NULL; HANDLE *shandle=NULL; Motor::Video::getDevice(1)->CreateTexture(880,624,0,D3DUSAGE_RENDERTARGET,D3DFMT_A8R8G8B8,D3DPOOL_DEFAULT,&Texture1,shandle); Texture1->GetSurfaceLevel(0,&Sample1); Device->Clear(0,NULL,D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0),1.0f,0); Device->BeginScene(); Device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); Device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); Device->SetFVF(CUSTOMFVF); Obj->setPositionTo(20,30); ObjectManager->Draw(); Device->SetRenderTarget(1,Sample1); Obj->setPositionTo(300,300); if (SUCCEEDED(g_pEffect->SetTechnique("Blur"))) { UINT numPasses; g_pEffect->Begin(&numPasses,0); g_pEffect->SetFloat("wave",wave); g_pEffect->SetFloat("blur",blur); //g_pEffect->SetTexture("input",Texture1); for (UINT i=0;i<numPasses;i++) { g_pEffect->BeginPass(i); ObjectManager->Draw(); Obj->setPositionTo(100,100); ObjectManager->Draw(); g_pEffect->EndPass(); } g_pEffect->End(); } Device->EndScene(); Device->Present(0,0,0,0);
  9. 1)if i set a surface to be a render target, all drawing will be in that surface? 2) how i use those multiple targets with pixel shader? for example first line in my pixelshader file is : sampler2D input : register(s0); 3) is this the backbuffer? (register(s0))? 4) if i have 2 techniques: blurx and blury; sampler2D input the texture; and use this tehnique: pass0: blurx; pass1 blury; then the final image will be only blury; *** the functions looks like: float4 GlowPS(float2 inTex : TEXCOORD0) : COLOR0 { return color}
  10. why it doesn't glow?

    ok so this is too much for me for the moment... This HDR is a library or is only a tehnique? Any links, tutorials? the hdrpipeline sample... is too hard i don't get it
  11. why it doesn't glow?

    thanks:D
  12. so i have 3 indexed polygons; i use directx and an effect: http://www.steelskies.com/HLSL2.htm How can i make this thing glow? http://yfrog.com/3189817402j the second one is whit this effect: ////////////////////////////////////////////// // Glow Shader: // Glows are rendered as a separate pass // to the rest of the scene. Glowing objects // get rendered to a texture, the texture is // blurred, then the texture is overlaid onto // the main scene. ////////////////////////////////////////////// texture glowTexture; // texTrans is a transform u // pSize is the pixel size of the texture, // equivalent to the inverse of the texture width. float pSize; sampler GlowSampler = sampler_state { Texture = (glowTexture); MipFilter = LINEAR; MinFilter = LINEAR; MagFilter = LINEAR; }; //Passed to the vertex shader from the pipeline struct GLOW_INPUT { float4 pos : POSITION; float2 texCoord : TEXCOORD; }; //VS output / PS input: struct GLOW_OUTPUT { float4 pos : POSITION; float2 texCoord0 : TEXCOORD0; float2 texCoord1 : TEXCOORD1; float2 texCoord2 : TEXCOORD2; float2 texCoord3 : TEXCOORD3; }; struct TEXTURE_OUTPUT { float4 pos : POSITION; float2 texCoord0 : TEXCOORD0; }; //PS output: struct pixel { float4 color : COLOR; }; ////////////////////////// // Vertex Shaders: ////////////////////////// // These glow vertex shaders blur the texture in // specific direction - up, down, left, and right. // They are used one after the other to obtain a full blur. // VS1.3 hardware could do this in 2 passes rather than 4, // but I only have a lowly Geforce4... // They work by offsetting the texture coordinates into // 4 texCoord streams. The pixel shader then reads the // texture color at each of these texcoords and averages them // together, effectively sampling a cluster of pixels. GLOW_OUTPUT glowVSHorizontal1(GLOW_INPUT IN) { GLOW_OUTPUT OUT; OUT.pos = IN.pos; OUT.texCoord0 = IN.texCoord + float2(-pSize*3, 0); OUT.texCoord1 = IN.texCoord + float2(-pSize*2, 0); OUT.texCoord2 = IN.texCoord + float2(-pSize*1, 0); OUT.texCoord3 = IN.texCoord + float2(0, 0 ); return OUT; } GLOW_OUTPUT glowVSHorizontal2(GLOW_INPUT IN) { GLOW_OUTPUT OUT; OUT.pos = IN.pos; OUT.texCoord0 = IN.texCoord + float2(pSize*3,0); OUT.texCoord1 = IN.texCoord + float2(pSize*2, 0); OUT.texCoord2 = IN.texCoord + float2(pSize*1, 0); OUT.texCoord3 = IN.texCoord + float2(0, 0 ); return OUT; } GLOW_OUTPUT glowVSVertical1(GLOW_INPUT IN) { GLOW_OUTPUT OUT; OUT.pos = IN.pos; OUT.texCoord0 = IN.texCoord + float2(0,-pSize*3); OUT.texCoord1 = IN.texCoord + float2(0,-pSize*2); OUT.texCoord2 = IN.texCoord + float2(0,-pSize*1); OUT.texCoord3 = IN.texCoord + float2(0,0); return OUT; } GLOW_OUTPUT glowVSVertical2(GLOW_INPUT IN) { GLOW_OUTPUT OUT; OUT.pos = IN.pos; OUT.texCoord0 = IN.texCoord + float2(0,pSize*3); OUT.texCoord1 = IN.texCoord + float2(0,pSize*2); OUT.texCoord2 = IN.texCoord + float2(0,pSize*1); OUT.texCoord3 = IN.texCoord + float2(0,0); return OUT; } // This is the plain vertex shader used to overlay the // final glow texture over the rest of the scene. TEXTURE_OUTPUT outputGlowVS(GLOW_INPUT IN) { TEXTURE_OUTPUT OUT; OUT.pos = IN.pos; OUT.texCoord0 = IN.texCoord; return OUT; } ////////////////////////// // Pixel Shaders: ////////////////////////// // Add the texture values at each of the supplied texCoords // together, weighted by some arbitary function that gives // a reasonable appearance. // These weights are critical to the glow behaviour, // and tiny changes in the values can suddenly make the glow // invisible or overpowering. If anyone knows how to make this // better, please let me know... pixel glowPS(GLOW_OUTPUT IN) { pixel OUT; float4 color = tex2D( GlowSampler, IN.texCoord0 ) * 0.1; color += tex2D( GlowSampler, IN.texCoord1 ) * 0.3; color += tex2D( GlowSampler, IN.texCoord2 ) * 0.4; color += tex2D( GlowSampler, IN.texCoord3 ) * 0.25; OUT.color = color; OUT.color.a = 1.0f; return OUT; } // This is the pixel shader used to overlay the final glow image // onto the rest of the scene. pixel outputGlowPS(TEXTURE_OUTPUT IN) { pixel OUT; OUT.color = tex2D( GlowSampler, IN.texCoord0); return OUT; } ////////////////////////// // Techniques: ////////////////////////// // Four passes blur the texture in different directions. // The final one overlays the texture onto the rest of // the scene. // Annotations are used so my application can automatically // sort these passes into the appropriate rendering stage. technique glow { pass P0 <string renderStage="texture";> { Sampler[0] = (GlowSampler); vertexshader = compile vs_2_0 glowVSHorizontal1(); pixelshader = compile ps_2_0 glowPS(); fvf = XYZRHW | Tex1; } pass P1 <string renderStage="texture";> { Sampler[0] = (GlowSampler); vertexshader = compile vs_2_0 glowVSVertical1(); pixelshader = compile ps_2_0 glowPS(); fvf = XYZRHW | Tex1; } pass P2 <string renderStage="texture";> { Sampler[0] = (GlowSampler); vertexshader = compile vs_2_0 glowVSHorizontal2(); pixelshader = compile ps_2_0 glowPS(); fvf = XYZRHW | Tex1; } pass P3 <string renderStage="texture";> { Sampler[0] = (GlowSampler); vertexshader = compile vs_2_0 glowVSVertical2(); pixelshader = compile ps_2_0 glowPS(); fvf = XYZRHW | Tex1; } pass P4 <string renderStage="post";> { Sampler[0] = (GlowSampler); vertexshader = compile vs_2_0 outputGlowVS(); pixelshader = compile ps_2_0 outputGlowPS(); fvf = XYZRHW | Tex1; AlphaBlendEnable = true; BlendOp = Min; SrcBlend = One; DestBlend = One; } }
  13. pixel shader effect file

    an LPD3DXSPRITE *ppSprite http://www.toymaker.info/Games/html/sprites.html
  14. if i use a pixel shader with a .psh file it works fine. But if i use .fx it doesn't work. Any idea? Device->Clear(0,NULL,D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0),1.0f,0); Device->BeginScene(); if(Sprite!=NULL) { Sprite->Begin(D3DXSPRITE_ALPHABLEND); if (SUCCEEDED(g_pEffect->SetTechnique( "PostProcess" ))) { //Device->SetPixelShader(pixelshader); g_pEffect->Begin( &cPasses, 0 ); for(UINT iPass = 0; iPass < cPasses; iPass++ ) { g_pEffect->BeginPass( iPass ) ; Sprite->Draw(ObjectManager->getTextureManager()->getTexture(1),0,0,&Position3,X4); Sprite->Draw(ObjectManager->getTextureManager()->getTexture(2),0,0,&Position5,X6); Sprite->Draw(ObjectManager->getTextureManager()->getTexture(0),0,0,&Position1,X3); Sprite->Draw(ObjectManager->getTextureManager()->getTexture(0),0,0,&Position2,X2); Sprite->Draw(ObjectManager->getTextureManager()->getTexture(0),0,0,&Position4,X1); g_pEffect->EndPass(); } g_pEffect->End(); } Sprite->End(); }; fx file: struct PS_INPUT { float4 Position : POSITION; float2 Texture : TEXCOORD0; }; struct PS_OUTPUT { float4 Color : COLOR0; }; sampler2D Tex0; PS_OUTPUT ps_main( in PS_INPUT In) { PS_OUTPUT Out; Out.Color = tex2D(Tex0, In.Texture.xy)*3; return Out; } technique PostProcess { pass P0 { VertexShader = null; PixelShader = compile ps_2_0 ps_main(); } }