• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

aprilspirit89

Members
  • Content count

    26
  • Joined

  • Last visited

Community Reputation

160 Neutral

About aprilspirit89

  • Rank
    Member
  1. I can't.The matrix itself was generate in shader.In fact, I 'm trying to do normal mapping without precomputed tangent attribute in vertex buffer.The technique can be found in ShaderX5, Chapter2.6.It provides a non-orthogonal tangent-to-local matrix,so I'm trying to get the local-to-tangent matrix so that I can do lighting calculations in tangent space.
  2. Hi,I'm just wondering whether this can be done in ps shader.I have an non-orthogonal matrix and need to orthogonalize it and using inverse-?transpose result.I turned to matlab for help,only found their instructions a bit of complicated for shaders.It might influence the performance.So is there a solution yet?Thanks for any reply:)   PS:Image below shows the result of using origin matrix and do lighting in world space. [attachment=13379:Right.png] And this is the wrong result of orthogonalize the origin matrix and then using the inverse-transpose one and do lighting in tangent space. [attachment=13380:wrong.jpg] And here is my Orthogonalization code. float3x3 Orthogonalization_Schmidt(float3x3 OrginMatrix) { float3 a1 = OrginMatrix[0]; float3 a2 = OrginMatrix[1]; float3 a3 = OrginMatrix[2]; float3 b1 = a1; float3 b2 = a2 - dot(a2,b1)/dot(b1,b1)*b1; float3 b3 = a3 - dot(a3,b1)/dot(b1,b1)*b1 - dot(a3,b2)/dot(b2,b2)*b2; return float3x3(normalize(b1),normalize(b2),normalize(b3)); }    
  3. Hello,I am trying normal map and I calculate TBN matrix in pixel shader.Problem is the technique I use give a TBN matrix which is not a orthogonal matrix.It can only translate vectors from tangent space to local space,not the opposite way.So I just do lighting in world space. I just wonder can I do parallax mapping in world space or view space?If I can't,is there a way to calculate a orthogonal TBN matrix in ps?And what else technique must have tangent space? Thanks for reply.
  4. Thanks for replying my problem. Things are not the way I thought.The problem is not about UV seams at all,but the UV directions.The truth is I was using directx sampling texture directions to calculate my Binormal,that is having a V direction from top to down.But I haven't check my resources.They are bulit in Maya,which have a down-to-top V direction.So it's OK with color and fails correct normal mapping.Without my artist,I could never know this.[img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
  5. Hi,I'm trying to do normalmap using directx9.After reading [url="http://www.shaderx5.com/TOC.html"]2.6 Normal Mapping without Pre-Computed Tangents by Christian Schueler[/url] ,I deside to use this. [source lang="cpp"]float3x3 ComputeTangentFrame(float3 N,float3 p,float2 uv) { float3 dp1 = ddx(p); float3 dp2 = ddy(p); float2 duv1 = ddx(uv); float2 duv2 = ddy(uv); float3x3 M = float3x3(dp1,dp2,cross(dp1,dp2)); float2x3 inversetransposeM = float2x3(cross(M[1],M[2]),cross(M[2],M[0])); float3 T = mul(float2(duv1.x,duv2.x),inversetransposeM); float3 B = mul(float2(duv1.y,duv2.y),inversetransposeM); return float3x3(normalize(T),normalize(B),N); }[/source] It seems good and simple,but soon I get punished at little seams with UV mirrors.The whole model looks right under light,but at those seams,normal gets wrong and light reflect in unproper way,so a sudden change or miss lighting on surface appears.I think this is because when current pixel is shared by different triangles with different directions of UV,the ddx and ddy instruction will get wrong answers. So,I use [source lang="cpp"]float r = (dot(cross(T,B),N)<0.0f) ? -1.0f : 1.0f;[/source] to judge whether UV was mirrored.Then I realized I can't change tangent or binormal or normal,for most part of the mesh already seems right.On the other hand,I cannot know whether it's U mirror or V mirror.It's hard to tell the right direction of two axes(tangent and binormal) when you only know one axes(Normal).The author do not give futher information. Btw,because I'm using dx9,so I can't split vertexes in shader. So I want to know is there a possible way to solve this problem?Thanks for any reply
  6. Hi,I want to change my projection matrix from Persective to Orthogonal way.I use the same width,height and other properties,so I get bigger things showing on the screen.My question is how to modify the projection matrix so I can get simillar size as Perspective Projection?
  7. My mistake.More time spend when modifing data,so the render data for next frame wasn't updated properly, which bothered me 2 days.
  8. It runs without errror or any waring,but shows wrong result. I rendered some colorful particles to the RT and saved it to file.But when I modified the pixel before saving,the colors of particles all change to yelllow(the start color).I guess maybe something happens when surface being wirtten,or the calculation takes too much time during locking rect and cause problem. [source lang="java"]LPDIRECT3DTEXTURE9 pCopyTexture = NULL; LPDIRECT3DSURFACE9 pCopySurface = NULL; g_pd3dDevice->CreateTexture(width,height,0,D3DUSAGE_DYNAMIC,D3DFMT_A8R8G8B8,D3DPOOL_SYSTEMMEM,&pCopyTexture,NULL); pCopyTexture->GetSurfaceLevel(0,&pCopySurface); hResult = g_pd3dDevice->GetRenderTargetData(pRenderSurface,pCopySurface); D3DLOCKED_RECT rect; if(S_OK == pCopySurface->LockRect(&rect,NULL,D3DLOCK_DONOTWAIT)) { DWORD* pColor = (DWORD*)rect.pBits; for( UINT y = 0 ; y < height ; y++ ) { for(UINT x = 0 ; x < width ; x++ ) { DWORD color = pColor[y*rect.Pitch/4+x]; D3DCOLOR dwcolor = color; //D3DXCOLOR fColor = Color2Value(dwcolor); //if(fColor.a > 0) //{ // fColor.r /= fColor.a; // fColor.g /= fColor.a; // fColor.b /= fColor.a; // float radio = 1; // if(fColor.r > radio) // radio = fColor.r; // if(fColor.g > radio) // radio = fColor.g; // if(fColor.b > radio) // radio = fColor.b; // fColor.r /= radio; // fColor.g /= radio; // fColor.b /= radio; // fColor.a /= radio; //} //dwcolor = Value2Color(fColor); pColor[y*rect.Pitch/4+x] = dwcolor; } } pCopySurface->UnlockRect(); } hResult = D3DXSaveSurfaceToFile(pTexPathName,texFormat,pCopySurface,NULL,NULL); g_pd3dDevice->SetRenderTarget(0,pBackBuffer);[/source] Here is my new code,copy data to another surface in system memory and get colorful paticles.And I get yellow paticles with comment code.I'm not sure of D3DLOCK flag here. Btw,I was trying to get a non-premultiplied alpha texture of 3D rendering scenes.So here I used separate alpha calculating but not good for Add blend mode(src is SRCALPHA,dest is ONE).Any suggestions will be great thankful.
  9. I'm trying to save render sth. to texture and modify the data before saving it to file.But I found the data incorrect when I modify them. [source lang="cpp"] LPDIRECT3DSURFACE9 pBackBuffer,pRenderSurface=NULL; g_pd3dDevice->CreateRenderTarget(width,height,D3DFMT_A8R8G8B8,D3DMULTISAMPLE_NONE,0,TRUE,&pRenderSurface,NULL); hResult = g_pd3dDevice->GetRenderTarget(0,&pBackBuffer); g_pd3dDevice->SetRenderTarget(0,pRenderSurface); g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DXCOLOR(0,0,0,0), 1.f, 0); Render(); g_pd3dDevice->SetRenderTarget(0,pBackBuffer); D3DLOCKED_RECT rect; if(S_OK == pRenderSurface->LockRect(&rect,NULL,D3DLOCK_NOSYSLOCK)) { DWORD* pColor = (DWORD*)rect.pBits; for( UINT y = 0 ; y < height ; y++ ) { for(UINT x = 0 ; x < width ; x++ ) { DWORD color = pColor[y*rect.Pitch/4+x]; D3DCOLOR dwcolor = color; D3DXCOLOR fColor = Color2Value(dwcolor); if(fColor.a > 0) { fColor.r /= fColor.a; fColor.g /= fColor.a; fColor.b /= fColor.a; } dwcolor = Value2Color(fColor); pColor[y*rect.Pitch/4+x] = dwcolor; } } pRenderSurface->UnlockRect(); } D3DXSaveSurfaceToFile(pTexPathName,texFormat,pRenderSurface,NULL,NULL);[/source] Here is the code.I tried every D3DLOCK flags but none of them work. I also try CreateOffscreenPlainSurface and GetRenderTargetData to copy the surface data to system memory before LockRect.Also Failed.Did I miss Something?
  10. Thanks! I'll change my code anyway.
  11. I wonder if I can get world matrix in shader using register.I wrote this in C++ and used a fixed pipeline: [source lang="cpp"]g_pd3dDevice->SetTransform(D3DTS_WORLD, &matWorldSave);[/source] Now I want to add a shader,and use world matrix without changing code above.For example,I can use register s0 to represent the first texture in shader.Which register should I use?
  12. [quote name='JTippetts' timestamp='1342063820' post='4958247'] However, before you go with a solution such as premultiplied alpha, why don't you figure out exactly what it is you are trying to achieve, and figure out exactly what configuration of blend modes and alpha setups you need to achieve the effect? [/quote] You're very helpful.I thought doing multiply alpha it in shader is equal to doing it in making assert stage.Yes,my problem maybe not the proper customer for pre-multiplied alpha technique.But so far,it's the closet way,because I have good result about alpha blend mode(srcAlpha VS 1-srcAlpha). As said above,I am rendering 3D particle sytems in 3D world,then I'm trying to save them to 2D texture arrays,so that they can be reused to 3D or 2D game world.I got a texture seems alright but shows black edges in Photoshop.They are inflenced by the default back ground color.I described my problem [url="http://www.gamedev.net/topic/626530-how-to-remove-the-black-background-of-a-tga-texture-with-alpha-channel/page__p__4950151#entry4950151"]here[/url]. What the PS accept is straight alpha,which is opposite to pre-multiplied alpha.RGB value should be independent from alpha.But rgb is definitely influnced by alpha during rendering process.So I tried to get rid of it.Because I got both premultilied alpha texture(particle resource) and unpremultiplied ones,I use mix alpha mode,additive and blend.Just devide rgb by alpha won't work.I studied premultiplied alpha and it gives me an inspiration,so I separate alpha calculation.It works well with alpha blend mode,while additive mode still remains unsolved.
  13. [quote name='JTippetts' timestamp='1342008819' post='4957996'] Now this assumes that the Src.rgb*src.alpha operation was done as a pre-process pass, so that places where the alpha=0 are set to rgb=0,0,0. What if this is not the case, though? What if you have a pixel in the source with an alpha of 0 and a non-zero rgb? [code] OutColor=Src.rgb+Dest.rgb*(1-0) OutColor=Src.rgb+Dest.rgb [/code] The result is an additive blend of Src.rgb and Dest.rgb. No change of blend state is required. By varying the alpha value, you can reduce the power of the additive effect until at 1 it becomes just the standard replacement blend. So by keeping your alpha values close to 0, you can have varying strengths of additive blend, without having to overload the source alpha to 0 and losing your details. [/quote] Thank you very much.Now I'm a little confused.You said I can keep alpha value to 0,to vary the strength of additive mode.But I can't see other way except to change the source alpha.I do the premultiplication in PS shader,then set alpha to 0.And the pipeline will do the alpha blend thing like this [CODE] OutColor=Src.rgb+Dest.rgb*(1-0) OutColor=Src.rgb+Dest.rgb //srcColor 1 //destColor 1-srcAlpha [/CODE] Then I get correct color and wrong alpha.Did I do it in a wrong way?
  14. [quote name='Hodgman' timestamp='1341546887' post='4956201'] The states for premultiplied alpha blending are: [font=courier new,courier,monospace] RenderState.SourceBlend = Blend.One; [/font] [font=courier new,courier,monospace] RenderState.DestinationBlend = Blend.InverseSourceAlpha; [/font] [/quote] Thank you for your reply.I had tried the original pre-multiplied alpha technique.But I must set alpha to 0 when I use additive mode,that destroy the final alpha.
  15. I was trying to save some texture from 3D rendering scene,and then get them to reuse. The big problem is that rgb value can not match its alpha value.I need some picture without black edge,so I must use rgb colors to divide its alpha value(Image manipulation software such as Photoshop can just deal with picture which alpha channel is nonpremultiplied.) Unfortunally,the color is too light that some result value are cut off to 1. So I turned to a technique called premultiplied alpha.([url="http://blogs.msdn.com/b/shawnhar/archive/2009/11/06/premultiplied-alpha.aspx"]See more[/url]). Instead of using shaders,I just use separate alpha calculation. For example: [CODE]RenderState.SourceBlend = Blend.SourceAlpha; RenderState.DestinationBlend = Blend.InverseSourceAlpha;[/CODE] Now I add some renderstate. [CODE]RenderState.SourceBlendAlpha = Blend.One; RenderState.DestinationBlendAlpha = Blend.InverseSourceAlpha;[/CODE] It works well.But when I try to handle following things: [CODE]RenderState.SourceBlend = Blend.SourceAlpha; RenderState.DestinationBlend = Blend.One; RenderState.SourceBlendAlpha = Blend.One; RenderState.DestinationBlendAlpha = Blend.One;[/CODE] The result is totally wrong. Because when I use nonpremultiplied blend state,which is SourceAlpha and inverseSourceAlpha.The rgba value is definitely controlled within 0~1.But when I switch to additive state,which is SourceAlpha and 1,the rgb values might be over one,thus cause the incorrect value. Now my problem is how to control the alpha value,to make sure it keep all details and do not overflow at the same time? //Modified PS:If you don't understand what I am trying to do,there is a commercial software called "[url="http://www.wondertouch.com/pillusion3.asp"]Particle Illusion[/url]".You can create various particles and then save the scene to texture,where you can choose to remove background of particles. [attachment=9970:particleIllusionDemostrate.png]