GetCubeShaderResource() 공개 메소드

public GetCubeShaderResource ( int mipLevel ) : ShaderResource
mipLevel int
리턴 ShaderResource
예제 #1
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="dst"></param>
		/// <param name="cubeSrc"></param>
		/// <param name="sampleCount"></param>
		public void PrefilterEnvMap ( RenderTargetCube envMap )
		{
			SetDefaultRenderStates();

			int width  = envMap.Width / 2;
			int height = envMap.Height / 2;

			using( new PixEvent("PrefilterEnvMap") ) {

				var sides =	new[]{ ShaderFlags.PREFILTER_ENVMAP | ShaderFlags.POSX, ShaderFlags.PREFILTER_ENVMAP | ShaderFlags.NEGX, 
								   ShaderFlags.PREFILTER_ENVMAP | ShaderFlags.POSY, ShaderFlags.PREFILTER_ENVMAP | ShaderFlags.NEGY, 
								   ShaderFlags.PREFILTER_ENVMAP | ShaderFlags.POSZ, ShaderFlags.PREFILTER_ENVMAP | ShaderFlags.NEGZ };

				//	loop through mip levels from second to last specular mip level :
				for (int mip=1; mip<RenderSystem.EnvMapSpecularMipCount; mip++) {

					float roughness = (float)mip / (float)(RenderSystem.EnvMapSpecularMipCount-1);
					float step		= 1.0f / width;

					vectorCB.SetData( new Vector4( roughness, step,0,0 ) );
					
								
					for (int face=0; face<6; face++) {

						rs.SetTargets( null, envMap.GetSurface( mip, (CubeFace)face ) );
					
						rs.SetViewport( 0,0, width, height );

						rs.PixelShaderConstants[0]	=	vectorCB;
						rs.PipelineState			=	factory[ (int)sides[face] ];
						rs.VertexShaderResources[0] =	envMap.GetCubeShaderResource( mip-1 );
						rs.PixelShaderResources[0]	=	envMap.GetCubeShaderResource( mip-1 );
						rs.PixelShaderSamplers[0]	=	SamplerState.LinearWrap;
						rs.VertexShaderConstants[0]	=	matrixCB;

						rs.Draw( 3, 0 );
					}

					width /= 2;
					height /= 2;
				}
			}


			rs.ResetStates();
		}