locked
Direct3D 11 Shaders

    Question

  • Hi --

    Whenever I try any lighting ideas in HLSL in Metro Direct3D I always get an assertion failure:
    ppltasks.h Expression: _SynchronousCancel && !IsCompleted()

    Can anyone show an example of a very simple lighting sample in HLSL -- just something to extends the basic shader that comes in the Visual Studio template when you create a Direct3D project type.

    Thank you!

    Monday, July 30, 2012 4:11 AM

Answers

  • Ahhhh... I found my problem!

    It turns out I was trying to learn HLSL by doing some tutorials online along with the basic cube that Visual Studio 2012 RC uses as a project template for Direct 3D project types. I started using HLSL tutorials with things like float4 Normal : NORMAL; but the basic cube in the VS 2012 project does not have norm it has only pos and color:

    struct VertexPositionColor{    
     DirectX::XMFLOAT3 pos;    
     DirectX::XMFLOAT3 color;
    };

    So I now realize I must change my cube to accommodate what I am doing with my HLSL (seems so obvious now :) For example in my case change the struct to include  DirectX::XMFLOAT3 norm; and also change the cubeVertices[] to comply with this struct.

    The SDK Direct3D tutorial sample has a great example and can be used to compare to the VS 2012 Template Direct3D project's basic cube to see the differences.


    Monday, July 30, 2012 2:52 PM

All replies

  • You can check D3D error message at [Output] window.

    C++ DX11

    Monday, July 30, 2012 12:01 PM
  • Hi --

    Yes I do that but it does not help me understand what is happening. I get... Output window: Platform::InvalidArgumentException ^ at memory location 0x008DA584. HRESULT:0x80070057

    So for example I try to do the Diffuse and Specular example form this site: http://www.neatware.com/lbstudio/web/hlsl.html and as soon as I use float4 Normal : NORMAL; I get the error.

    What would be a really great help is if someone could put up a very simple lighting example that works in Metro apps DirectX 11.1 so I can then compare/test/etc. while I try to learn HLSL.

    Thank you!

    p.s is this the right way to do lighting in Metro - by writing HLSL in two files (vertex and pixel shader)? It sems like there are so many different ways to do DirectX in the different versions it makes it interesting to try to learn :)


    • Edited by mcngraphics Monday, July 30, 2012 2:07 PM typo
    Monday, July 30, 2012 2:06 PM
  • Ahhhh... I found my problem!

    It turns out I was trying to learn HLSL by doing some tutorials online along with the basic cube that Visual Studio 2012 RC uses as a project template for Direct 3D project types. I started using HLSL tutorials with things like float4 Normal : NORMAL; but the basic cube in the VS 2012 project does not have norm it has only pos and color:

    struct VertexPositionColor{    
     DirectX::XMFLOAT3 pos;    
     DirectX::XMFLOAT3 color;
    };

    So I now realize I must change my cube to accommodate what I am doing with my HLSL (seems so obvious now :) For example in my case change the struct to include  DirectX::XMFLOAT3 norm; and also change the cubeVertices[] to comply with this struct.

    The SDK Direct3D tutorial sample has a great example and can be used to compare to the VS 2012 Template Direct3D project's basic cube to see the differences.


    Monday, July 30, 2012 2:52 PM