Jump to content

  • Log In with Google      Sign In   
  • Create Account

thmfrnk

Member Since 17 Mar 2013
Offline Last Active Mar 31 2016 01:58 PM

Topics I've Started

Texture Coord Generation in Shader

31 March 2016 - 01:02 PM

Hi,

 

I'm looking for a way to give my users the option to use automatically generated UV coords instead of UVs delivered by imported meshes. So something equal like in Cinema 4D where you can choose between UVW, Cubic, Cylindric, Spherical, etc.. mapping. Finally I want to generate the UVs based on vertex positions and normals. I think this should be possible in Vertex or Geometry shader, but I've no idea actually. I know the result would not be always perfect for non-convex meshes, but most cases are for simple boxes, spheres or planes.

 

Any help, links or codes are appreciated.

 

Thanks,

Thomas


CS write to Texture

01 July 2015 - 08:40 AM

Hi,

 

I'm getting crazy actually. I simply try to write to a texture using a Compute Shader. I've tried lots of formats but the texture keeps black. Is there anything I forgot?

 

Here some code:

 

This is how I create Texture, SRV and UAV

        Dim TexDex As New Texture2DDescription
        TexDex.Format = DXGI.Format.R16G16B16A16_Float
        TexDex.ArraySize = 1
        TexDex.BindFlags = BindFlags.ShaderResource Or BindFlags.UnorderedAccess
        TexDex.Height = View.Camera.Viewport.Height
        TexDex.Width = View.Camera.Viewport.Width
        TexDex.MipLevels = 1
        TexDex.Usage = ResourceUsage.Default
        TexDex.SampleDescription = New DXGI.SampleDescription(1, 0)
        TexDex.CpuAccessFlags = CpuAccessFlags.None

        LitBuffer = New Texture2D(MyEngine.Device, TexDex)
        LitBuffer.DebugName = "TestBuffer"

        Dim SRV As New ShaderResourceViewDescription
        SRV.ArraySize = 1
        SRV.Format = DXGI.Format.R16G16B16A16_Float
        SRV.Dimension = ShaderResourceViewDimension.Texture2D
        SRV.MipLevels = 1

        LitBuffer_SRV = New ShaderResourceView(MyEngine.Device, LitBuffer, SRV)

        Dim UAV As New UnorderedAccessViewDescription
        UAV.Dimension = UnorderedAccessViewDimension.Texture2D
        UAV.FirstElement = 0
        UAV.Format = DXGI.Format.R16G16B16A16_Float
        UAV.ElementCount = TexDex.Width * TexDex.Height

        LitBuffer_UAV = New UnorderedAccessView(MyEngine.Device, LitBuffer, UAV)

and here my simple Compute Shader (I just want to write 255x255 pixels) so I dispatch him with 8x8x1 groups

RWTexture2D<float4> LitTexture : register ( u0 );


[numthreads(32, 32, 1)]
void RenderLight( uint3 localIdx : SV_GroupThreadID, uint3 groupIdx : SV_GroupID, uint3 globalIdx : SV_DispatchThreadID )
{
	
	LitTexture[globalIdx.xy] = float4(1.0f, 1.0f, 0.0f, 1.0f);
}

what I'm doing wrong?

 


"Fade" - interpolation of a ViewMatrix

30 June 2015 - 02:03 AM

Hi,

 

In my editors I always try to keep the camera movements as smooth as possible. Now I try to get this done by interpolating the ViewMatrix. I want that my Camera should follow my mouse interactions with a small delay (don't know how to explain in english).

So finally I have an ViewMatrix (will be used for rendering) and ViewMatrixTo (the target matrix he should fade to).

 

My first idea was to simply interpolate each component of the matrix with a function like this:

Public Shared Sub ApproachTo(ByRef Value As Single, ByVal ValueTo As Single, ByVal Delay As Single, Optional MinDiff As Single = 0.01!)
  Value = (Delay * (Value - ValueTo)) + ValueTo
  If Math.Abs(ValueTo - Value) < MinDiff Then Value = ValueTo
End Sub


Public Shared Sub ApproachMatrix(ByRef MatIn As Matrix, ByVal MatrixTo As Matrix, ByVal Delay As Single)
   For c As Integer = 0 To 3
      For r As Integer = 0 To 3
        ApproachTo(MatIn.Item(c, r), MatrixTo.Item(c, r), Delay, 0.00001)
      Next
   Next
End Sub

This is working, but it produces distortions because I think its a linear interpolation and the rotation/position components needs to be interpolated in a spherical way? I already found some slerp functions on quaternions and vectors but I don't really have a "factor", I only have a CurrMatrix and ToMatrix and every frame he should approach this matrix.


Best technique for lighting

24 June 2015 - 10:24 AM

Hey Guys,

I'm working on a new engine which is focused on lighting. I've originally written my first version in DX9 and doing a new implementation on DX11 now. I've already implemented Tiled-Based Pointlights (based on Intel samples) which is working insane. But now it comes to a more complex part - my spotlights. My Engine should be able to handle hundreds of spotlights including shadows. Each of my spotlights have a shadowmap and projection texture.

My old DX9 approach:
- Shadowmapping was done in old-school way by rendering scene from view of light with some frustum culling.
- The projection was done deferred and culled by render a mesh in form of the light frustum.

This all was done per light, so quite CPU heavy. Also the culling is not optimal, because the full way from light to surface is also shaded. The overal performance was ok and on modern cards it's possible to get ~300 dynamic lights working.

However, now with DX11, ComputeShader and lots of other cool stuff I think there could be a better way? I was also thinking about something like the TiledBased system, but I think its difficult to get all the textures at once in the shader.

Would be cool if someone haves an idea,
Thanks, Thomas
 


Actively Developed > DirectX 12?

15 June 2015 - 01:07 PM

Hey,

 

we're starting a new big project based on DirectX 11 and I've already started with SlimDX, same as with my previous projects where SlimDX was always perfect. But it looks more and more that SlimDX is a dead project? Will it comes out with DirectX 12 support? Should I better switch to SharpDX?

We're using VB.NET in our projects, so we decided to use SlimDX because of some problems with SharpDX and VB.NET.

 

However what you guys would suggest me? 

Cheers,

Thomas


PARTNERS