Leafteaner

Members
  • Content count

    92
  • Joined

  • Last visited

Community Reputation

860 Good

About Leafteaner

  • Rank
    Member
  1. If you are trying to retrieve a constant buffer that is currently bound to the device, this is the only way that I'm aware of to do it.  But it does seem fairly well documented to me.  The first parameter is the starting register, the second is the number of buffers you want to retrieve starting from the register you gave as the first parameter, and the last is a pointer to the array of ID3D11Buffer pointers where you want to store the results. So if you wanted to get the constant buffer in register 1, you would do something like: ID3D11Buffer* buffer[1]; context->VSGetConstantBuffers(1, 1, &buffer);
  2. Pass entire vector of objects to constructor by reference?

    I'm going to assume that your variable heroes is not a pointer, in which case you should not use the * operator and just pass it directly to the constructor: spells.push_back(new Star(heroes));   It works for your single objects since they are pointers.  
  3. When I'm rendering VSM/ESM to color multisampled targets I'm getting some pretty severe numerical stability issues, flickering white blocks of pixels inside the shadow regions. There's no issue when constructing the VSM or ESM from a multisampled depth buffer.   It took a good amount of searching to track down any reason for this, but it sounds like multisampled color render targets are having some gamma correction applied behind the scenes?  I wasn't able to find any info about this in the d3d docs, or really anywhere except for some random slides. Is this the case? If so is there a way to disable this or any way I can set the formats to avoid it?   Ideally I would like to use normalized distance to light as my depth and there's a small performance hit having to build the VSM in separate pass.
  4. There are a lot of cases where it's useful or required to use dynamic branching in this way, where one thread needs to perform some operations. But I'm not sure if this is what you really want to be doing here, since you are using a single thread to loop over the entire group's shared data.  Have you looked into InterlockedMax?  You should be able to compute your max depth without doing any sort of looping over the data, or need for the cache other than a single groupshared uint. Just remember you will need to convert your sampled depth to uint first, and then convert the final max depth back to a float before storing in your max z buffer.     Edit:   As far as the branching goes, it's perfectly ok to have the first thread do some work if it's going to be shared across the group.  For example, computing the frustum for each tile would just need to be done for the one thread. Obviously only do this in cases where it only makes sense for one thread to do it.   Based on the comments it looks like you have your light list building code inside that if statement. This can be distributed as well.  I believe one of the tile based shading articles in GPU Pro 4 shows how to do this, and I'm pretty sure it's done in this sample.  Something like this:   // Get a list of the lights that affect the tile for(uint i=0; i<g_NumLights; i+=GROUP_SIZE) { uint lightIndex = groupIndex + i; if( lightIndex < g_NumLights ) { // Check if the light affects this tile if( light is visible to the tile ) { // Update the counter uint currentTileLightIndex; InterlockedAdd(sharedTileLightCounter, 1, currentTileLightIndex); // Add the light to the list if(currentTileLightIndex < MAX_LIGHTS) g_LightList[currentTileLightIndex] = lightIndex; } } } GroupMemoryBarrierWithGroupSync();
  5.   Well you definitely don't have to hard code the values. In the 2d games I've worked on we've always used an animation tool to determine the image rects for each frame, and this was exported to file.  We wrote our own editor so we could tie events to certain frames a bit easier but I know there are a few free tools that will do this from a sprite sheet. I'm sorry but I can't remember any of the names at the moment, try google. But if you prefer having your frames as individual images then go for it, do whatever works best for your project.
  6. If you are targeting d3d11, you can store your page visibility list in a RWStructuredBuffer<int>.  All you need is the page ID, which is easy to compute from the UV coords.  In my engine I store this as an array of all pages, and increment the corresponding page index in the pixel shader in the geometry pass.  This also gives you the number of pixels that use each page, which you can use to prioritize the page streaming.
  7. [.net] C# Windows Forms Events Question

    Quote:Original post by CodeCriminal Oh yeah, i see thank you! [smile] Just one more thing, i have something like this set up *** Source Snippet Removed *** But i want to check which save button was pressed, the Save As or Save, so i can skip opening a dialog if the file loaded into the application is not a brand new file. Like other applications do. Do i have to check against sender? if so how? Yes the control that triggered the event is the sender param. To check you can just do something like: if(sender==toolStripItemSave)
  8. OpenGL 3d file format loader tutorial

    Quote:Original post by DarkBalls I think I don't need all the 3D file format. I heard that 3ds and md2 is good in games that's why I'll focus on those formats. But maybe I'll need that 3rd party library in the future so I'll bookmark it. Thank you very much RealMarkP. I second using ASSIMP, unless of course you are trying to learn the details about loading the particular file formats. ASSIMP loads all of the supported formats into a single framework, so you only have to code one loading path and it will work for lots of different file types. But if you are going the route of learning the details, the book Terrimus linked to is pretty good.
  9. Deferred shading artifacts....[FIXED] WOOT!

    Quote:I thought i converted that shader from point to directional fully... Here it looks like it's a point light the way you get the direction: float3 lightDir = float3( lightpos.xyz - position3); float d = length(lightDir); lightDir = normalize(lightDir); float attenuation = 1.0/(kC + kL * d + kQ *d *d);
  10. Deferred shading artifacts....[FIXED] WOOT!

    I'm not sure what ModelViewIT is (where you store your normal), but you can't mix vector spaces for your lighting. It looks like you store world space positions, and maybe? view-space normals, and you transform the light position to view-space as well. If you want to shade in view-space, keep everything in view-space and multiply the position by the ModelView instead of ModelToWorld when you store it in the GBuffer. If you want to shade in world-space keep the position the same and make sure the normal and light are in world space. And by clamp, I meant to keep your dot product in the 0-1 range, but it looks like you are doing this. Quote:its a directional light that is behind the camera... in your code it is a point light... Based on your code: float spec_power; if(nDotLD &lt;= 0.0) { spec_power = 0.0; } else spec_power = pow(nDotHA, shininess); You will get black artifacts if nDotLD is <=0 when it shouldn't be (keep a consistent vector space for shading as above), your shininess is somehow <1, or nDotHA is <1. Make sure your shininess is actually specular power value( eg probably > 4) and not really a shininess factor from 0-1.
  11. Initialization Question

    hmmm. Are you checking the HRESULT values when you try to create them? Either the create functions are failing or somewhere they are getting released and set to NULL before they get to the shape class.
  12. Initialization Question

    Quote:That sounds like you have two different instances of your objects. Are you missing inclusion guards (#pragma once or #ifndef...). This would give a linker error, at least in VS. Quote:My question is, is there a better way to do this? I am currently doing this and I call InitializeVertexTypes, all the data becomes valid but then later in my code all of the variables become erased back to (0x00000) like they were reset. If I'm understanding you correctly, that first block of code are the globals that get setup once at load time. And then m_VD points to one of those global IDirect3DVertexDeclaration9's in gcVertexDefinitions? If you are doing this once at load time, and then release them when you exit, there should not be a problem. I would have to guess that you are releasing them somewhere in your code, perhaps your shape class releases m_VD?
  13. Deferred shading artifacts....[FIXED] WOOT!

    Without seeing the code for your specular I can't be certain. But my guess is that you are not clamping the dot product. I don't know which type of specular you compute, but try clamping the dot product in the 0-1 range (HLSL saturate).
  14. Yup it would definitely be a problem, there's no way for the driver to know what render targets are used for what. I can't see any way for it to work correctly unless it's done at the very end after all the rendering is finished and added directly to the framebuffer. But then of course HDR and other post processing can't be applied to it...
  15. Interpolating Texture Color from 3 Vertices

    Since you pass the type from the VS, it's going to get interpolated across the polygon in the PS. Because of this, it is only going to equal 0.0 on the very corner where that vertex has the value of 0. If you want to do a smooth blend across the polygon, I think it will work if you lerp between the textures using the type. Try this: float4 TerrainPS(float2 tiledTexC : TEXCOORD0, float2 nonTiledTexC : TEXCOORD1, float shade : TEXCOORD2, float type : TEXCOORD3) : COLOR { //Detail Map float3 c0 = tex2D(Tex0S, tiledTexC).rgb; //Rock Texture float3 c1 = tex2D(Tex1S, nonTiledTexC).rgb; //Grass Texture float3 c2 = tex2D(Tex2S, nonTiledTexC).rgb; // Linearly interpolated between the two values float3 final = lerp(c1, c2, type); //Add the detail map final *= c0; return float4(final, 1.0f); }