Advertisement Jump to content
  • Advertisement

dave09cbank

Member
  • Content Count

    91
  • Joined

  • Last visited

Community Reputation

231 Neutral

About dave09cbank

  • Rank
    Member
  1. Ignore the previous post #14   It was cause of my stupidity.    the reason for the issue was that the texture to which i would render to my entire scene wasn't being initialised correctly for the correct size which had caused the issue above. In case it helps someone else.
  2. Ok i have progressed further with the rendering to texture.    At this moment my rendered texture isn't rendered of correct size. The size changes once i perform zoom by updating the  Z value on the view-projection matrix which eventually stops updating its size once its reached the correct size.   For whatever reason the texture is not filling the entire quad and i dont know why. How i know this: In my shader i just return a single colour [gray float4(0.5f, 0.5f, 0.5f, 1) ] instead of the sampled colour.    And from what i conclude is this: my texture is either of the not same size as the quad or something else is going on.   The issue seen is via this link   Any suggestions anyone ?
  3. OK i have figured out as to why the images were being rendered with weird shaped quad being rendered.   The reason for this is that my matrices for WVP were getting transposed incorrectly on every alternate render call (transposed matrix being transposed again) , since they need to be in "row major".
  4. thanks for the reply @Norman Barrows   After reading and implementing it in the code, i can get the render to texture work with WPF (as i used previously), with DirectX API underneath the hood.   However i still have a issue when i zoom in.    Issue:  See image flashing and weird shaped quad being rendered. i have attached a zip with the 3 videos in it. (just pretend you don't see watermark in the video)   Download Link:  https://dl.dropboxusercontent.com/u/5196736/Users/Kartik/DirectX/Dx%20Capture.zip   Any ideas as to why the above issue would occur ?
  5. thanks for the update @Norman Barrows   Yes i agree as after researching & reading on it.   However from what i read rendering to texture can have performance issues.  If this is the case then whats the main reason/best case scenario for its usage ?   Also the confusion i  still have : 1. As to how to copy it over to back buffer as in my case Invalidate the surface as using D3DImage (part of WPF) ? 2.  How would my ortho camera work in this case.   Though i'm still investigating the above two points, since i've just started to implement it in code.
  6. I haven't rendered to offscreen texture before but can look into it. However that brings me to next question. The yellow quads which I draw were simple example of quads filled with color as I do use different effects such as pixelated or blur the quad represented by yellow color. Could they still be achieved when trying to render offscreen texture as per your suggestion ? Currently how I render: 1. Draw background quad 2. Draw my yellow quads 3. Present the buffer or invalidate surface as using D3DImage part of WPF In order to do render to offscreen texture: 1. Have 2 render targets 2. Draw background quad on texture render target which not my main back buffer 3. Draw my yellow quad as above 4. Convert the offscreen render target to shader resource view 5. Map this shader resource view to update my back buffer which my main render target 6. Present the back buffer or invalidate surface as above Are my steps correct or am I approaching this completely in a wrong way.
  7. The way i zoom is i try to keep the point under the mouse at the same position by moving quad left/right/top/bottom if it needs to.   Also, i wasn't expecting an image detection algorithm.  The background image used was from live camera feed.
  8. Thanks for the reply @markypooch   I tried to upload some screenshots but for some reason they wont upload (no specific reason) so i have uploaded them to my dropbox.   Screenshot 1 Link: Scenario where the overlay quad (in yellow) are drawn on background quad   Screenshot 2 Link: Scenario where i have zoomed in and then drawn my overlay (in yellow)   Also,   My quads are drawn using actual screen co-ordinates which are transformed to world space in the shader file. All the quad i.e both background and overlay use the same matrices.   However, at this point I cant understand how would the scaling matrix fit as a solution ? Would you kindly explain/elaborate.   Thanks
  9. Hi,   I'm trying to draw an overlay quad/shape on top of another quad.   Now i could have my background quad zoomed in (using ortho camera) while i'm trying to draw my overlay object.  Thus, what i really want is to draw the overlay shape which takes into consideration how much i'v already zoomed in.   As currently it doesn't expand/enlarge when i zoom in and thus keeps the overlay shape of the same size.   Do i need to manually enlarge the shape and then draw or could it be all done in shader ?   Any suggestion how i could approach this.   Note: Using SharpDx & C# & Directx11
  10. After several days of trying different things i figured it out.   It seems the issue was being caused by my graphics card driver. Once i rolled back to a previous driver which i know worked everything worked fine as expected.   Note: Using AMG Radeon R9 series card with driver version 21.19.137.1 & Radeon Software version 16.9.2
  11.  I'm trying to create Direct2D render target. This was working fine before but recently it has stopped working and I don't know why & cant seem to figuree out why this has stopped. I have been on google and trying to figure out exactly why this is happening but cant seem to get any where. I'm using SharpDx with C# & Directx11 Any suggestions or help would be great.   I've attached some images below: [attachment=33700:Exception_A.PNG] [attachment=33701:Exception_B.PNG]  
  12. Thanks for the reply xycsoscyx    I have been trying out different suggestions mentioned by yourself and i can conclude the blending works but not as expected but have managed to narrow things down.   While trying to render images on Picture in Picture:   Firstly, i have separated all the drawing of quads in a class. using this class i can draw as many objects as required with calling a couple of functions including setting the following on a draw call: DxDevice.ImmediateContext.InputAssembler.InputLayout = m_shaderData.InputLayoutConfig; DxDevice.ImmediateContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleStrip; SetVertexBuffer(); DxDevice.ImmediateContext.VertexShader.Set(m_shaderData.VertexShaderConfig); DxDevice.ImmediateContext.PixelShader.Set(m_shaderData.PixelShaderConfig); DxDevice.ImmediateContext.Draw(4, 0); Now, from extensive testing and playing around what i have found is:   1. I have a quad drawing object which draws the background and a separate quad object to draw the flag png. Using this way the png would show the actual controls color.    Now if i enable the AlphaBlending, what i get is just a gray color filling the flag png quad. Also for this i have tried to update the render the rgb colors returned when i sample the texture: ShaderTexture.Sample(Sampler, input.TextureUV); the color returned is black : r=1, g=1, b= 1, a= 1     2. If i reuse the same quad object that i have used to draw the background image, and then draw the flag png then my background image is drawn underneath the flag png within the quad representing the flag png and my background image is not quad on the bigger quad.   Now from above (finding in point 2.); it seems the blending doesn't work if i draw using a new quad.   Any ideas why this would happen ?    
  13. I have now spent last few weeks trying to figure out what/where i'm going wrong but had no luck to do so.    Could anyone suggest anything on the above problem ?
  14. Thanks for the reply.    I think i'm performing the steps suggested in the 2nd suggestion i.e.  Draw the background image Draw the circle images invalidate the surface (purple control)   As suggested iv tried to enable/disable the blending  just before and after drawing the circle images (shown ins steps below) Draw background image Enable blending draw all circular images Disable blending Invalidate the texture surface   The code used to perform the blending: var renderTargetDesc = new RenderTargetBlendDescription(); renderTargetDesc.IsBlendEnabled = bEnable; renderTargetDesc.SourceBlend = BlendOption.SourceAlpha; renderTargetDesc.DestinationBlend = BlendOption.InverseSourceAlpha; renderTargetDesc.BlendOperation = BlendOperation.Add; renderTargetDesc.SourceAlphaBlend = BlendOption.One; renderTargetDesc.DestinationAlphaBlend = BlendOption.One; renderTargetDesc.BlendOperation = BlendOperation.Add; renderTargetDesc.AlphaBlendOperation = BlendOperation.Add; renderTargetDesc.RenderTargetWriteMask = ColorWriteMaskFlags.All; BlendStateDescription desc = new BlendStateDescription(); desc.AlphaToCoverageEnable = false; desc.IndependentBlendEnable = false; m_blendState?.Dispose(); m_blendState = new BlendState(m_Dx11Device, desc); desc.RenderTarget[0] = renderTargetDesc; if(bEnable) { m_Dx11Device.ImmediateContext.OutputMerger.SetBlendState(m_blendState, new Color4(0f), -1); } else { m_Dx11Device.ImmediateContext.OutputMerger.SetBlendState(null, new Color4(1.0f), -1); m_blendState?.Dispose(); }    Yet it doesn't seem to work and now the circle images aren't visible at all (just black screen) from which i assume either they are transparent completely or not render. However, i believe it not to be the later case.   Any further suggestion ?   Thanks.   NOTE: The images (background and circular) are being rendered using quad textures.
  15. Since by default blending is not enabled then it should work without giving/showing the issue as per the question asked.     1.  Using PNG image. I have tried setting the Alpha value in the pixel shader and it displays black where it's meant to be purple. So from my understanding it seems the alpha value is set to 0 in the image.  Using SharpDx i create the creature from the image data bytes. the texture format is B8G8R8A8_UNorm I do not set the blending state at this. Do i need to set it ? Return the alpha of the image itself without making any changes to it.   Furthermore, the circular images are drawn on top of the background image.   Why would it display the colour of the underlying control and not the background image ?   And if i take your suggestion from .4 and return the luminosity of the color as the alpha would that no affect the alpha when i actually need to display the alpha value as it is ?   Also will try to set the alpha blending state and see if that helps to resolve the issue. Thanks.   Edit: I've tried setting the blend state as below: m_renderTexture = CreateTexture2D(m_Dx11Device, iWidth, iHeight, BindFlags.RenderTarget | BindFlags.ShaderResource, SharpDX.DXGI.Format.B8G8R8A8_UNorm); m_RenderTargetView = new RenderTargetView(m_Dx11Device, this.m_renderTexture); m_Dx11Device.ImmediateContext.OutputMerger.SetTargets(m_RenderTargetView); m_Dx11Device.ImmediateContext.OutputMerger.SetTargets(m_RenderTargetView); // code to set the alpha blend state var renderTargetDesc = new RenderTargetBlendDescription(); renderTargetDesc.IsBlendEnabled = true; renderTargetDesc.SourceBlend = BlendOption.SourceAlpha; renderTargetDesc.DestinationBlend = BlendOption.InverseSourceAlpha; renderTargetDesc.BlendOperation = BlendOperation.Add; renderTargetDesc.SourceAlphaBlend = BlendOption.One; renderTargetDesc.DestinationAlphaBlend = BlendOption.SecondarySourceAlpha; renderTargetDesc.BlendOperation = BlendOperation.Add; renderTargetDesc.RenderTargetWriteMask = ColorWriteMaskFlags.All; BlendStateDescription blendStateDesc = new BlendStateDescription(); blendStateDesc.AlphaToCoverageEnable = false; blendStateDesc.IndependentBlendEnable = false; m_blendState = new BlendState(m_Dx11Device, desc); blendStateDesc.RenderTarget[0] = renderTargetDesc; The above still didnt work and my issue still present. 
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!