- Timestamp:
- 10/05/06 13:43:54 (18 years ago)
- Location:
- GTP/trunk/App/Demos/Illum/EnvMap
- Files:
-
- 1 added
- 1 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Illum/EnvMap/.matrix
r1556 r1573 4 4 0 1 0 0 5 5 0 0 1 0 6 0 0 4.922 16 0 0 6.82 1 7 7 8 8 Camera position: 9 0 0 -4.922069 0 0 -6.82 10 10 11 11 Mesh position: 12 0.133334 0 012 1.49802 0 -1.49802 -
GTP/trunk/App/Demos/Illum/EnvMap/.params
r1556 r1573 1 1 47 version ----- RayTraceEffects: Saved parameters of the algorithm ----- 2 2 Bool values: 3 00 113 0001 4 4 (Help [F1]; [F]ireballs; Multiple [O]bjects; Between [W]alls only; ) 5 5 Float values: 6 1(WhichMethod [TAB,Q], 0..3)6 3 (WhichMethod [TAB,Q], 0..3) 7 7 1 (WhichMesh [Home,End], 0..9) 8 28(Mesh size [Ins,Del], 0..100)8 34 (Mesh size [Ins,Del], 0..100) 9 9 1 (Resolution [M], 0..3) 10 10 0 (ShowCubeMap [C], 0..3) 11 62(Intensity [+,-], 0..100)12 0(shininess [/,*], 0..30)11 50 (Intensity [+,-], 0..100) 12 3 (shininess [/,*], 0..30) -
GTP/trunk/App/Demos/Illum/EnvMap/EnvMap.cpp
r1556 r1573 26 26 #define TEX1 L"Media\\Maps\\pixel-grid-gy.png" 27 27 #define TEX2 L"Media\\Maps\\fire.jpg" // src: astronomy.swin.edu.au/~pbourke/texture/fire 28 #define ROOM_TEXTURE L"Media\\Maps\\pixel-grid-b .png"28 #define ROOM_TEXTURE L"Media\\Maps\\pixel-grid-b_white.png" 29 29 30 30 //-------------------------------------------------------------------------------------- … … 290 290 break; 291 291 case DIFFUSE_SPECULAR_LOCALIZED_NEW: 292 sprintf(techniqueName, "EnvMapDiffuseLocalizedNew%i", LR_CUBEMAP_SIZE );293 292 V( g_pEffect->SetTechnique( "EnvMapDiffuseLocalizedNew" ) ); 293 break; 294 case DIFFUSE_SPECULAR_LOCALIZED_P2P: 295 V( g_pEffect->SetTechnique( "EnvMapDiffuseP2P" ) ); 294 296 break; 295 297 case DIFFUSE_SPECULAR_LOCALIZED_5TEX: … … 433 435 for( int i=0; i<6; i++ ) 434 436 { 435 /*objColor = D3DXVECTOR4(0.4f-i*0.1f, i*0.1f, (i%2)*0.4f, 1); // a colorful room436 if (i==3) objColor += D3DXVECTOR4(0.05, 0.05, 0, 1);*/437 //objColor = D3DXVECTOR4(0.4f-i*0.1f, i*0.1f, (i%2)*0.4f, 1); // a colorful room 438 //if (i==3) objColor += D3DXVECTOR4(0.05, 0.05, 0, 1); 437 439 438 440 objColor = facecolors[i]; -
GTP/trunk/App/Demos/Illum/EnvMap/EnvMap.fx
r1556 r1573 459 459 /// \brief Calculates diffuse or specular contributions of the 5 "most important" texels of #SmallEnvironmentMap to the current point. 460 460 /// For these texels, function GetContr(int,float3,float3,float3,float3) is called. 461 float4 GetContibution(float3 L1, float3 L2, float3 L3, float3 L4, float3 pos, float3 N, float d) 462 { 461 float4 GetContibution(float3 L, float3 L1, float3 L2, float3 L3, float3 L4, float3 pos, float3 N, samplerCUBE cubemap) 462 { 463 float d; 464 d = texCUBE(cubemap, L).a; 465 //d = texCUBE(cubemap, L1).a; 463 466 L1 = d * normalize(L1); 467 //d = texCUBE(cubemap, L2).a; 464 468 L2 = d * normalize(L2); 465 L3 = d * normalize(L3); 466 L4 = d * normalize(L4); 469 //d = texCUBE(cubemap, L3).a; 470 L3 = d * normalize(L3); 471 //d = texCUBE(cubemap, L4).a; 472 L4 = d * normalize(L4); 473 467 474 468 475 float3 r1 = normalize(L1 - pos); … … 470 477 float3 r3 = normalize(L3 - pos); 471 478 float3 r4 = normalize(L4 - pos); 472 473 474 float kd = 0.3; // 0.3 475 /* 476 float3 R; 477 R = cross(r1, r2); 478 float tri1 = asin(length(R)) * dot(R, N); 479 R = cross(r2, r3); 480 float tri2 = asin(length(R)) * dot(R, N); 481 R = cross(r3, r4); 482 float tri3 = asin(length(R)) * dot(R, N); 483 R = cross(r4, r1); 484 float tri4 = asin(length(R)) * dot(R, N); 485 */ 486 479 487 480 float tri1 = acos(dot(r1, r2)) * dot(cross(r1, r2), N); 488 481 float tri2 = acos(dot(r2, r3)) * dot(cross(r2, r3), N); … … 493 486 //return tri1 + tri2 + tri3 + tri4; 494 487 } 488 489 490 495 491 496 492 float4 EnvMapDiffuseLocalizedNewPS( _EnvMapVS_output IN ) : COLOR … … 511 507 float3 L1, L2, L3, L4, L; 512 508 float4 Le; 513 float d;514 509 float width = 1.0 / M; 515 516 for (int x = 0; x < M; x++) 517 for (int y = 0; y < M; y++) 510 float width2 = width * 2; 511 float d; 512 513 for (float x = 0.5; x < M; x++) 514 for (float y = 0.5; y < M; y++) 518 515 { 519 516 float2 p, tpos; 520 tpos.x = (x + 0.5) * width; // 0..1521 tpos.y = (y + 0.5) * width; // 0..1517 tpos.x = x * width; 518 tpos.y = y * width; 522 519 523 520 p = tpos.xy; … … 530 527 L = float3(p.x, p.y, 1); 531 528 Le = float4(texCUBE(SmallEnvironmentMapSampler, L).rgb, 1); 532 d = texCUBE(SmallEnvironmentMapSampler, L).a;533 529 534 I += 0.5 * Le * GetContibution( L1, L2, L3, L4, pos, N, d); 535 //I += Le / 16.0; 536 } 530 I += 0.5 * Le * GetContibution( L, L1, L2, L3, L4, pos, N, SmallEnvironmentMapSampler); 537 531 538 for (int x = 0; x < M; x++) 539 for (int y = 0; y < M; y++) 532 } 533 534 for (float x = 0; x < M; x++) 535 for (float y = 0; y < M; y++) 540 536 { 541 537 float2 p, tpos; 542 tpos.x = (x + 0.5)* width; // 0..1543 tpos.y = (y + 0.5)* width; // 0..1538 tpos.x = x * width; // 0..1 539 tpos.y = y * width; // 0..1 544 540 545 541 p = tpos.xy; … … 552 548 L = float3(p.x, p.y, -1); 553 549 Le = float4(texCUBE(SmallEnvironmentMapSampler, L).rgb, 1); 554 d = texCUBE(SmallEnvironmentMapSampler, L).a;555 550 556 I += 0.5 * Le * GetContibution( L1, L2, L3, L4, pos, N, d); 557 //I += Le / 16.0; 551 I += 0.5 * Le * GetContibution( L, L1, L2, L3, L4, pos, N, SmallEnvironmentMapSampler); 558 552 } 559 553 560 for ( int x = 0; x < M; x++)561 for ( int y = 0; y < M; y++)554 for (float x = 0; x < M; x++) 555 for (float y = 0; y < M; y++) 562 556 { 563 557 float2 p, tpos; 564 tpos.x = (x + 0.5)* width; // 0..1565 tpos.y = (y + 0.5)* width; // 0..1558 tpos.x = x * width; // 0..1 559 tpos.y = y * width; // 0..1 566 560 567 561 p = tpos.xy; … … 574 568 L = float3(p.x, 1, p.y); 575 569 Le = float4(texCUBE(SmallEnvironmentMapSampler, L).rgb, 1); 576 d = texCUBE(SmallEnvironmentMapSampler, L).a;577 570 578 I += 0.5 * Le * GetContibution( L1, L2, L3, L4, pos, N, d); 579 //I += Le / 16.0; 571 I += 0.5 * Le * GetContibution( L, L1, L2, L3, L4, pos, N, SmallEnvironmentMapSampler); 580 572 } 581 573 582 for ( int x = 0; x < M; x++)583 for ( int y = 0; y < M; y++)574 for (float x = 0; x < M; x++) 575 for (float y = 0; y < M; y++) 584 576 { 585 577 float2 p, tpos; 586 tpos.x = (x + 0.5)* width; // 0..1587 tpos.y = (y + 0.5)* width; // 0..1578 tpos.x = x * width; // 0..1 579 tpos.y = y * width; // 0..1 588 580 589 581 p = tpos.xy; … … 596 588 L = float3(p.x, -1, p.y); 597 589 Le = float4(texCUBE(SmallEnvironmentMapSampler, L).rgb, 1); 598 d = texCUBE(SmallEnvironmentMapSampler, L).a;599 590 600 I += 0.5 * Le * GetContibution( L1, L2, L3, L4, pos, N, d); 601 //I += Le / 16.0; 591 I += 0.5 * Le * GetContibution( L, L1, L2, L3, L4, pos, N, SmallEnvironmentMapSampler); 602 592 } 603 for (int x = 0; x < M; x++) 604 for (int y = 0; y < M; y++) 605 { 593 594 for (float x = 0; x < M; x++) 595 for (float y = 0; y < M; y++) 596 { 606 597 float2 p, tpos; 607 tpos.x = (x + 0.5)* width; // 0..1608 tpos.y = (y + 0.5)* width; // 0..1598 tpos.x = x * width; // 0..1 599 tpos.y = y * width; // 0..1 609 600 610 601 p = tpos.xy; … … 617 608 L = float3(1, p.x, p.y); 618 609 Le = float4(texCUBE(SmallEnvironmentMapSampler, L).rgb, 1); 619 d = texCUBE(SmallEnvironmentMapSampler, L).a;620 610 621 I += 0.5 * Le * GetContibution( L1, L2, L3, L4, pos, N, d); 622 //I += Le / 16.0; 623 } 611 I += 0.5 * Le * GetContibution( L, L1, L2, L3, L4, pos, N, SmallEnvironmentMapSampler); 612 } 624 613 625 for (int x = 0; x < M; x++)626 for ( int y = 0; y < M; y++)614 for (float x = 0; x < M; x++) 615 for (float y = 0; y < M; y++) 627 616 { 628 617 float2 p, tpos; 629 tpos.x = (x + 0.5)* width; // 0..1630 tpos.y = (y + 0.5)* width; // 0..1618 tpos.x = x * width; // 0..1 619 tpos.y = y * width; // 0..1 631 620 632 621 p = tpos.xy; … … 639 628 L = float3(-1, p.x, p.y); 640 629 Le = float4(texCUBE(SmallEnvironmentMapSampler, L).rgb, 1); 641 d = texCUBE(SmallEnvironmentMapSampler, L).a;642 630 643 I += 0.5 * Le * GetContibution( L1, L2, L3, L4, pos, N, d); 644 //I += Le / 16.0; 645 } 631 I += 0.5 * Le * GetContibution( L, L1, L2, L3, L4, pos, N, SmallEnvironmentMapSampler); 632 } 646 633 return intensity * I; 647 634 } 648 635 649 636 float4 P2PContr(float3 N, float3 Nl, float3 pos, float3 L, samplerCUBE cubemap) 637 { 638 Nl = normalize(Nl); 639 L = normalize(L); 640 float4 Le = float4(texCUBE(cubemap, L).rgb, 1); 641 float d = texCUBE(cubemap, L).a; 642 float3 Lpos = L * d; 643 float3 Ldir = Lpos - pos; 644 float dist = dot(Ldir, Ldir); 645 Ldir = normalize(Ldir); 646 647 return Le * max(dot(N, Ldir),0) * dot(Nl, -1 * Ldir) / dist; 648 } 649 650 float4 EnvMapDiffuseP2PPS( _EnvMapVS_output IN ) : COLOR 651 { 652 float M = 4.0; 653 IN.View = -normalize( IN.View ); 654 IN.Normal = normalize( IN.Normal ); 655 IN.Position -= reference_pos.xyz; 656 float3 pos = IN.Position.xyz; 657 658 //return reference_pos; 659 //return texCUBE(SmallEnvironmentMapSampler, pos); 660 661 float3 N =IN.Normal; 662 663 float4 I = 0; 664 float3 L; 665 float4 Le; 666 float width = 1.0 / M; 667 float d; 668 669 for (float x = 0.5; x < M; x++) 670 for (float y = 0.5; y < M; y++) 671 { 672 float2 p, tpos; 673 tpos.x = x * width; 674 tpos.y = y * width; 675 676 p = tpos.xy; 677 p = 2.0 * p - 1.0; //-1..1 678 679 I += P2PContr(N, float3(0,0,-1), pos, float3(p.x, p.y, 1), SmallEnvironmentMapSampler); 680 I += P2PContr(N, float3(0,0,1), pos, float3(-p.x, p.y, -1), SmallEnvironmentMapSampler); 681 I += P2PContr(N, float3(-1,0,0), pos, float3(1, p.y, -p.x), SmallEnvironmentMapSampler); 682 I += P2PContr(N, float3(1,0,0), pos, float3(-1, p.y, p.x), SmallEnvironmentMapSampler); 683 I += P2PContr(N, float3(0,-1,0), pos, float3(p.x, 1, -p.y), SmallEnvironmentMapSampler); 684 I += P2PContr(N, float3(0,1,0), pos, float3(p.x, -1, p.y), SmallEnvironmentMapSampler); 685 } 686 687 return intensity * I; 688 } 650 689 //-------------------------------------------------------------------------------------- 651 690 // Shading the environment … … 694 733 float4 IlluminatedScenePS( _IlluminatedSceneVS_output IN ) : COLOR0 695 734 { 696 float3 color = objColor ;//* tex2D(DecorationSampler, IN.TexCoord);697 /*735 float3 color = objColor * tex2D(DecorationSampler, IN.TexCoord); 736 /* 698 737 if (iShowCubeMap > 0) 699 738 { … … 710 749 color *= abs(pow(dot(L,N), 4)) * brightness; 711 750 } 712 else color *= 0.7; 713 */751 else color *= 0.7;*/ 752 714 753 float dist = length( IN.Position ); 715 754 return float4(color, dist); … … 745 784 746 785 TechniqueUsingCommonVS( EnvMapDiffuseLocalizedNew ); 786 TechniqueUsingCommonVS( EnvMapDiffuseP2P ); 747 787 //TechniqueUsingCommonVS( EnvMapDiffuseLocalizedNew4 ); 748 788 //TechniqueUsingCommonVS( EnvMapDiffuseLocalizedNew8 ); -
GTP/trunk/App/Demos/Illum/EnvMap/Main.cpp
r1534 r1573 199 199 200 200 // SLIDERS 201 pp.Add( iWhichMethod, "WhichMethod [TAB,Q]", 3, VK_TAB, 'Q', noconvert, OnChangeCubeMap );201 pp.Add( iWhichMethod, "WhichMethod [TAB,Q]", 4, VK_TAB, 'Q', noconvert, OnChangeCubeMap ); 202 202 pp.Add( iWhichMesh, "WhichMesh [Home,End]", 9, VK_HOME, VK_END, noconvert, OnChangeMesh ); 203 203 pp.Add( fMeshScale, "Mesh size [Ins,Del]", 100, VK_DELETE, VK_INSERT, noconvert, OnChangeMeshSize ); … … 700 700 else 701 701 txtHelper.DrawFormattedTextLine( L"Method : Our method (diffuse)"); 702 break; 703 case DIFFUSE_SPECULAR_LOCALIZED_NEW: 704 if (pp.GetInt( iShininess ) > 0) 705 txtHelper.DrawFormattedTextLine( L"Method : Our method New (specular, s=%i)", 706 pp.GetInt( iShininess )); 707 else 708 txtHelper.DrawFormattedTextLine( L"Method : Our method New (diffuse)"); 709 break; 702 break; 710 703 case DIFFUSE_SPECULAR_LOCALIZED_5TEX: 711 704 if (pp.GetInt( iShininess ) > 0) … … 714 707 else 715 708 txtHelper.DrawFormattedTextLine( L"Method : Our method (diffuse), 5 TEXEL ONLY"); 716 break; } 709 break; 710 case DIFFUSE_SPECULAR_LOCALIZED_NEW: 711 txtHelper.DrawFormattedTextLine( L"Method : Our method New (diffuse)"); 712 break; 713 case DIFFUSE_SPECULAR_LOCALIZED_P2P: 714 txtHelper.DrawFormattedTextLine( L"Method : Point-to-point form factor (diffuse)"); 715 break; 716 } 717 717 718 718 //txtHelper.DrawFormattedTextLine( L"IOR : %.2f Fresnel : %.2f", pp.Get( refractionIndex ), pp.Get( sFresnel )); -
GTP/trunk/App/Demos/Illum/EnvMap/Parameters.h
r1534 r1573 17 17 DIFFUSE_SPECULAR_LOCALIZED, ///< Our proposal. 18 18 DIFFUSE_SPECULAR_LOCALIZED_5TEX, ///< Our proposal, using 5 texel only. 19 DIFFUSE_SPECULAR_LOCALIZED_NEW ///< Our proposal. 19 DIFFUSE_SPECULAR_LOCALIZED_NEW, ///< Our proposal. 20 DIFFUSE_SPECULAR_LOCALIZED_P2P ///< Point to point form factor 20 21 } method_t; 21 22
Note: See TracChangeset
for help on using the changeset viewer.