Esempio n. 1
0
	void SetParameters(FRHICommandList& RHICmdList, const FViewInfo& View)
	{
		FGlobalShader::SetParameters(RHICmdList, GetVertexShader(),View);

		{
			// The fog can be set to start at a certain euclidean distance.
			// clamp the value to be behind the near plane z
			float FogStartDistance = FMath::Max(30.0f, View.ExponentialFogParameters.W);

			// Here we compute the nearest z value the fog can start
			// to render the quad at this z value with depth test enabled.
			// This means with a bigger distance specified more pixels are
			// are culled and don't need to be rendered. This is faster if
			// there is opaque content nearer than the computed z.

			FMatrix InvProjectionMatrix = View.ViewMatrices.GetInvProjMatrix();

			FVector ViewSpaceCorner = InvProjectionMatrix.TransformFVector4(FVector4(1, 1, 1, 1));

			float Ratio = ViewSpaceCorner.Z / ViewSpaceCorner.Size();

			FVector ViewSpaceStartFogPoint(0.0f, 0.0f, FogStartDistance * Ratio);
			FVector4 ClipSpaceMaxDistance = View.ViewMatrices.ProjMatrix.TransformPosition(ViewSpaceStartFogPoint);

			float FogClipSpaceZ = ClipSpaceMaxDistance.Z / ClipSpaceMaxDistance.W;

			SetShaderValue(RHICmdList, GetVertexShader(),FogStartZ, FogClipSpaceZ);
		}
	}
Esempio n. 2
0
// Adds a new vertex shader to the pass.
// If a vertex shader already exists within the pass, it will be released.
FCDEffectPassShader* FCDEffectPass::AddVertexShader()
{
	FCDEffectPassShader* vertexShader;
	for (vertexShader = GetVertexShader(); vertexShader != NULL; vertexShader = GetVertexShader())
	{
		SAFE_RELEASE(vertexShader);
	}

	vertexShader = AddShader();
	vertexShader->AffectsVertices();
	SetNewChildFlag();
	return vertexShader;
}
	/** to have a similar interface as all other shaders */
	void SetParameters(const FRenderingCompositePassContext& Context, FIntPoint TileCountValue, uint32 TileSize, float PixelKernelSize, float Threshold)
	{
		const FVertexShaderRHIParamRef ShaderRHI = GetVertexShader();

		FGlobalShader::SetParameters(Context.RHICmdList, ShaderRHI, Context.View);

		PostprocessParameter.SetVS(ShaderRHI, Context, TStaticSamplerState<SF_Bilinear, AM_Clamp, AM_Clamp, AM_Clamp>::GetRHI());

		{
			FIntRect TileCountAndSizeValue(TileCountValue, FIntPoint(TileSize, TileSize));

			SetShaderValue(Context.RHICmdList, ShaderRHI, TileCountAndSize, TileCountAndSizeValue);
		}

		{
			// only approximate as the mip mapping doesn't produce accurate brightness scaling
			FVector4 ColorScaleValue(1.0f / FMath::Max(1.0f, PixelKernelSize * PixelKernelSize), Threshold, 0, 0);

			SetShaderValue(Context.RHICmdList, ShaderRHI, ColorScale, ColorScaleValue);
		}

		{
			FVector4 KernelSizeValue(PixelKernelSize, PixelKernelSize, 0, 0);

			SetShaderValue(Context.RHICmdList, ShaderRHI, KernelSize, KernelSizeValue);
		}
	}
