//--------------------------------------------------------------------------------------- // ワールド変換行列設定(&シェーダへ設定) //--------------------------------------------------------------------------------------- void SetWorldMatrixShader(LPD3DXMATRIX pWorld) { g_pFX->SetMatrix(g_hMatWVP, &(*pWorld * g_mView * g_mProj)); g_pFX->SetMatrix(g_hMatW, pWorld); g_pFX->SetFloatArray(g_hLight, &g_vLight.x, 4); g_pFX->SetFloatArray(g_hCamera, &g_vCamera.x, 3); }
void CGlowEffect::SetBlurEffectParameters(float dx,float dy,float blurAmount,CEffectFile* pEffect) { const int sampleCount = 9; float sampleWeights[sampleCount]; float sampleOffset[sampleCount * 2]; sampleWeights[0] = ComputeGaussian(0,blurAmount); sampleOffset[0] = 0; sampleOffset[1] = 0; float totalWeight = sampleWeights[0]; for (int i=0;i<sampleCount/2;i++) { float weight = ComputeGaussian( (float)(i+1),blurAmount); sampleWeights[i*2+1] = weight; sampleWeights[i*2+2] = weight; totalWeight += weight * 2; float offset = i * 2 + 1.5f; float offsetX = dx * offset; float offsetY = dy * offset; int index = (i * 2) * 2 + 2; sampleOffset[index] = offsetX; sampleOffset[index+1] = offsetY; sampleOffset[index+2] = -offsetX; sampleOffset[index+3] = -offsetY; } for(int i=0;i<sampleCount;i++) { sampleWeights[i] /= totalWeight; } //optimize code here!!! LPD3DXEFFECT fx = pEffect->GetDXEffect(); fx->SetFloatArray(fx->GetParameterByName(NULL,"sampleWeight"),sampleWeights,sampleCount); fx->SetFloatArray(fx->GetParameterByName(NULL,"sampleOffset"),sampleOffset,sampleCount * 2); }
void CRenderTarget::Fill(CGame2D* g2d, int x, int y, int w, int h, float color[4]) { LPD3DXEFFECT effect = LoadEffect("utils.fx"); if (effect == NULL) return; BeginRenderTarget(0); if (SUCCEEDED(GetDevice()->BeginScene())) { CGame2D* g2d = Get2D(); effect->SetFloatArray("g_Fill", color, 4); effect->SetTechnique("FillTexture"); DX_BEGIN_EFFECT(effect); g2d->DrawRect(x, y, w, h, 0xFFFFFFFF); DX_END_EFFECT(effect); GetDevice()->EndScene(); } EndRenderTarget(); }
void Manipulator::RenderSphere(LPD3DXEFFECT effect, const Matrix& projection, const Matrix& view, const D3DXVECTOR3& color, const Transform& world) { D3DXMATRIX wvp = world.GetMatrix() * view.GetMatrix() * projection.GetMatrix(); effect->SetMatrix(DxConstant::WordViewProjection, &wvp); effect->SetFloatArray(DxConstant::VertexColor, &color.x, 3); UINT nPasses = 0; effect->Begin(&nPasses, 0); for(UINT iPass = 0; iPass < nPasses; iPass++) { effect->BeginPass(iPass); m_sphere->DrawSubset(0); effect->EndPass(); } effect->End(); }
void CollisionMesh::DrawMesh(const Matrix& projection, const Matrix& view, const D3DXVECTOR3& color) { if(m_draw && m_geometry) { LPD3DXEFFECT shader = m_geometry->GetShader(); D3DXMATRIX wvp = m_world.GetMatrix() * view.GetMatrix() * projection.GetMatrix(); shader->SetMatrix(DxConstant::WordViewProjection, &wvp); shader->SetTechnique(DxConstant::DefaultTechnique); shader->SetFloatArray(DxConstant::VertexColor, &(color.x), 3); UINT nPasses = 0; shader->Begin(&nPasses, 0); for(UINT pass = 0; pass < nPasses; ++pass) { shader->BeginPass(pass); m_geometry->GetMesh()->DrawSubset(0); shader->EndPass(); } shader->End(); } }