Xtreme Visual Basic Talk

Xtreme Visual Basic Talk (http://www.xtremevbtalk.com/)
-   Managed DirectX (http://www.xtremevbtalk.com/managed-directx/)
-   -   Direct3d: Render 2Dimage with a shader (http://www.xtremevbtalk.com/managed-directx/313377-direct3d-render-2dimage-shader.html)

Zosimas 01-19-2010 12:16 PM

[SOLVED] Direct3d: Render 2Dimage with a shader
 
At the first step of my program, I use 'RenderToSurface' technique
to draw my scene to a texture.
At the second step, I want to draw this texture to the screen with the
use of a pixel shader effect.

I tried 'Sprites' but the shader has no effect on my image.

Any idea?

Zosimas 01-20-2010 12:08 PM

[SOLVED] Direct3d: Render 2Dimage with a shader
 
Problem SOLVED!

I use quads and render them with an OrthoLH Projection.
Here is the code:
----------------------------------------------------------------------
Code:

'Declare vertices
Private vertices(5) As CustomVertex.PositionNormalTextured

'Set vertices
vertices(0).X = -Width
vertices(0).Y = -Height
vertices(0).Tu = 1
vertices(0).Tv = 0

vertices(1).X = Width
vertices(1).Y = Height
vertices(1).Tu = 0
vertices(1).Tv = 1

vertices(2).X = Width
vertices(2).Y = -Height
vertices(2).Tu = 0
vertices(2).Tv = 0

vertices(3).X = -Width
vertices(3).Y = -Height
vertices(3).Tu = 1
vertices(3).Tv = 0

vertices(4).X = -Width
vertices(4).Y = Height
vertices(4).Tu = 1
vertices(4).Tv = 1

vertices(5).X = Width
vertices(5).Y = Height
vertices(5).Tu = 0
vertices(5).Tv = 1

'Set World, View, Projection
device.Transform.World = Matrix.Identity * Matrix.Translation(0, 0, 0)
device.Transform.View = Matrix.Identity * Matrix.Translation(New Vector3(-1, -1, 0))
device.Transform.Projection = Matrix.OrthoLH(-Width * 2, -Height * 2, 0, 1)

'Render quads
Passes = blurEffect.Begin(FX.None)
For k = 0 To Passes - 1
blurEffect.BeginPass(k)
DEV.VertexFormat = CustomVertex.PositionNormalTextured.Format
DEV.DrawUserPrimitives(PrimitiveType.TriangleList, 2, vertices)
blurEffect.EndPass()
Next k
blurEffect.End()

----------------------------------------------------------------------

I really don't understand why width and height must be multiplied with 2
but this works perfect! :)


All times are GMT -6. The time now is 04:31 PM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Optimisation provided by DragonByte SEO v2.0.15 (Lite) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
All site content is protected by the Digital Millenium Act of 1998. Copyright©2001-2011 MAS Media Inc. and Extreme Visual Basic Forum. All rights reserved.
You may not copy or reproduce any portion of this site without written consent.