const Ogre::MaterialPtr& MaterialGenerator::GetMaterial(Perm permutation)
{
    // Check if material/shader permutation already was generated
    MaterialMap::iterator i = mMaterials.find(permutation);
    if (i != mMaterials.end())
    {
        return i->second;
    }
    else
    {
        // Create it
        Ogre::MaterialPtr templ = GetTemplateMaterial(permutation & mMatMask);
        Ogre::GpuProgramPtr vs = GetVertexShader(permutation & mVsMask);
        Ogre::GpuProgramPtr fs = GetFragmentShader(permutation & mFsMask);

        // Create material name
        string name = mMaterialBaseName + Ogre::StringConverter::toString(permutation);

        // Create material from template, and set shaders
        Ogre::MaterialPtr mat = templ->clone(name);
        Ogre::Technique* tech = mat->getTechnique(0);
        Ogre::Pass* pass = tech->getPass(0);
        pass->setFragmentProgram(fs->getName());
        pass->setVertexProgram(vs->getName());

        // And store it
        mMaterials[permutation] = mat;
        return mMaterials[permutation];
    }
}
	void SetParameters(const FRenderingCompositePassContext& Context)
	{
		const FVertexShaderRHIParamRef ShaderRHI = GetVertexShader();

		const FSceneView& View = Context.View;

		FGlobalShader::SetParameters(Context.RHICmdList, ShaderRHI, Context.View);
		
		PostprocessParameter.SetVS(ShaderRHI, Context, TStaticSamplerState<SF_Bilinear,AM_Clamp,AM_Clamp,AM_Clamp>::GetRHI());

		const FPooledRenderTargetDesc* InputDesc = Context.Pass->GetInputDesc(ePId_Input0);

		if(!InputDesc)
		{
			// input is not hooked up correctly
			return;
		}

		{
			// from percent to fraction
			float Offset = View.FinalPostProcessSettings.SceneFringeIntensity * 0.01f;
			// we only get bigger to not leak in content from outside
			FVector4 Value(1.0f, 1.0f - Offset * 0.5f, 1.0f - Offset, 0);

			SetShaderValue(Context.RHICmdList, ShaderRHI, FringeUVParams, Value);
		}
	}
	void SetParameters(FRHICommandList& RHICmdList, const FSceneView& View, const FMatrix& InFrustumComponentToClip)
	{
		const FVertexShaderRHIParamRef ShaderRHI = GetVertexShader();

		FGlobalShader::SetParameters(RHICmdList, ShaderRHI, View);
		SetShaderValue(RHICmdList, ShaderRHI, FrustumComponentToClip, InFrustumComponentToClip);
	}
 void SetParameters(
     FRHICommandList& RHICmdList,
     const FSceneView& View )
 {
     FVertexShaderRHIParamRef ShaderRHI = GetVertexShader();
     FGlobalShader::SetParameters(RHICmdList, ShaderRHI, View);
 }
	/** to have a similar interface as all other shaders */
	void SetParameters(const FRenderingCompositePassContext& Context, FIntPoint TileCountValue)
	{
		const FVertexShaderRHIParamRef ShaderRHI = GetVertexShader();

		FGlobalShader::SetParameters(Context.RHICmdList, ShaderRHI, Context.View);
		PostprocessParameter.SetVS(ShaderRHI, Context, TStaticSamplerState<SF_Point,AM_Clamp,AM_Clamp,AM_Clamp>::GetRHI());

		SetShaderValue(Context.RHICmdList, ShaderRHI, TileCount, TileCountValue);
	}
Esempio n. 9
0
	/**
	 * Sets parameters for particle injection.
	 */
	void SetParameters(FRHICommandList& RHICmdList, const FVector2D& CurveOffset )
	{
		FParticleCurveInjectionParameters Parameters;
		Parameters.PixelScale.X = 1.0f / GParticleCurveTextureSizeX;
		Parameters.PixelScale.Y = 1.0f / GParticleCurveTextureSizeY;
		Parameters.CurveOffset = CurveOffset;
		FParticleCurveInjectionBufferRef UniformBuffer = FParticleCurveInjectionBufferRef::CreateUniformBufferImmediate( Parameters, UniformBuffer_SingleDraw );
		FVertexShaderRHIParamRef VertexShader = GetVertexShader();
		SetUniformBufferParameter(RHICmdList, VertexShader, GetUniformBufferParameter<FParticleCurveInjectionParameters>(), UniformBuffer );
	}
