Example #1
0
FMaterialRelevance UMaterialInterface::GetRelevance_Internal(const UMaterial* Material, ERHIFeatureLevel::Type InFeatureLevel) const
{
	if(Material)
	{
		const FMaterialResource* MaterialResource = Material->GetMaterialResource(InFeatureLevel);
		const bool bIsTranslucent = IsTranslucentBlendMode((EBlendMode)GetBlendMode());

		EMaterialShadingModel ShadingModel = GetShadingModel();

		const bool bIsLit =  ShadingModel != MSM_Unlit;
		// Determine the material's view relevance.
		FMaterialRelevance MaterialRelevance;
		MaterialRelevance.bOpaque = !bIsTranslucent;
		MaterialRelevance.bMasked = IsMasked();
		MaterialRelevance.bDistortion = Material->bUsesDistortion && bIsTranslucent;
		MaterialRelevance.bSeparateTranslucency = bIsTranslucent && Material->bEnableSeparateTranslucency;
		MaterialRelevance.bNormalTranslucency = bIsTranslucent && !Material->bEnableSeparateTranslucency;
		MaterialRelevance.bDisableDepthTest = bIsTranslucent && Material->bDisableDepthTest;
		MaterialRelevance.bSubsurfaceProfile = (Material->MaterialDomain == MD_Surface) && !bIsTranslucent && (ShadingModel == MSM_SubsurfaceProfile);
		MaterialRelevance.bOutputsVelocityInBasePass = Material->bOutputVelocityOnBasePass;

		return MaterialRelevance;
	}
	else
	{
		return FMaterialRelevance();
	}
}
Example #2
0
sParticleSystem::sParticleSystem( uint32 max_particles, eParticleType type, uint32 texture_checksum, uint32 blendmode_checksum, int fix, int num_segments, int history )
{
	// Obtain the texture.
	Nx::CTexture		* p_texture			= Nx::CTexDictManager::sp_particle_tex_dict->GetTexture( texture_checksum );
	Nx::CXboxTexture	*p_xbox_texture		= static_cast<Nx::CXboxTexture*>( p_texture );
	NxXbox::sTexture	*p_engine_texture	= NULL;
	if( p_xbox_texture )
	{
		p_engine_texture = p_xbox_texture->GetEngineTexture(); 
	}
	
	// Create a (semi-transparent) material used to render the mesh.
	sMaterial *p_material			= new sMaterial();
	p_material->m_flags[0]			= 0x40 | (( p_engine_texture ) ? MATFLAG_TEXTURED : 0 );
	p_material->m_checksum			= (uint32)rand() * (uint32)rand();
	p_material->m_passes			= 1;
	p_material->mp_tex[0]			= p_engine_texture;
	p_material->m_reg_alpha[0]		= GetBlendMode( blendmode_checksum ) | ((uint32)fix << 24 );
	p_material->m_color[0][0]		= 0.5f;
	p_material->m_color[0][1]		= 0.5f;
	p_material->m_color[0][2]		= 0.5f;
	p_material->m_color[0][3]		= fix * ( 1.0f /  128.0f );

	p_material->m_uv_addressing[0]	= 0;
	p_material->m_k[0]				= 0.0f;
	p_material->m_alpha_cutoff		= 1;
	p_material->m_no_bfc			= true;
	p_material->m_uv_wibble			= false;

	mp_material						= p_material;
}
Example #3
0
void SkeletonSprite::Render() const {
	// TAREA: Implementar la especificacion del enunciado
	Renderer::Instance().SetBlendMode( GetBlendMode() );
	Renderer::Instance().SetColor( GetRed(), GetGreen(), GetBlue(), GetAlpha() );
	glPushMatrix();
	glTranslated( GetX(), GetY(), 0 );
	root->Render();
	glPopMatrix();
}
Example #4
0
bool ETHRenderEntity::DrawAmbientPass(const float maxHeight, const float minHeight,
									  const bool enableLightmaps, const ETHSceneProperties& sceneProps,
									  const float parallaxIntensity)
{
	if (!m_pSprite || IsHidden())
		return false;

	Vector4 v4FinalAmbient = Vector4(sceneProps.ambient, 1.0f);
	v4FinalAmbient.x = Min(1.0f, v4FinalAmbient.x + m_properties.emissiveColor.x);
	v4FinalAmbient.y = Min(1.0f, v4FinalAmbient.y + m_properties.emissiveColor.y);
	v4FinalAmbient.z = Min(1.0f, v4FinalAmbient.z + m_properties.emissiveColor.z);
	v4FinalAmbient = v4FinalAmbient * m_v4Color;

	SetDepth(maxHeight, minHeight);

	const VideoPtr& video = m_provider->GetVideo();

	const bool applyLightmap = (m_pLightmap && enableLightmaps && IsStatic());
	if (applyLightmap)
	{
		m_pLightmap->SetAsTexture(1);
	}

	// sets the alpha mode according to the entity's property
	const Video::ALPHA_MODE& am = GetBlendMode();

	if (am != video->GetAlphaMode())
		video->SetAlphaMode(am);

	ValidateSpriteCut(m_pSprite);
	m_pSprite->SetRect(m_spriteFrame);
	SetOrigin();

	const bool shouldUseFourTriangles = ShouldUseFourTriangles(parallaxIntensity);
	const float angle = (m_properties.type == ETHEntityProperties::ET_VERTICAL) ? 0.0f : GetAngle();
	const Vector2 pos = ETHGlobal::ToScreenPos(GetPosition(), sceneProps.zAxisDirection);

	if (shouldUseFourTriangles)
		m_pSprite->SetRectMode(Sprite::RM_FOUR_TRIANGLES);

	m_pSprite->DrawOptimal(pos,	ConvertToDW(v4FinalAmbient), angle, GetCurrentSize());

	if (shouldUseFourTriangles)
		m_pSprite->SetRectMode(Sprite::RM_TWO_TRIANGLES);

	if (applyLightmap)
	{
		video->UnsetTexture(1);
	}
	return true;
}
Example #5
0
void	CRendererDX::Apply()
{
	//	Update world transformation.
	if( isBit( m_bDirtyMatrices, eWorld ) )
	{
		m_pDevice->SetTransform( D3DTS_WORLD, (D3DMATRIX *) (const fp4 *)m_WorldMat.m_Mat );
		remBit( m_bDirtyMatrices, eWorld );
	}

	//	Update view transformation.
	if( isBit( m_bDirtyMatrices, eView ) )
	{
		m_pDevice->SetTransform( D3DTS_VIEW, (D3DMATRIX *) (const fp4 *)m_ViewMat.m_Mat );
		remBit( m_bDirtyMatrices, eView );
	}

	//	Update projection transformation.
	if( isBit( m_bDirtyMatrices, eProjection ) )
	{
		m_pDevice->SetTransform( D3DTS_PROJECTION, (D3DMATRIX *) (const fp4 *)m_ProjMat.m_Mat );
		remBit( m_bDirtyMatrices, eProjection );
	}

	//	Blend state.	Suboptimal!
	if( m_spActiveBlend != m_spSelectedBlend )
	{
		m_spActiveBlend = m_spSelectedBlend;

		m_pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, m_spActiveBlend->m_bEnabled );
		m_pDevice->SetRenderState( D3DRS_SRCBLEND, GetBlendConstant( m_spActiveBlend->m_Src ) );
		m_pDevice->SetRenderState( D3DRS_DESTBLEND, GetBlendConstant( m_spActiveBlend->m_Dst ) );
		m_pDevice->SetRenderState( D3DRS_BLENDOP, GetBlendMode( m_spActiveBlend->m_Mode ) );
	}

	CRenderer::Apply();
}
Example #6
0
// Save():
const char * IllumiSurf_Instance::Save( const LWSaveState *saver ) {
  char cvalue;

  // Version
  LWSAVE_BEGIN( saver, &illumisurf_io_isfv[0], 0 );
  cvalue = 1;
  LWSAVE_I1( saver, &cvalue, 1 );

  // Blending Mode
  LWSAVE_BEGIN( saver, &illumisurf_io_root[ ISIOID_BLND ], 1 );
  cvalue = GetBlendMode();
  LWSAVE_I1( saver, &cvalue, 1 );
  LWSAVE_END( saver );

  // Base Intensity
  LWSAVE_BEGIN( saver, &illumisurf_io_root[ ISIOID_BINT ], 1 );
  vparam_funcs->save( GetBaseIntensity(), saver );
  LWSAVE_END( saver );

  // Alternate Intensity
  LWSAVE_BEGIN( saver, &illumisurf_io_root[ ISIOID_AINT ], 1 );
  vparam_funcs->save( GetAltIntensity(), saver );
  LWSAVE_END( saver );

  // Color
  LWSAVE_BEGIN( saver, &illumisurf_io_root[ ISIOID_COLR ], 1 );
  cvalue = GetUseColor() ? 1 : 0;
  LWSAVE_I1( saver, &cvalue, 1 );
  vparam_funcs->save( GetColor(), saver );
  LWSAVE_END( saver );

  // Luminosity
  LWSAVE_BEGIN( saver, &illumisurf_io_root[ ISIOID_LUMI ], 1 );
  cvalue = GetUseLuminosity() ? 1 : 0;
  LWSAVE_I1( saver, &cvalue, 1 );
  vparam_funcs->save( GetLuminosity(), saver );
  LWSAVE_END( saver );

  // Diffusion
  LWSAVE_BEGIN( saver, &illumisurf_io_root[ ISIOID_DIFF ], 1 );
  cvalue = GetUseDiffusion() ? 1 : 0;
  LWSAVE_I1( saver, &cvalue, 1 );
  vparam_funcs->save( GetDiffusion(), saver );
  LWSAVE_END( saver );

  // Specular
  LWSAVE_BEGIN( saver, &illumisurf_io_root[ ISIOID_SPEC ], 1 );
  cvalue = GetUseSpecular() ? 1 : 0;
  LWSAVE_I1( saver, &cvalue, 1 );
  vparam_funcs->save( GetSpecular(), saver );
  LWSAVE_END( saver );

  // Glossiness
  LWSAVE_BEGIN( saver, &illumisurf_io_root[ ISIOID_GLOS ], 1 );
  cvalue = GetUseGlossiness() ? 1 : 0;
  LWSAVE_I1( saver, &cvalue, 1 );
  vparam_funcs->save( GetGlossiness(), saver );
  LWSAVE_END( saver );

  // Reflection
  LWSAVE_BEGIN( saver, &illumisurf_io_root[ ISIOID_REFL ], 1 );
  cvalue = GetUseReflection() ? 1 : 0;
  LWSAVE_I1( saver, &cvalue, 1 );
  vparam_funcs->save( GetReflection(), saver );
  LWSAVE_END( saver );

  // Transparency
  LWSAVE_BEGIN( saver, &illumisurf_io_root[ ISIOID_TRNP ], 1 );
  cvalue = GetUseTransparency() ? 1 : 0;
  LWSAVE_I1( saver, &cvalue, 1 );
  vparam_funcs->save( GetTransparency(), saver );
  LWSAVE_END( saver );

  // Refraction
  LWSAVE_BEGIN( saver, &illumisurf_io_root[ ISIOID_REFR ], 1 );
  cvalue = GetUseRefraction() ? 1 : 0;
  LWSAVE_I1( saver, &cvalue, 1 );
  vparam_funcs->save( GetRefraction(), saver );
  LWSAVE_END( saver );

  // Translucency
  LWSAVE_BEGIN( saver, &illumisurf_io_root[ ISIOID_TRNC ], 1 );
  cvalue = GetUseTranslucency() ? 1 : 0;
  LWSAVE_I1( saver, &cvalue, 1 );
  vparam_funcs->save( GetTranslucency(), saver );
  LWSAVE_END( saver );

  LWSAVE_END( saver );

  return NULL;
}