Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

TiagoCosta

Member Since 26 Nov 2008
Offline Last Active Today, 04:21 PM
-----

#5062761 [VS2012] Debugging pixel shader

Posted by TiagoCosta on 18 May 2013 - 04:34 AM

Hi,

 

I'm trying to debug a pixel shader in VS2012 but I can't access the pixel history because "This draw call is using system-value semantics and interferes with pixel history computation"

 

The vertex shader generates a fullscreen triangle using SV_VertexID...

 

Is it impossible to debug pixel shaders associated with vertex shaders that use SV_VertexID?

 

Thanks




#5059754 DX11 InstanceDataStepRate

Posted by TiagoCosta on 06 May 2013 - 09:53 AM

It can be useful in some effects.

 

Example:

 

Drawing a model multiple times at different positions in pairs (each pair with a different tint).

struct VS_IN
{
    float3 position;
    ...
    float4x4 instanceWorld : mTransform ;
    float4 tint : mTint;
};
 

 

Since 2 instances should be draw with the same tint the instance step rate is 2

const D3D11_INPUT_ELEMENT_DESC instlayout[] =
{
    ...
    { L"mTransform", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 0, D3D11_INPUT_PER_INSTANCE_DATA, 1 },
    { L"mTransform", 1, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 16, D3D11_INPUT_PER_INSTANCE_DATA, 1 },
    { L"mTransform", 2, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 32, D3D11_INPUT_PER_INSTANCE_DATA, 1 },
    { L"mTransform", 3, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 48, D3D11_INPUT_PER_INSTANCE_DATA, 1 },
    { L"mTint", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 2, 0, D3D11_INPUT_PER_INSTANCE_DATA, 2 },
};

 

Most common instancing effects use step rate = 1 though.




#5053942 Render queue texture clearing

Posted by TiagoCosta on 16 April 2013 - 01:05 PM

Do I need a seperate command for submitting a state group only for my render queue (because now I only support render instance submitting), or do you mean "submit" here more like explicitely set those states here?

 

Can't you simply submit the state group in a RenderItem with the draw call as null?
Or you could explicitely set those states... Anyway should work fine.




#5053792 Render queue texture clearing

Posted by TiagoCosta on 16 April 2013 - 05:48 AM

IMO, you should create a new class, let's call it Stage along with a new StateGroup, and move the render target binding/clearing to it (now the Effects state group will only bind the hardware shaders and set default shader values).

 

In my renderer, models can have more than one RenderItem (draw call/state groups pair) each one is assigned to a Stage. Example: the RenderItem assigned to the Shadow Mapping stage doesn't need the material state group to be executed)

 

As you can read in this topic, the renderer has multiple buckets (lists of RenderItems) each bucket is associated with a Stage. Before rendering the renderer goes through the Scene (a list of model instances, etc) finds all the model instances and puts its RenderItems in the appropriate bucket.

 

Then Stages are executed according to the order defined in the renderer_config file: the bucket associated with each stage is sorted (if needed), the state group of that stage (containing the render target clearing/binding commands) is submitted and only then the RenderItems inside the bucket are submitted.




#5053514 Render queue texture clearing

Posted by TiagoCosta on 15 April 2013 - 12:08 PM

I do also have stage groups, probably a lot like yours. As in one of Hodgmans posts, my model, material and effect all holds their own state group, which the model puts together and submits to the queue.

 

In my implementation the models don't have access to the render queue, (in my opinion the model class should be independent on the Renderer), instead the model class has a method getStateGroups() an array containing the effect, material, mesh, model state groups.

 

