Archive 17/01/2023.

Render model always on top with color/alpha

esakylli

I want to render a model always on top of all other models, specifying a color with alpha value for it.
Is it possible?

The technique NoTextureOverlay seems to do it, but I cannot use alpha value with the color…
(I want my model to look somewhat transparent.)

esakylli

In my material I tried using technique NoTexture with a color (+ alpha), together with renderorder but no luck.
I’m not sure how renderorder works, but shouldn’t I be able to adjust the rendering order with it?
But maybe it just works with some specific technique?

Dave82

Perhaps this helps.The same idea should work for your case

https://discourse.urho3d.io/t/show-ui-element-behind-3d-model/3185

esakylli

Thanks for the reply, it got me a little further.
With it I can get my model on top of all, but I’m still facing two issues with it:

  • The model is rendered on top of my cursor, how can I get it rendered between the UI and all other models?
  • I can’t get any alpha (transparency) along with my color, is it possible?
Dave82

Try it like this

<renderpath>
    <command type="clear" depth="1.0" />
    <command type="scenepass" pass="TopObjects"/>
    <command type="renderui"/>
</renderpath> 

Create a copy of your DiffAlpha.xml technique and try to change the “alpha” pass to TopObjects.

esakylli

Thanks @Dave82! It works like a charm :smiley:

One last question about this, is it right adding the render path like this (after I have created the Viewport)?

		var rp = Viewport.RenderPath.Clone();
		rp.Append(ResourceCache.GetXmlFile("RenderPaths/TopObjects.xml"));
		Viewport.RenderPath = rp;
Dave82

Probably the Clone() is unneccessary so you could simply write :

Viewport.RenderPath.Append(ResourceCache.GetXmlFile("RenderPaths/TopObjects.xml"));