my occluder models do not seem to work.

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
Post Reply
User avatar
vanblam
Posts: 243
Joined: Sun Nov 09, 2014 12:15 am

my occluder models do not seem to work.

Post by vanblam »

Occluder is to block light from seeping in correct?
If that is the case I can't figure out how to get them to work.
The occluder I have has 3 sides to block light from seeping into my cave model.
I've had the face's facing outward and inward, light is still coming through. ( I quadruple checked for misspellings and what not, its all correct)
Could some 1 explain to me how they work and what you can and can't do with them.

Image
this is my occluder model.
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: my occluder models do not seem to work.

Post by minmay »

Only triangles on enabled ModelComponents (that have shadow casting enabled) will cast shadows ("block light"). Nothing to do with OccluderComponent

OccluderComponents do exactly what you would expect from the name, they cause occlusion. Specifically, if a ModelComponent (or LightComponent etc). is completely obstructed by OccluderComponent triangles, i.e. no line can be drawn from the camera to the model's (or light's) bounding box without passing through an OccluderComponent triangle that is facing the camera, then that model won't be drawn.

Occlusion is extremely important, without occlusion the dungeon environments would have really, really terrible performance. Make sure you remember to put occluders on all your walls, floors, ceilings etc. and test them. There are a few assets and dungeons released with walls etc. that are missing OccluderComponents or have broken ones (ones that immediately come to mind: Eye of the Atlantis, that dwarf kingdom one, and everything released by Doridion, Prozail, and Eleven Warrior) and it's really visible, they often take more than 5 times as long to render a frame than they should.

You can look at the occluder models in the asset pack if you're confused. Basically you just want to make sure that your occluders are low-triangle (the most complicated one in the asset pack is 32 tris, most occluders are just a rectangle or box), won't have gaps between them, and are facing the right way.

Light isn't "going through" your tunnel model from the outside: it's going through thin air, because your tunnel model doesn't put anything there to block light in the first place, because triangles are one-sided by default. Adding doubleSided = true to its material definition will cause the triangles to block light from both directions (still only the front sides will be lit correctly, but both sides will cast shadows). If you only need that on a few triangles then you should make those double-sided in the model itself instead. Or in this case it looks like you could just add a cage of single-sided, outward-facing rectangles around it, since that appears to be exactly what you're trying to do with OccluderComponent.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
vanblam
Posts: 243
Joined: Sun Nov 09, 2014 12:15 am

Re: my occluder models do not seem to work.

Post by vanblam »

Ahhh I see... I always kind of wondered what that did. You see in my head I was imagining "ambient occlusion" and I was like that makes no sense for these models :P, so then I assumed it meant blocking light haha. Glad you cleared that up for me. So now Ill make sure all my walls, floors and ceilings have an occluder model. :)
Thank you
Post Reply