// Retrieve specified vertex shader
//-----------------------------------------------------------------------------
CPUTResult CPUTAssetLibraryOGL::GetVertexShader(
    const cString       &name,
    const cString       &shaderMain,
    const cString       &shaderProfile,
    CPUTShaderOGL       **ppVertexShader,
    bool                nameIsFullPathAndFilename,
    CPUT_SHADER_MACRO   *pShaderMacros
)
{
    std::vector<cString> filenames;
    filenames.push_back(name);
    return GetVertexShader(filenames, shaderMain, shaderProfile, ppVertexShader, nameIsFullPathAndFilename, pShaderMacros);
}
	void SetParameters(const FRenderingCompositePassContext& Context)
	{
		const FVertexShaderRHIParamRef ShaderRHI = GetVertexShader();

		FGlobalShader::SetParameters(Context.RHICmdList, ShaderRHI, Context.View);

		const FPooledRenderTargetDesc* InputDesc = Context.Pass->GetInputDesc(ePId_Input0);

		if(!InputDesc)
		{
			// input is not hooked up correctly
			return;
		}
	}
	void SetParameters( const FSceneView* View, const FLightSceneInfo* LightSceneInfo )
	{
		FMaterialShader::SetParameters(GetVertexShader(), *View);
		
		// Light functions are projected using a bounding sphere.
		// Calculate transform for bounding stencil sphere.
		FSphere LightBounds = LightSceneInfo->Proxy->GetBoundingSphere();
		if (LightSceneInfo->Proxy->GetLightType() == LightType_Directional)
		{
			LightBounds.Center = View->ViewMatrices.ViewOrigin;
		}

		FVector4 StencilingSpherePosAndScale;
		StencilingGeometry::CalcTransform(StencilingSpherePosAndScale, LightBounds, View->ViewMatrices.PreViewTranslation);
		StencilingGeometryParameters.Set(this, StencilingSpherePosAndScale);
	}
Esempio n. 13
0
	void SetParameters(const FRenderingCompositePassContext& Context)
	{
		const FVertexShaderRHIParamRef ShaderRHI = GetVertexShader();

		FGlobalShader::SetParameters(Context.RHICmdList, ShaderRHI, Context.View);

		const FPooledRenderTargetDesc* InputDesc = Context.Pass->GetInputDesc(ePId_Input0);

		if(!InputDesc)
		{
			// input is not hooked up correctly
			return;
		}

		FVector2D InvExtent = FVector2D(1.0f / InputDesc->Extent.X, 1.0f / InputDesc->Extent.Y);

		SetShaderValue(Context.RHICmdList, ShaderRHI, fxaaQualityRcpFrame, InvExtent);
	}
Esempio n. 14
0
    void SetParameters(const FRenderingCompositePassContext& Context, const FRCPassPostProcessUpscale::PaniniParams& InPaniniConfig)
    {
        const FVertexShaderRHIParamRef ShaderRHI = GetVertexShader();

        FGlobalShader::SetParameters(Context.RHICmdList, ShaderRHI, Context.View);

        {
            const FVector2D FOVPerAxis = Context.View.ViewMatrices.GetFieldOfViewPerAxis();
            const FVector2D ScreenPosToPaniniFactor = FVector2D(FMath::Tan(FOVPerAxis.X), FMath::Tan(FOVPerAxis.Y));
            const FVector2D PaniniDirection = FVector2D(1.0f, 0.0f) * ScreenPosToPaniniFactor;
            const FVector2D PaniniPosition = PaniniProjection(PaniniDirection, InPaniniConfig.D, InPaniniConfig.S);

            const float WidthFit = ScreenPosToPaniniFactor.X / PaniniPosition.X;
            const float OutScreenPosScale = FMath::Lerp(1.0f, WidthFit, InPaniniConfig.ScreenFit);

            FVector Value(InPaniniConfig.D, InPaniniConfig.S, OutScreenPosScale);

            SetShaderValue(Context.RHICmdList, ShaderRHI, PaniniParameters, Value);
        }
    }
