Jump to content

Photo

Membrane shader problem

script shader actor automaton alive effect membrane glow living papyrus

  • Please log in to reply
39 replies to this topic

#1
CALEB2

CALEB2

    Old hand

  • Premium Member
  • 533 posts

I'm trying to make a script that adds glow to Dwemer automatons. (As an update to my already existing mod)

 

Introduction:

 

My mod currently uses membrane shader that covers automaton glow when automaton dies. (Automatons have glow maps attached to meshes) This method works perfectly, however there are few things that are bad -

 

1. The effect must remain constant after automatons have been killed.

2. Already dead automatons (not the static ones - but the not active, never been alive ones) are glowing, because they use the same mesh as living ones.

3. When using ENB, the glow shines a bit through the membrane shader after automaton gets killed. (depends on the ENB settings)

4. The membrane shader uses texture, but the problem is that the texture, when added as a membrane, looks too dark in the places with bright light and too bright in the darkness.

 

Solution - turn this thing around. In my update I removed the glow maps from the meshes and I use the membrane shader texture as glow. This way I can apply the glow to the active automatons only and when the automaton dies, the membrane shader gets removed slowly, making the glow disappear.

 

 

 

Now the problem I'm having with the membrane shader:

 

I need a simple way to detect if actor is alive. There is a script to detect if actor is dead, but not if the actor is alive. I'm using all kinds of different states to emulate this. But it's not working in every occasion. I need a 100 % working solution that's simple, just one state in script.

 

What is the simplest way to determine if actor is alive ?

 

 

And the worst problem: when my script works, everything seems fine - automaton glows and if I kill it, the glow disappears slowly.

