Bonjour à tous,
Je reviens vers nous avec un nouveau mystère.
J'aimerai créer un shader qui reproduit l'effet "Glow" en HLSL :
Nom : Borderglowafter.jpg
Affichages : 529
Taille : 8,5 Ko
Pour cela, j'ai parcouru le net à la recherche de tuto
GPU GEMS GLOW
Autre tuto

J'ai pu définir un algorithme simple en 5 étapes :

  1. Rendu de la scene sans activer le glow
  2. Rendu de la scene avec uniquement les parties "glow"
    • Définition des parties "glow"
    • Enregistrement d'une "texture map"
  3. Blur horizontal
  4. Blur vertical
  5. Rendu final de la scene


Je suis arrivé à la partie où je dois enregistré ma texture dans une Render Target Texture, mais je n'arrive pas à créer la Dept Stencil View.
Le résultat de la fonction me renvoie que je n'utiliser pas les bon arguements (E_INVALIDARG)...
Je me suis pourtant basé sur un exemple officiel Microsoft : http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
 
HRESULT DX11Manager::InitRenderTargetTexture(int _textureWidth, int _textureHeight, int _samplecount)
{
	D3D11_TEXTURE2D_DESC textureDesc;
	HRESULT hr;
	D3D11_RENDER_TARGET_VIEW_DESC renderTargetViewDesc;
	D3D11_SHADER_RESOURCE_VIEW_DESC shaderResourceViewDesc;
 
 
	// Initialize the render target texture description.
	ZeroMemory(&textureDesc, sizeof(textureDesc));
 
	// Setup the render target texture description.
	textureDesc.Width = _textureWidth;
	textureDesc.Height = _textureHeight;
	textureDesc.MipLevels = 1;
	textureDesc.ArraySize = 1;
	textureDesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
	textureDesc.SampleDesc.Count = 1;
	textureDesc.Usage = D3D11_USAGE_DEFAULT;
	textureDesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
	textureDesc.CPUAccessFlags = 0;
	textureDesc.MiscFlags = 0;
 
	// Create the render target texture.
	hr = m_D3DDevice->CreateTexture2D(&textureDesc, NULL, &m_renderTargetTexture);
	if(FAILED(hr))
	{
		return false;
	}
 
	// Setup the description of the render target view.
	renderTargetViewDesc.Format = textureDesc.Format;
	renderTargetViewDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
	renderTargetViewDesc.Texture2D.MipSlice = 0;
 
	// Create the render target view.
	hr = m_D3DDevice->CreateRenderTargetView(m_renderTargetTexture, &renderTargetViewDesc, &m_renderTargetViewTexture);
	if(FAILED(hr))
	{
		return false;
	}
 
	// Setup the description of the shader resource view.
	shaderResourceViewDesc.Format = textureDesc.Format;
	shaderResourceViewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
	shaderResourceViewDesc.Texture2D.MostDetailedMip = 0;
	shaderResourceViewDesc.Texture2D.MipLevels = 1;
	shaderResourceViewDesc.Texture2D.MostDetailedMip = 0;
 
	// Create the shader resource view.
	hr = m_D3DDevice->CreateShaderResourceView(m_renderTargetTexture, &shaderResourceViewDesc, &m_shaderResourceView);
	if(FAILED(hr))
	{
		return false;
	}
	//--------------------------------------------------
	//-------------DEPTH STENCIL VIEW-------------------
	//--------------------------------------------------
 
	//Create a Depth-Stencil Resource
	ID3D11Texture2D* pDepthStencil = NULL;
	D3D11_TEXTURE2D_DESC descDepth;
 
	descDepth.Width = _textureWidth;
	descDepth.Height = _textureHeight;
	descDepth.MipLevels = 1;
	descDepth.ArraySize = 1;
	descDepth.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
	descDepth.SampleDesc.Count = 1;
	descDepth.SampleDesc.Quality = 0;
	descDepth.Usage = D3D11_USAGE_DEFAULT;
	descDepth.BindFlags = D3D11_BIND_DEPTH_STENCIL;
	descDepth.CPUAccessFlags = 0;
	descDepth.MiscFlags = 0;
	hr = m_D3DDevice->CreateTexture2D( &descDepth, NULL, &pDepthStencil );
 
	if(FAILED(hr))
	{
		return false;
	}
 
	//--------------------------------------------------
 
	//Create Depth-Stencil State
	D3D11_DEPTH_STENCIL_DESC dsDesc;
 
	// Depth test parameters
	dsDesc.DepthEnable = true;
	dsDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
	dsDesc.DepthFunc = D3D11_COMPARISON_LESS;
 
	// Stencil test parameters
	dsDesc.StencilEnable = true;
	dsDesc.StencilReadMask = 0xFF;
	dsDesc.StencilWriteMask = 0xFF;
 
	// Stencil operations if pixel is front-facing
	dsDesc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
	dsDesc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_INCR;
	dsDesc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
	dsDesc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
 
	// Stencil operations if pixel is back-facing
	dsDesc.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
	dsDesc.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_DECR;
	dsDesc.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
	dsDesc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
 
	// Create depth stencil state
	ID3D11DepthStencilState * pDSState;
	hr = m_D3DDevice->CreateDepthStencilState(&dsDesc, &pDSState);
	if(FAILED(hr))
	{
		return false;
	}
 
	//--------------------------------------------------
 
	// Bind depth stencil state
	m_D3DImmediateContext->OMSetDepthStencilState(pDSState, 1);
 
	//--------------------------------------------------
 
	D3D11_DEPTH_STENCIL_VIEW_DESC descDSV;
	descDSV.Format = DXGI_FORMAT_D32_FLOAT_S8X24_UINT;
	descDSV.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
	descDSV.Texture2D.MipSlice = 0;
 
	// Create the depth stencil view
	ID3D11DepthStencilView* pDSV;
	hr = m_D3DDevice->CreateDepthStencilView( pDepthStencil, // Depth stencil texture
											&descDSV, // Depth stencil desc
											&pDSV );  // [out] Depth stencil view
	if(FAILED(hr))
	{
		return false;
	}
 
	// Bind the depth stencil view
	m_D3DImmediateContext->OMSetRenderTargets( 1,          // One rendertarget view
											&m_renderTargetViewTexture,      // Render target view, created earlier
											pDSV );     // Depth stencil view for the render target
	return S_OK;
}
Merci pour votre aide.