Esempio n. 15
0
void Shader::LinkProgram()
{
  p = glCreateProgramObjectARB();

  for ( std::vector< std::string >::iterator it = vertexes.begin(), it2 = vertexes.end(); it != it2; ++it )
  {
    int s = GetVertexShader( *it );
    glAttachObjectARB( p, s );
  }

  for ( std::vector< std::string >::iterator it = fragments.begin(), it2 = fragments.end(); it != it2; ++it )
  {
    int s = GetFragmentShader( *it );
    glAttachObjectARB( p, s );
  }

  glLinkProgramARB( p ); 

  BindProgram();
}
	void SetVS(const FRenderingCompositePassContext& Context)
	{
		const FVertexShaderRHIParamRef ShaderRHI = GetVertexShader();

		FGlobalShader::SetParameters(Context.RHICmdList, ShaderRHI, Context.View);

		PostprocessParameter.SetVS(ShaderRHI, Context, TStaticSamplerState<SF_Bilinear,AM_Clamp,AM_Clamp,AM_Clamp>::GetRHI());

		if(EyeAdaptation.IsBound())
		{
			if (Context.View.HasValidEyeAdaptation())
			{
				IPooledRenderTarget* EyeAdaptationRT = Context.View.GetEyeAdaptation(Context.RHICmdList);
				SetTextureParameter(Context.RHICmdList, ShaderRHI, EyeAdaptation, EyeAdaptationRT->GetRenderTargetItem().TargetableTexture);
			}
			else
			{
				SetTextureParameter(Context.RHICmdList, ShaderRHI, EyeAdaptation, GWhiteTexture->TextureRHI);
			}
		}
	}
Esempio n. 17
0
	void SetVS(const FRenderingCompositePassContext& Context, EStereoscopicPass StereoPass)
	{
		const FVertexShaderRHIParamRef ShaderRHI = GetVertexShader();

		FGlobalShader::SetParameters(Context.RHICmdList, ShaderRHI, Context.View);

		check(GEngine->HMDDevice.IsValid());
		FVector2D EyeToSrcUVScaleValue;
		FVector2D EyeToSrcUVOffsetValue;
		GEngine->HMDDevice->GetEyeRenderParams_RenderThread(StereoPass, EyeToSrcUVScaleValue, EyeToSrcUVOffsetValue);
		SetShaderValue(Context.RHICmdList, ShaderRHI, EyeToSrcUVScale, EyeToSrcUVScaleValue);
		SetShaderValue(Context.RHICmdList, ShaderRHI, EyeToSrcUVOffset, EyeToSrcUVOffsetValue);

		if (bTimeWarp)
		{
			FMatrix startM, endM;
			GEngine->HMDDevice->GetTimewarpMatrices_RenderThread(StereoPass, startM, endM);
			SetShaderValue(Context.RHICmdList, ShaderRHI, EyeRotationStart, startM);
			SetShaderValue(Context.RHICmdList, ShaderRHI, EyeRotationEnd, endM);
		}
	}
Esempio n. 18
0
void plLayer::Write(hsStream* s, hsResMgr* mgr)
{
    plLayerInterface::Write(s, mgr);

    fState->Write(s);

    fTransform->Write(s);
    fPreshadeColor->Write(s);
    fRuntimeColor->Write( s );
    fAmbientColor->Write(s);
    fSpecularColor->Write( s );
    
    s->WriteLE32(*fUVWSrc);
    s->WriteLEScalar(*fOpacity);
    s->WriteLEScalar(*fLODBias);
    s->WriteLEScalar(*fSpecularPower);


    mgr->WriteKey(s, GetTexture());
    mgr->WriteKey(s, GetVertexShader());
    mgr->WriteKey(s, GetPixelShader());

    fBumpEnvXfm->Write(s);
}
HRESULT myIDirect3DDevice9::DrawIndexedPrimitive(D3DPRIMITIVETYPE PrimitiveType,INT BaseVertexIndex,UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount)
{
	if (isThisSky && GetKeyState(VK_F3))
	{
		DebugBreak();
	}

	if (isThisBarrel)
	{
		IDirect3DVertexDeclaration9* vDecl;
		GetVertexDeclaration(&vDecl);

		IDirect3DVertexShader9* vShader;
		GetVertexShader(&vShader);

		DB_EnumXAssets(ASSET_TYPE_VERTEXDECL, DebugVertexDecl, (int)vDecl);
		DB_EnumXAssets(ASSET_TYPE_VERTEXSHADER, DebugVertexShader, (int)vShader);

		__asm int 3
		isThisBarrel = false;
	}

    return(m_pIDirect3DDevice9->DrawIndexedPrimitive(PrimitiveType,BaseVertexIndex,MinVertexIndex,NumVertices,startIndex,primCount));
}
	/** Sets shader parameter values */
	void SetParameters(FRHICommandList& RHICmdList, const FViewInfo& View)
	{
		FGlobalShader::SetParameters(RHICmdList, GetVertexShader(), View);
	}
