How to Camera-Space Rendering ?

#1
Hi! Recently I read this article https://docs.cryengine.com/display/CEPR ... nd+Effects
and I want to trying this feature
I wrote this code for testing only, I just wanna checking camera space rendering abbility with random static object

Code: Select all

void ISelectable::Initialize()
{
//...code
// camera space
m_pEntity->LoadGeometry(2, "Assets\\Objects\\selection.cgf");
flags = ENTITY_SLOT_RENDER | ENTITY_SLOT_RENDER_NEAREST;
GetEntity()->SetSlotFlags(2, flags);
auto *pMaterial = gEnv->p3DEngine->GetMaterialManager()->LoadMaterial("Assets\\Objects\\selection.mtl");

m_pEntity->SetSlotMaterial(2, pMaterial);
m_pEntity->SetSlotCameraSpacePos(2, Vec3(10, 10, 10));

}
Question: Why it not working and why I don't see my static mesh relatively to camera space ?
What range for Vec3 I should use in method SetSlotCameraSpacePos ?
Last edited by MoonBeam on Tue Oct 23, 2018 4:16 pm, edited 1 time in total.

Re: How to Camera-Space Rendering ?

#2
Hey there,

Something like this should work;

Code: Select all

const Vec3 cameraSpacePosition = (gEnv->pSystem->GetViewCamera().GetMatrix().GetInverted() * worldTransform).GetTranslation();
pEntity->SetSlotCameraSpacePos(2, cameraSpacePosition);
Let us know if this doesn't work for you
Uniflare
CRYENGINE Community Coordinator
Here to help the community and social channels grow and thrive.

My personal belongings;
Beginner Guides | My GitHub | Splash Plugin

Re: How to Camera-Space Rendering ?

#3
Thx! Yep, now I see meshes above all other objects, but this is not the "Camera Space" in my opinion
I expected that I see the camera's attached objects, but not projections tricks for nearest rendering.
I thinking some kinda of 3d HUD menu, and how to draw it. but this techique is more likely for weapon's and hand's rendering in FPS games near the walls )
Anyway thanks)
Do you know how to draw objects over / above all scene, but attached to camera space/ view ?

Re: How to Camera-Space Rendering ?

#4
I am not a rendering guy so take this with a grain of salt but;

Camera space is just the space with the camera as the origin, using the inverse of the camera rotation you have a base for the camera space which is what cameraSpacePosition is essentially doing in its argument calculation.

Having an object draw over other objects in a scene is not related to camera space but simply drawing the object last in the scene, making sure it is over every other object. Generally this is what the rendering flag ENTITY_SLOT_RENDER_NEAREST does for you, as well as setting the camera space position attribute - telling the renderer to render this object in the nearest render phase.

Are you saying this is not what your outcome is?
Do you have a screenshot or something showing the issue you are having trying to draw this object over other objects?
Uniflare
CRYENGINE Community Coordinator
Here to help the community and social channels grow and thrive.

My personal belongings;
Beginner Guides | My GitHub | Splash Plugin

Who is online

Users browsing this forum: No registered users and 1 guest