Models w/ translucency not rendered from the inside
Moderator: GZDoom Developers
Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
- Tormentor667
- Posts: 13533
- Joined: Wed Jul 16, 2003 3:52 am
- Contact:
Models w/ translucency not rendered from the inside
Just playing around with some stuff and noticed that models with an Tranclucency value aren't rendered from the inside, just from the outside - where as normal rendered models (like cubes or globes) are rendered from the inside and outside both.
*EDIT*
Added an example to demonstrate the problem:
https://www.dropbox.com/s/tk0tqbihc381j ... e.zip?dl=0
1 is rendered normal, step "into" the moon model and you will see the textures from the inside.
2 is rendered translucent with full alpha, step into the inside of the model and it will "disappear" (no textures drawn from the inside)
3 is rendered additive with full alpha, you can already see the problem.
It is clear to me why this has been solved the way it has been, but some option that forces rendering the inside of a model even when it is translucent would help a lot to do the skybox effect people have been suggested in the other thread
*EDIT*
Added an example to demonstrate the problem:
https://www.dropbox.com/s/tk0tqbihc381j ... e.zip?dl=0
1 is rendered normal, step "into" the moon model and you will see the textures from the inside.
2 is rendered translucent with full alpha, step into the inside of the model and it will "disappear" (no textures drawn from the inside)
3 is rendered additive with full alpha, you can already see the problem.
It is clear to me why this has been solved the way it has been, but some option that forces rendering the inside of a model even when it is translucent would help a lot to do the skybox effect people have been suggested in the other thread
Last edited by Tormentor667 on Sat Dec 02, 2017 6:32 am, edited 1 time in total.
Re: Models w/ translucency not rendered from the inside
This is because the model translucency support was never really properly finished. It makes the model "translucent" by turning on backface culling, which only works for simple models.
A better way to do it would be to render the model twice. First with color output disabled that fills the zbuffer. Then draw it again with color enabled. That will make the second pass not draw faces that are occluded by the model itself.
Relying on two-sided materials is bad in general. This is because it has to render all faces no matter what, effectively making it twice as expensive for the GPU to draw the model. It is much better to make your faces always point in the right direction.
A better way to do it would be to render the model twice. First with color output disabled that fills the zbuffer. Then draw it again with color enabled. That will make the second pass not draw faces that are occluded by the model itself.
Relying on two-sided materials is bad in general. This is because it has to render all faces no matter what, effectively making it twice as expensive for the GPU to draw the model. It is much better to make your faces always point in the right direction.
- Tormentor667
- Posts: 13533
- Joined: Wed Jul 16, 2003 3:52 am
- Contact:
Re: Models w/ translucency not rendered from the inside
Thanks for the explanation, so all I need is actually a model for "planet.md3" that has its faces inversed? (no idea how to do it btw)
- Major Cooke
- Posts: 8175
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: Models w/ translucency not rendered from the inside
I would like to know how to do inverted modelling as well.
Re: Models w/ translucency not rendered from the inside
Normally you do this in the modelling tool (Blender, 3ds max, Maya), which differs. It sounds like you don't have the original source, but only the exported planet.md3. I don't know if there's any tool out there that can edit a md3 file directly.
- Tormentor667
- Posts: 13533
- Joined: Wed Jul 16, 2003 3:52 am
- Contact:
Re: Models w/ translucency not rendered from the inside
Exactly that. So what about an option for the MODELDEF instead that forces to render the inside?dpJudas wrote:It sounds like you don't have the original source, but only the exported planet.md3.
Re: Models w/ translucency not rendered from the inside
If you are adept at creating models, you can create a large cube, and then put your source model inside the cube and set it to be a negative intersection (in other words, a cut-out). You can then use a raw polygon editor and remove the extra 6 outside faces this created.
- Tormentor667
- Posts: 13533
- Joined: Wed Jul 16, 2003 3:52 am
- Contact:
Re: Models w/ translucency not rendered from the inside
If this is not a bug, can it be turned into a feature request - actually an additional flag in the MODELDEF to force rendering of the inside?
- Major Cooke
- Posts: 8175
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: Models w/ translucency not rendered from the inside
I'll just make one for you Tormentor. Worst case scenario, it's 6 planes because god knows how the texture placement is going to work... so six actors in total, if it doesn't go according to plan. In fact I think that actually might be easier than trying to stitch together 6 whole images to perfection via photoshop...
Re: Models w/ translucency not rendered from the inside
@Major Cooke -
You can specify textures per surface/group in MODELDEF - so as long as each plane is a separate group, you can just set the texture for each one as appropriate (using the SurfaceSkin property). Or you can compile the model with the relative paths to the skybox textures and they'll work fine in-game.
As a thought (and I haven't tested this at all...), could a 3D floor set to render inside and to use the sidedef's lower or upper texture for the sides be used for this instead of a model?
(EDIT: No, you can't, unless someone knows of a way to change the alpha of a 3d floor in game).
You can specify textures per surface/group in MODELDEF - so as long as each plane is a separate group, you can just set the texture for each one as appropriate (using the SurfaceSkin property). Or you can compile the model with the relative paths to the skybox textures and they'll work fine in-game.
As a thought (and I haven't tested this at all...), could a 3D floor set to render inside and to use the sidedef's lower or upper texture for the sides be used for this instead of a model?
(EDIT: No, you can't, unless someone knows of a way to change the alpha of a 3d floor in game).
Last edited by AFADoomer on Sat Dec 02, 2017 7:44 pm, edited 1 time in total.
- Major Cooke
- Posts: 8175
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: Models w/ translucency not rendered from the inside
Please do show me then. I'm having a hard time figuring out how that's done.
Re: Models w/ translucency not rendered from the inside
Check out the model that Talon1024 put together for WolfenDoom here. It is just a plain cube, but each face is grouped as a separate surface - top, bottom, east, west, north, south. Additionally, the textures on the model were set in whatever editor was used, pointing them to "textures/skyboxes/plainssun/_____.png" (where _____ is the appropriate texture for that side of the skybox).
The MODELDEF entry for this actor is relatively simple:
If we wanted to specify the skin via MODELDEF instead of using the compiled-in texture paths, we'd use the SurfaceSkin property:
To get the surface-index number, we need to know the order of the surfaces within the model file. The easiest way to see this is to import the model into your editor or model viewer and look at the order that the groups are listed in. In the case of the plainssun3d model, surface indexes 0 to 5 correspond to west, south, east, top, bottom, and north, in that order.
Defining the various face's textures in MODELDEF would then look something like this:
This also allows you to use the same model again with different textures without having to bloat your mod and add additional copies of model files.
The MODELDEF entry for this actor is relatively simple:
Code: Select all
Model PlainsSun3D
{
Path "models"
Model 0 "plainssun3D.md3"
Scale 1.0 1.0 1.2
USEACTORPITCH
USEACTORROLL
FrameIndex MDLA A 0 0
}
Code: Select all
SurfaceSkin model-index surface-index skin-file
Defining the various face's textures in MODELDEF would then look something like this:
Code: Select all
Model PlainsSun3D
{
Path "models"
Model 0 "plainssun3D.md3"
Scale 1.0 1.0 1.2
USEACTORPITCH
USEACTORROLL
Path "textures/skyboxes/plainssun"
SurfaceSkin 0 0 "abra_w.jpg"
SurfaceSkin 0 1 "abra_s.jpg"
SurfaceSkin 0 2 "abra_e.jpg"
SurfaceSkin 0 3 "abra_t.jpg"
SurfaceSkin 0 4 "abra_b.jpg"
SurfaceSkin 0 5 "abra_n.jpg"
FrameIndex MDLA A 0 0
}