Esempio n. 21
0
	void SetParameters(const FSceneView& View)
	{
		const FVertexShaderRHIParamRef ShaderRHI = GetVertexShader();
		
		FGlobalShader::SetParameters(ShaderRHI, View);
	}
Esempio n. 22
0
	void SetParameters(const FMaterialRenderProxy* MaterialRenderProxy,const FMaterial& MaterialResource,const FSceneView& View)
	{
		FMeshMaterialShader::SetParameters(GetVertexShader(),MaterialRenderProxy,MaterialResource,View,ESceneRenderTargetsMode::DontSet);
	}
	void SetMesh(FRHICommandList& RHICmdList, const FVertexFactory* VertexFactory,const FSceneView& View,const FPrimitiveSceneProxy* Proxy,const FMeshBatchElement& BatchElement, float DitheredLODTransitionValue)
	{
		FMeshMaterialShader::SetMesh(RHICmdList, GetVertexShader(),VertexFactory,View,Proxy,BatchElement,DitheredLODTransitionValue);
	}
Esempio n. 24
0
	void SetParameters(FRHICommandList& RHICmdList, const FVertexFactory* VertexFactory,const FMaterialRenderProxy* MaterialRenderProxy,const FSceneView* View)
	{
		FMeshMaterialShader::SetParameters(RHICmdList, GetVertexShader(), MaterialRenderProxy, *MaterialRenderProxy->GetMaterial(View->GetFeatureLevel()), *View, ESceneRenderTargetsMode::SetTextures);
	}