But - when I hit the automaton with fire or lightning, the glow disappears instantly. (even when the automaton doesn't die)

It does not happen when I hit the automaton with a regular weapon or frost impact. Only when the weapon or spell does fire or shock damage.

 

How to prevent this ? 

 

 

 

 



#2
HeirOfTheSeptims

HeirOfTheSeptims

    Old hand

  • Premium Member
  • 717 posts

I'm going to answer question 2 first, because I'm a rebel like that. Unfortunately, there's no reliable way that I know of to fix that problem (I could be wrong). The membrane shader from the spell effect is overriding the one you've applied. A "solution" might be to make the glow look less solid and more magical, then it may look less odd when other shaders suppress it.

 

As far as question 1 I have have two options for you:

 

You could make the shader be applied by an ability spell instead, then give it the condition GetDead != 1 (this is probably the simpler option, with your actor script just adding the spell or even giving it directly to the race's ability)

 

or you could have the script apply the shader OnCellAttach with an If statement to check that they are not dead already, then make the script remove it either OnDying or OnDeath (It would probably be best to also remove the shader OnCellDetach as well).



#3
CALEB2

CALEB2

    Old hand

  • Premium Member
  • 533 posts

About the membrane shader from the spell overriding the one I've applied - I tried the option "Allow multiple membrane Shaders" in CK, but that didn't help.

 

Is there some option to disable the membrane shader from spell ?  Or re-apply my membrane shader automatically again after it has been overridden ?

 

 

 

My experience with scripting is quite new.

 

How to use the condition GetDead != 1  ?

 

I found some examples like: if player.getdead==1 and if getdead == 0   What's the right usage ?  Is it an event or a function ?  

 

As I understand. the number must be 0, not 1, because I need to get the "alive" state (as in not dead.)

 

 

Is it like this:

 

Function GetDead()

   If _Self.IsDead = 0

     LoadGlow()
   EndIf

EndFunction



#4
HeirOfTheSeptims

HeirOfTheSeptims

    Old hand

  • Premium Member
  • 717 posts

No, I mean as part of the conditions on the magic effect (it may not be 100% necessary, since spells usually dispel on their own after death, but abilities may be different. Either way it wont hurt.) 

 

https://www.creation...le=Magic_Effect

https://www.creation...ition_Functions

 

You use your shader as the hit shader, check FX Persist, then use it as part of an ability spell. No scripting required.

 

If you use this method it may also fix your issue of the shader not reapplying. As far as I recall shaders from active spells reappear after overriding shaders wear off (Such as being hit by a fire spell while you have an armor spell active, the armor spell shader will return afterwards).

 

If you wanted to use the scripting method, you would use either: If(AutomatonRef.IsDead() == 0) or If(AutomatonRef.IsDead() != 1)  (same thing, different syntax. There are several other ways to phrase it, but I find that these are the best for knowing what the code was when you look back later)

 

Again, I recommend at least trying the ability method first, especially if you're unfamiliar with scripting. With shaders in particular you can risk lagging the game if you get something wrong. Doing it as part of a spell effect means that all of the hard work is done for you.



#5
CALEB2

CALEB2

    Old hand

  • Premium Member
  • 533 posts

I have glow mapped textures for very specific areas for the automatons. Only certain patterns must glow. This needs the textures. 

 

If I can ditch the script, very good. 

 

 

I have FX Persist checked, also Hit Shader (set as my effect shader that has the textures) Target conditions I added GetDead == 0

What should I set as the Effect  Archetype if I want to get rid of the script ? (currently it's set as script) 



#6
HeirOfTheSeptims

HeirOfTheSeptims

    Old hand

  • Premium Member
  • 717 posts

The script archetype is fine. It doesn't mean that there has to be a script, it just means that the effect itself doesn't actively do anything.



#7
CALEB2

CALEB2

    Old hand

  • Premium Member
  • 533 posts

Ok, thanks a lot ! 

 

I will try with these settings. 



#8
maxarturo

maxarturo

    What does this even mean?

  • Supporter
  • PipPipPipPipPip
  • 2,732 posts
I've already been down this road, that's why on your first post on the matter i suggested specific solutions on how to do this, taking the easy road always has hiccups.
 
Unfortunately, the only valid and correct solutions for your issue is in that first post.
 
Have a happy modding.


#9
CALEB2

CALEB2

    Old hand

  • Premium Member
  • 533 posts

I got it partially working without script. (using GetDead != 1 as spell condition) The spell is applied as ability.

 

What works: living automatons glow and non-living (clutter) automatons are not glowing. And when I kill an automaton, the glow disappears slowly.

 

But there is still the problem with glow disappearing instantly when automaton gets hit by fire or lightning.

Is there any way to reset or re-apply the glow on such occasion ?

And another thing - I wish to apply different glow (dimmer and pulsating) when automatons are not moving. With GetDead != 1 there is only one glow effect active. If I use any other condition instead, there is no glow at all.

 

If these problems cannot be solved in plugin, I'd like to know how to replace the mesh (nif file) with script. I have mesh A and mesh B. how does the swapping look like in script ? Mesh with glow should be loaded when living automaton gets detected and upon death the mesh without glow should be loaded. (Without any disappearing-reappearing) And there should be slow fade away effect.

 

Desired result:

Automatons that are in sleep state or stationary, use one effect (dim and pulsating),

automatons that are active and move, use another effect (full constant glow),

automatons that are dead by default (never been alive) must remain without glow,

when kiling automatons, the glow must disappear slowly.

when hitting automatons with fire or lightning, the glow should not disppear.

 

Is this doable with swapping meshes or with mesh animations ? 



#10
maxarturo

maxarturo

    What does this even mean?

  • Supporter
  • PipPipPipPipPip
  • 2,732 posts
What you want to do can only be achieved by 'Animating the Glow', this is not an easy thing to explain in a written post, you are gonna have to start doing some research/studying.
 
Everything you need is in the "Magic Tablets", i don't remember the correct name of the models, it's those tablets with the school of magic on them that glow when you get close to them.
Extract them and study them.
 
The mesh uses the "PlayAnim01" and "PlayAnim02" to turn on and off the glow, and it has the option on its nif data to do it gradually.
 
Once you have comprehend that and you can implement it on your mesh, then you can start worrying about the script, this part it's actually quite easy since there are individuals here that can assist you with that, plus i already have quite a few script that use this already, they may just need some modification to suit your need.
 
The swap of meshes is more easy to do, but you can't achieve the fade out effect you want, it's just On > Off and vice versa.
 
The solutions i suggested in your previous post don't get affected by been hit from a spell, this only happens with the "Magic Effect" that the actor is using at that particular time and there is no workaround to this (the Membrane shader approach). The mesh will always have a flickering of the membrane shader and it will never be stable when hitted by a spell, it's just how the game's engine magic effect system works.
 
Start from somewhere and take it one step at the time, please don't get offended, but for a newbie on the field it's not an easy task, i mean the complicated approach.
 
Have a happy modding.

Edited by maxarturo, 08 May 2021 - 05:01 AM.






Also tagged with one or more of these keywords: script, shader, actor, automaton, alive, effect, membrane, glow, living, papyrus

IPB skins by Skinbox
Page loaded in: 1.046 seconds