• 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.


  • Content count

  • Joined

  • Last visited

Community Reputation

132 Neutral

About seacow2

  • Rank
  1. Sure...it's a .dds (that might be the problem, too). I can't upload the .dds file, but here is the mipmipped image (and alpha channel) in two separate jpegs. I noticed this morning the technique I am using for drawing the shadow is mhBuildShadowMapTech, which corresponds to BuildShadowMapTech in the .fx file...the PS for that simply returns the depth.x/depth.y.    I notice that I am working in LightShadowPS, which is the technique set when drawing the tree, not the shadow.  The tree does draw OK with alpha testing turned on. The black is definitely masked out. It's when I try to draw that shadow that I see the billboards.  I apologize for not knowing which way is up when it comes to shaders. It could be that I need to add some code to the BuildShadowMapTech part, instead of returning just a depth. I am at a loss.  Thanks for looking at it!!
  2. I should also mention I am doing the clip test (w .5 alpatestvalue) in function LightShadowPS of the .fx file.
  3. Hi Hupsilardee,   I set the value to .5...but where do I turn on alpha testing? I'm not even sure where when I am rendering into the billboard. I am that new to shaders. Sorry.
  4. Maybe...   technique LightVertexShader {     pass P0   {        FillMode          = WireFrame;   } }     Works for me. Of course, you probably have to make it a global var in the shader if you want to turn it on and off....but that raises the question, if you are turning it on and off, why not just do it setting the render state? That's how I always do it. Hope this helps.   http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.renderstate_members%28v=xnagamestudio.31%29.aspx
  5. Well, for now I have a placeholder of a 2k polycount mesh with a bunch of random poly's that I render in place of the TRUE shadow map (an alpha channel billboard). I don't know how much of a hit I am taking performance wise, because I could never get the billboard to cast a shadow with a bunch of holes in it. Using a 300 poly count placeholder mesh with which to render the shadows, I get about 200+ more FPS. So I know using a placeholder mesh will give me a big hit as opposed to 20 quads (billboards).   With that being said...I would really appreciate it if somebody knows ANYTHING about terrain engines, and shadow maps, and billboards, and HLSL, could look at the code and maybe take a stab at solving it. HELP!!  Good grief, all over google I see this in terrain engines. I already asked Danny Green, and he has given me great help...but I am stuck. Shaders...ugh.    
  6. I got something working...at least closer. I have clipped out the alpha tested shadow parts on the billboards themselves...not on the actual shadow area! I disabled the alpha testing in the .cpp code when rendering the tree to verify that I am getting an alpha channel SOMETHING on the billboards (in the image, the pink circle)...but I am trying to get the same thing to happen on the ground (the green circle).  For the record, I do render the billboards alpha tested properly (the black is turned off and all you see are the leaves)...but I did that to show that I am getting the shadow to at least appear...just not where I want it to appear.   I added to the LightShadowPS function the following code:   const float fAlphaTestValue = .01f; float4 textureSample = tex2D(TexS, projTex.xy); clip(textureSample.a - fAlphaTestValue); So maybe I need to replace TexS with ShadowMapS...however, when I do that, I see zero change in anything. [attachment=14534:shadowmapwrong.jpg]
  7. Hello,   I am trying to use Frank Luna's great, great shader book to render terrain with billboarded trees that are alpha tested, but also use shadow maps to draw some nice, leafy shadows under the trees. It's an age old problem, and one I am unable to find a solution for after googling for a few days. At least now I've narrowed it down to alpha test and not alpha blend, but still not working. What I think should show as alpha blended shadows on the terrain instead turns up as solid black rectangles.   void ShadowMapDemo::drawShadowMap() { mShadowMap->beginScene(); HR(gd3dDevice->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00000000, 1.0f, 0)); HR(mFX->SetTechnique(mhBuildShadowMapTech)); UINT numPasses = 0; HR(mFX->Begin(&numPasses, 0)); HR(mFX->BeginPass(0)); // Draw scene mesh. HR(mFX->SetMatrix(mhLightWVP, &(mSceneWorld*mLightVP))); HR(mFX->CommitChanges()); for(UINT j = 0; j < mSceneMtrls.size(); ++j) { for(UINT j = 0; j < mSceneMtrls.size(); ++j) { HR(mSceneMesh->DrawSubset(j)); } } // Draw car mesh. (substituted w/ a tree with trunk and billboard leaves/branches) HR(mFX->SetMatrix(mhLightWVP, &(mCarWorld*mLightVP))); HR(mFX->CommitChanges()); HR(gd3dDevice->SetRenderState(D3DRS_ALPHATESTENABLE, true)); HR(gd3dDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL)); HR(gd3dDevice->SetRenderState(D3DRS_ALPHAREF, 200)); for(UINT j = 0; j < mCarMtrls.size(); ++j) { for(UINT j = 0; j < mCarMtrls.size(); ++j) { HR(mCarMesh->DrawSubset(j)); } } HR(gd3dDevice->SetRenderState(D3DRS_ALPHATESTENABLE, false)); HR(mFX->EndPass()); HR(mFX->End()); mShadowMap->endScene(); } Here is the .fx file //============================================================================= // LightShadow.fx by Frank Luna (C) 2004 All Rights Reserved. // // Does lighting and shadowing with shadow maps. //============================================================================= uniform extern float4x4 gLightWVP; static const float SHADOW_EPSILON = 0.00005f; static const float SMAP_SIZE = 512.0f; void BuildShadowMapVS(float3 posL : POSITION0, out float4 posH : POSITION0, out float2 depth : TEXCOORD0) { // Render from light's perspective. posH = mul(float4(posL, 1.0f), gLightWVP); // Propagate z- and w-coordinates. depth = posH.zw; } float4 BuildShadowMapPS(float2 depth : TEXCOORD0) : COLOR { // Each pixel in the shadow map stores the pixel depth from the // light source in normalized device coordinates. return depth.x / depth.y; // z / w } technique BuildShadowMapTech { pass P0 { vertexShader = compile vs_2_0 BuildShadowMapVS(); pixelShader = compile ps_2_0 BuildShadowMapPS(); } } struct Mtrl { float4 ambient; float4 diffuse; float4 spec; float specPower; }; struct SpotLight { float4 ambient; float4 diffuse; float4 spec; float3 posW; float3 dirW; float spotPower; }; uniform extern float4x4 gWorld; uniform extern float4x4 gWVP; uniform extern Mtrl gMtrl; uniform extern SpotLight gLight; uniform extern float3 gEyePosW; uniform extern texture gTex; uniform extern texture gShadowMap; sampler TexS = sampler_state { Texture = <gTex>; MinFilter = LINEAR; MagFilter = LINEAR; MipFilter = LINEAR; AddressU = WRAP; AddressV = WRAP; }; sampler ShadowMapS = sampler_state { Texture = <gShadowMap>; MinFilter = POINT; MagFilter = POINT; MipFilter = POINT; AddressU = CLAMP; AddressV = CLAMP; }; void LightShadowVS(float3 posL : POSITION0, float3 normalL : NORMAL0, float2 tex0 : TEXCOORD0, out float4 oPosH : POSITION0, out float3 oPosW : TEXCOORD0, out float3 oNormalW : TEXCOORD1, out float3 oToEyeW : TEXCOORD2, out float2 oTex0 : TEXCOORD3, out float4 oProjTex : TEXCOORD4) { // Transform to homogeneous clip space. oPosH = mul(float4(posL, 1.0f), gWVP); // Transform vertex position to world space. oPosW = mul(float4(posL, 1.0f), gWorld).xyz; // Transform normal to world space (assume no non-uniform scaling). oNormalW = mul(float4(normalL, 0.0f), gWorld).xyz; // Compute the unit vector from the vertex to the eye. oToEyeW = gEyePosW - oPosW; // Pass on texture coords to PS oTex0 = tex0; // Generate projective texture coordinates. oProjTex = mul(float4(posL, 1.0f), gLightWVP); } float4 LightShadowPS(float3 posW : TEXCOORD0, float3 normalW : TEXCOORD1, float3 toEyeW : TEXCOORD2, float2 tex0 : TEXCOORD3, float4 projTex : TEXCOORD4) : COLOR { // Interpolated normals can become unnormal--so normalize. normalW = normalize(normalW); toEyeW = normalize(toEyeW); // Light vector is from pixel to spotlight position. float3 lightVecW = normalize(gLight.posW - posW); // Compute the reflection vector. float3 r = reflect(-lightVecW, normalW); // Determine how much (if any) specular light makes it into the eye. float t = pow(max(dot(r, toEyeW), 0.0f), gMtrl.specPower); // Determine the diffuse light intensity that strikes the vertex. float s = max(dot(lightVecW, normalW), 0.0f); // Compute the ambient, diffuse and specular terms separately. float3 spec = t*(gMtrl.spec*gLight.spec).rgb; float3 diffuse = s*(gMtrl.diffuse*gLight.diffuse.rgb); float3 ambient = gMtrl.ambient*gLight.ambient; // Compute spotlight coefficient. float spot = pow(max( dot(-lightVecW, gLight.dirW), 0.0f), gLight.spotPower); // Sample decal map. float4 texColor = tex2D(TexS, tex0); // Project the texture coords and scale/offset to [0, 1]. projTex.xy /= projTex.w; projTex.x = 0.5f*projTex.x + 0.5f; projTex.y = -0.5f*projTex.y + 0.5f; // Compute pixel depth for shadowing. float depth = projTex.z / projTex.w; // Transform to texel space float2 texelpos = SMAP_SIZE * projTex.xy; // Determine the lerp amounts. float2 lerps = frac( texelpos ); // 2x2 percentage closest filter. float dx = 1.0f / SMAP_SIZE; float s0 = (tex2D(ShadowMapS, projTex.xy).r + SHADOW_EPSILON < depth) ? 0.0f : 1.0f; float s1 = (tex2D(ShadowMapS, projTex.xy + float2(dx, 0.0f)).r + SHADOW_EPSILON < depth) ? 0.0f : 1.0f; float s2 = (tex2D(ShadowMapS, projTex.xy + float2(0.0f, dx)).r + SHADOW_EPSILON < depth) ? 0.0f : 1.0f; float s3 = (tex2D(ShadowMapS, projTex.xy + float2(dx, dx)).r + SHADOW_EPSILON < depth) ? 0.0f : 1.0f; float shadowCoeff = lerp( lerp( s0, s1, lerps.x ), lerp( s2, s3, lerps.x ), lerps.y ); // Light/Texture pixel. Note that shadow coefficient only affects diffuse/spec. float3 litColor = spot*ambient*texColor.rgb + spot*shadowCoeff*(diffuse*texColor.rgb + spec); return float4(litColor, gMtrl.diffuse.a*texColor.a); } technique LightShadowTech { pass P0 { // Specify the vertex and pixel shader associated with this pass. vertexShader = compile vs_2_0 LightShadowVS(); pixelShader = compile ps_2_0 LightShadowPS(); } } The tree draws fine with alpha blended leaves...it's the shadow that shows up as the quad based billboard. I know I have to do some type of test...maybe in the shader.  Not too sure. Anyone know how to do this?
  8. I am having a problem when I go from windowed mode to full screen mode. My skydome will not render properly, the magenta background color shows through on different polygons. I think it has something to do with the near far plane being set...but between full screen and windowed mode every parameter for the camera is identical! Here is a link to the picture: http://www.seacowgames.com/defective%20skybox.JPG Or it can be found here: http://seacowgames.com/blog/ I've tried resizing the mesh in max to no avail. Any help?
  9. Apparently if any headers are included in an .fx file, they need to be locatable to the compiler. Extended debugging helped out, so I recommend anyone having similar problems with rogue .fx files to follow the link http://www.gamedev.net/community/forums/topic.asp?topic_id=502014. Why oh why Microsoft decided to include a Vista dll with a XP SDK is beyond me. Good luck.
  10. Does this have anything to do with the d3d9.dll that was mismatched between XP and Vista with the latest DirectX SDK? I am using D3DX throughout. Anyone?
  11. So it looks like GameDev won out the flipcode gavedev battle from 8 years ago, eh? Very well. On to my question: I am working on a terrain engine using DirectX 9/10, GAIA, specifically. I've gotten the code to build, after much effort. When I run the code through the debugger, some effects work, other's don't. Water will render, lens flares will not. The return values for the lens flare renders are OK. But...when I run the .exe OUTSIDE the debugger (dev studio 2008), I get my lens flares...why? I already read through http://www.gamedev.net/community/forums/topic.asp?topic_id=502014, so I may not be using the correct debug libs, or I may have to set DirectX to use debug. Is there anything else I might be missing?