Esempio n. 25
0
bool GLVideo::DrawRectangle(
	const math::Vector2 &v2Pos,
	const math::Vector2 &v2Size,
	const Color& color0,
	const Color& color1,
	const Color& color2,
	const Color& color3,
	const float angle,
	const Sprite::ENTITY_ORIGIN origin)
{
	if (v2Size == math::Vector2(0,0))
	{
		return true;
	}

	// TODO/TO-DO this is diplicated code: fix it
	math::Vector2 v2Center;
	switch (origin)
	{
	case Sprite::EO_CENTER:
	case Sprite::EO_RECT_CENTER:
		v2Center.x = v2Size.x / 2.0f;
		v2Center.y = v2Size.y / 2.0f;
		break;
	case Sprite::EO_RECT_CENTER_BOTTOM:
	case Sprite::EO_CENTER_BOTTOM:
		v2Center.x = v2Size.x / 2.0f;
		v2Center.y = v2Size.y;
		break;
	case Sprite::EO_RECT_CENTER_TOP:
	case Sprite::EO_CENTER_TOP:
		v2Center.x = v2Size.x / 2.0f;
		v2Center.y = 0.0f;
		break;
	case Sprite::EO_DEFAULT:
	default:
		v2Center.x = 0.0f;
		v2Center.y = 0.0f;
		break;
	};

	math::Matrix4x4 mRot;
	if (angle != 0.0f)
		mRot = math::RotateZ(math::DegreeToRadian(angle));
	m_rectVS->SetMatrixConstant("rotationMatrix", mRot);
	m_rectVS->SetConstant("size", v2Size);
	m_rectVS->SetConstant("entityPos", v2Pos);
	m_rectVS->SetConstant("center", v2Center);
	m_rectVS->SetConstant("color0", color0);
	m_rectVS->SetConstant("color1", color1);
	m_rectVS->SetConstant("color2", color2);
	m_rectVS->SetConstant("color3", color3);

	ShaderPtr prevVertexShader = GetVertexShader(), prevPixelShader = GetPixelShader();

	SetVertexShader(m_rectVS);
	SetPixelShader(ShaderPtr());

	UnsetTexture(0);
	UnsetTexture(1);
	GetVertexShader()->SetShader();
	m_rectRenderer.Draw(Sprite::RM_TWO_TRIANGLES);

	SetPixelShader(prevPixelShader);
	SetVertexShader(prevVertexShader);
	return true;
}
void FSimpleElementVS::SetParameters(const FMatrix& TransformValue, bool bSwitchVerticalAxis)
{
	SetShaderValue(GetVertexShader(),Transform,TransformValue);
	SetShaderValue(GetVertexShader(),SwitchVerticalAxis, bSwitchVerticalAxis ? -1.0f : 1.0f);
}
Esempio n. 27
0
void FCubemapTexturePropertiesVS::SetParameters( FRHICommandList& RHICmdList, const FMatrix& TransformValue )
{
	SetShaderValue(RHICmdList, GetVertexShader(), Transform, TransformValue);
}
Esempio n. 28
0
void RotationManipulator::RenderScaled(const Vect &cameraDir, float scale)
{
    traceInFast(RotationManipulator::RenderScaled);

    DWORD i;

    Shader *rotManipShader = GetVertexShader(TEXT("Editor:RotationManipulator.vShader"));
    LoadVertexShader(rotManipShader);
    LoadPixelShader(GetPixelShader(TEXT("Base:SolidColor.pShader")));

    rotManipShader->SetVector(rotManipShader->GetParameter(2), cameraDir);

    MatrixPush();
    MatrixTranslate(GetWorldPos());
    MatrixScale(scale, scale, scale);

        for(i=0; i<3; i++)
        {
            Vect axisColor(0.0f, 0.0f, 0.0f);

            axisColor.ptr[i] = 1.0f;
            if(i == activeAxis)
                axisColor.Set(1.0f, 1.0f, 0.0f);
            else
                axisColor.ptr[i] = 1.0f;

            rotManipShader->SetVector(rotManipShader->GetParameter(1), axisColor);

            LoadVertexBuffer(axisBuffers[i]);
            LoadIndexBuffer(NULL);

            Draw(GS_LINESTRIP);
        }

        LoadVertexBuffer(NULL);

        //----------------------------------------------------

        Shader *solidShader = GetVertexShader(TEXT("Base:SolidColor.vShader"));
        LoadVertexShader(solidShader);

        MatrixPush();
        MatrixRotate(Quat().SetLookDirection(cameraDir));

            LoadVertexBuffer(axisBuffers[2]);
            LoadIndexBuffer(NULL);

            solidShader->SetColor(solidShader->GetParameter(1), 0.5, 0.5, 0.5, 0.5);

            Draw(GS_LINESTRIP);

            MatrixScale(1.25f, 1.25f, 1.25f);

            //---------------

            if(activeAxis == 4)
                solidShader->SetColor(solidShader->GetParameter(1), 1.0f, 1.0f, 0.0, 1.0f);
            else
                solidShader->SetColor(solidShader->GetParameter(1), 0.8, 0.8, 0.8, 0.8);

            Draw(GS_LINESTRIP);

        MatrixPop();

    MatrixPop();

    LoadVertexShader(NULL);
    LoadPixelShader(NULL);

    traceOutFast;
}
Esempio n. 29
0
	void SetMesh(FRHICommandList& RHICmdList, const FVertexFactory* VertexFactory,const FSceneView& View,const FPrimitiveSceneProxy* Proxy,const FMeshBatchElement& BatchElement)
	{
		FMeshMaterialShader::SetMesh(RHICmdList, GetVertexShader(),VertexFactory,View,Proxy,BatchElement);
	}
Esempio n. 30
0
	void SetMesh(FRHICommandList& RHICmdList, const FVertexFactory* VertexFactory, const FMeshBatch& Mesh, int32 BatchElementIndex, const FViewInfo& View, const FPrimitiveSceneProxy* Proxy, const FMatrix& InPreviousLocalToWorld)
	{
		FMeshMaterialShader::SetMesh(RHICmdList, GetVertexShader(), VertexFactory, View, Proxy, Mesh.Elements[BatchElementIndex]);

		SetShaderValue(RHICmdList, GetVertexShader(), PreviousLocalToWorld, InPreviousLocalToWorld.ConcatTranslation(View.PrevViewMatrices.PreViewTranslation));
	}