for(Model model : models)
{
    queue.submit(model.getStageGroups(), model.getNumStateGroups();
}

 

 

Now that you say "models, materials and effects should not have anything to do" with clearing render targets - how do you set the stage group anyway? Since each of those entities have their own stage groups, command injection has to go through them, at some point, right? E.g. my model has a "SetVertexConstant"-method that adds a VertexConstantX-command to the stage. How do you handle this? Thats a question I was going to ask anyway at some point, because I was really unsure how this is normally done.

 

The Stage group is submitted individually before the models. How do you bind render targets/depth stencil buffers?

 

I don't have commands to set individual constants, instead I work with constant buffers, the model "SetVertexConstant"-method will change the value of the constant in a POD buffer then the model uses two commands, UpdateCBuffer (that fills a D3D buffer with the contents of the POD buffer containing the constants) and VSBindCBuffer0 (that binds the D3D buffer to the constant buffer slot 0 of the vertex stage)




#5053497 Render queue texture clearing

Posted by TiagoCosta on 15 April 2013 - 11:26 AM

Hi,

 

I also implemented a render queue like discussed in "frostbite render architecture".

 

have commands called ClearRenderTarget and ClearDepthStencilTarget that I put inside a "Stage" state group that is executed at the beginning of the corresponding stage.

 

I don't think Models, Materials or Effects have anything to do with clearing render targets that's why I have the Stage state group.

 

(I also have a command for updating buffers, etc in case you're wondering).




#5053381 Animation in DirectX 9, 10 and 11

Posted by TiagoCosta on 15 April 2013 - 02:58 AM

The loader class should output API independent data (arrays of C structures containing the model/animation data). You can use the 3DS max sdk or Assimp to load the files. IMO Assimp is easier to use and supports a wide range of formats.

To render/play the animations you have to write specific code to each D3D version because each creates its own buffers, etc. Unless you just write the renderer in D3D11 and set the feature level to D3D9 so it runs on D3D9 GPUs on Windows 7


#5046483 hlsl normalize a float9 ?

Posted by TiagoCosta on 25 March 2013 - 04:12 AM

If data[9] is simply a 9 dimensional vector you can do it manually:

 

float z = 0;

for(int i = 0; i < 9; i++)
    z += pow(data[i], 2);

z = sqrt(z);

for(int i = 0; i < 9; i++)
    data[i] /= z; //Or use a temporary vector if "data" is in a constant buffer

 

 

If data[9] is a 3x3 matrix divide each value by the determinant.

 

Do you have to normalize it in the shaders? It would be faster do normalize it in the CPU and send to the shaders.




#5043985 [june 2010 sdk]Wheres D3D11Reflect defined?

Posted by TiagoCosta on 17 March 2013 - 10:50 AM

The file "d3dcompiler.inl" is located here: "C:\Program Files (x86)\Windows Kits\8.0\Include\um"

My guess is that the last Windows update moved it from the June 2010 SDK folder...

 

If you can't find it, this is the whole file:

//////////////////////////////////////////////////////////////////////////////
//
//  Copyright (c) Microsoft Corporation.  All rights reserved.
//
//  File:       D3DCompiler.inl
//  Content:    D3D Compilation Inline Functions
//
//////////////////////////////////////////////////////////////////////////////

#ifndef __D3DCOMPILER_INL__
#define __D3DCOMPILER_INL__

#include "d3dcompiler.h"

//////////////////////////////////////////////////////////////////////////////
// APIs //////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////

//----------------------------------------------------------------------------
// Wrappers to retrieve specific reflection interfaces.
//----------------------------------------------------------------------------

FORCEINLINE HRESULT
D3D11Reflect(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData,
             _In_ SIZE_T SrcDataSize,
             _Out_ ID3D11ShaderReflection** ppReflector)
{
    return D3DReflect(pSrcData, SrcDataSize,
                      IID_ID3D11ShaderReflection, (void**)ppReflector);
}

#endif // #ifndef __D3DCOMPILER_INL__

 

 

Just put that in whatever folder you want. smile.png




#5043936 Artefacts using big model

Posted by TiagoCosta on 17 March 2013 - 06:14 AM

Could please someone give a simple example with logarithmic depth buffer for DirectX 11, because from the article hard to understand how to implement it?

 

 

Add this line to the end of the vertex shader after the projection multiply.

 

out.Position.z = log(C*out.Position.z + 1) / log(C*Far + 1) * out.Position.w;

 

where C is a constant used to choose the resolution near the camera: try it with C = 1.0f.

and Far is the far plane distance used to create the projection matrix.




#5043932 [june 2010 sdk]Wheres D3D11Reflect defined?

Posted by TiagoCosta on 17 March 2013 - 06:11 AM

According to the docs it's defined in D3DCompiler.inl so including D3DCompiler.h should do the trick.




#5042663 Applying light effects and reflection

Posted by TiagoCosta on 13 March 2013 - 05:41 AM

If you want specular light reflections use a light and Blinn-Phong.

 

Why are you trying to use reflection maps if you want lighting?




#5042087 Artefacts using big model

Posted by TiagoCosta on 11 March 2013 - 04:39 PM

There are some methods to "increase" the precision of depth buffers, this article talks about some. Take special attention reading the logarithmic depth buffer part.




#5041641 Whats the shader data a Material class holds?

Posted by TiagoCosta on 10 March 2013 - 05:18 PM

This is how I do it (this is based on Hodgman posts):

 

At asset build time I assign each material a set of base "shader resources" (one for each pass the material should be drawn in).

 

The material chooses the right permutation of each "shader resource" based on what it needs and then, using the correct shader permutation, it finds out which cbuffers/textures slots to use using shader reflection.

 

A material will contain a bitset where each bit specifies a shader feature that the material needs and the Renderer will use that bitset to choose the right shader permutation every time the material is used. So you can change this list to change the material appearance by changing the bitset. 

 

The number of lights or other external factors shouldn't modify the material, after all they're external factors.

So in my engine I have a class called Actor (basically a Model instance), that holds a pointer to a Model and vectors like position, rotation, etc.

The Actor also has a bitset, like the Materials, that will dynamically be updated based on the Actor/lights positions, so the Renderer will get the bitsets from Material/Actor/Geometry and other classes in order to choose the right shader permutation.




#5032972 Good Books for Intermediate Graphics Programmer

Posted by TiagoCosta on 16 February 2013 - 03:50 AM

A MUST HAVE: Buy Real Time Rendering, 3rd edition! (if you haven't already) It's from 2008 but the content is still extremely useful and will teach you the "fundamentals" you're looking for .

 

You can also check out "Mathematics for 3D Game Programming and Computer Graphics, Third Edition" or "3D Math Premier for Graphics and Game Development".

 

Then you have the ShaderX/GPU Pro series that contain a wide range of techniques that might be useful to you (check the TOC before buying).

 

Here you can find a good list a graphics books

 

Also read papers/presentations from SIGGRAPH and GDC for free and useful techniques, like this ones






PARTNERS