source: GTP/trunk/App/Demos/Illum/pathmap/PRMRenderStrategy.cpp @ 2197

Revision 2197, 2.6 KB checked in by szirmay, 18 years ago (diff)
Line 
1#include "dxstdafx.h"
2#include ".\prmrenderstrategy.h"
3
4PRMRenderStrategy::PRMRenderStrategy(PathMapEffect* pathMapEffect, Radion* radion)
5:RenderStrategy(pathMapEffect)
6{
7        this->radion = radion;
8}
9
10void PRMRenderStrategy::applyTargets()
11{
12}
13
14void PRMRenderStrategy::applyRenderState()
15{
16        LPDIRECT3DDEVICE9 device = pathMapEffect->device;
17        // blend-add contribution of virtual light source to PRM
18        device->SetRenderTarget(0, prmSurface);
19        device->SetDepthStencilSurface(NULL);
20        device->SetViewport(&vp);
21        device->SetRenderState(D3DRS_CULLMODE,  D3DCULL_NONE);
22        device->SetRenderState(D3DRS_ALPHABLENDENABLE,  true);
23        device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
24        device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
25        device->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD);
26        device->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
27
28}
29
30void PRMRenderStrategy::applyTechnique()
31{
32        LPD3DXEFFECT effect = pathMapEffect->effect;
33
34        effect->SetTechnique("BushToAtlas");
35        effect->SetFloatArray("lightPos", (float*)&bushRadions[ir].position, 3);
36        effect->SetFloatArray("lightDir", (float*)&bushRadions[ir].normal, 3);
37        effect->SetTexture("depthMap", pathMapEffect->depthMapTexture);
38
39        static float opttme[9] = {0.5f, 0.0f, 0.0f,
40                                                        0.0f, -0.5f, 0.0f,
41                                                        0.5f + (0.5f / DEPTHMAPRES), 0.5f + (0.5f / DEPTHMAPRES), 1.0f};
42        effect->SetFloatArray("occProjToTexMatrix", opttme, 9);
43        effect->SetMatrix("occWorldToProjMatrix", &(*radionCamera.GetViewMatrix() * *radionCamera.GetProjMatrix()));
44}
45
46void PRMRenderStrategy::applyTransforms(Entity* entity)
47{
48}
49
50void PRMRenderStrategy::applyTextures(SubEntity* subEntity)
51{
52
53
54        float acs = 4096.0f / nRadions;
55        if(acs <= 0.25f || acs > 1000.0f)
56                bool kamugaz = true;
57        effect->SetFloat("alphaCounterStep", acs);
58
59        Vector bb0 = this->rayTraceEntity->bbox.minPoint;
60        Vector bb1 = this->rayTraceEntity->bbox.maxPoint;
61        //effect->SetFloat("cutNearness2", (bb1 - bb0).norm2() / 200.0f);
62        float nne = 5.0f / bushRadions[ir].probability;
63        float onne = (bb1 - bb0).norm2() / 200.0f;
64        effect->SetFloat("cutNearness2", nne);
65        //effect->SetFloat("cutNearness2", 0.0f);
66       
67        //set global params
68
69
70        effect->SetMatrix("modelToWorldMatrix", &(this->modelWorldTransform));
71        effect->SetMatrix("inverseTransposedModelToWorldMatrix", &(this->inverseTransposedModelWorldTransform));
72        Vector scaledPower = bushRadions[ir].radiance * scaleFactor;
73        hr=effect->SetFloatArray("lightPower", (float*)&scaledPower, 3);
74}
75
76
77void PRMRenderStrategy::resetRenderState()
78{
79        LPDIRECT3DDEVICE9 device = pathMapEffect->device;
80}
81
Note: See TracBrowser for help on using the repository browser.