0 votes

enter image description here
Add a universal common rim light shader even if the material is different for each modeling !!!!

You can include effects header files in each and every material shader file to support the effects of all materials.

For example,
in all other material's .glsl ( shader source )

include "effect_shader.h" <-include effects header files in each and every material shader

// rim light effect

if %RIMLIGHT

color = function():

endif

style header add please!!!!

Godot Engine Material
HumanSkin shader - head, body
illum shader - item ( weapon, shield, cloth )

head, body, cloth = material is different for each modeling
rim lighting = all material support effect file ( header file )

effect shader - effect header file for all other shader material support ( add please !!!! )

in Engine by (12 points)
edited by

1 Answer

0 votes

Rim is supported in SpatialMaterial, all you have to do is to enable it. It works in editor of from a script.

It shouldn't be too hard to do it with a bit of scripting:
Get all materials of your character, and enable rim on them:

extends MeshInstance

func set_rim(enabled):
    for i in mesh.get_surface_count():
        var mat = mesh.surface_get_material(i)
        mat.rim_enabled = enabled
        # + set other params if needed

However that will modify all MeshInstances if you re-used the same mesh multiple times.

Another way is to use material_override, which will temporarily use a different material for only one particular MeshInstance. So you could duplicate the mesh's material, set rim params and set it as an override.
However, if your mesh has multiple materials it's a known problem: https://github.com/godotengine/godot/issues/14588

Apart from that, I'm not sure what you want to be added in the engine, the effect you posted in your screenshot can be achieved already. If what I said doesn't help you, please explain your problem better because I don't understand half of what you wrote...

If you can't find a solution anyways, you can go to the Github, do a search, explain clearly your problem, why you can't do it and why it should be built-in.

by (29,046 points)
edited by

Purpose of effect shader
Turns the target effect shader on or off during the action event time (attack or defense).

real time toggle target's effect shader.

Can the above answer solve my problem?

PS.
The following conditions must be met:
Add generic common effects shader even if the material is different for each modeling!

For a rim effect like your screenshot shows, you don't need to write any shader. Godot supports it already.
If you wrote your own shaders for everything, it's on you to do that.

Can I change the rim light color to another color?

Hmm not on the material, but apparently it follows the color of the nearest light source. It has a "physically based" implementation, so it can't be coloured arbitrarily...
Unless you fork the internal shader to force a specific rim color. BUT, you don't need to change the engine to do that, you can create a ShaderMaterial, write your shaders directly in the editor and have your own rim using the engine's shading language. There is a way to pre-fill such a shader from an existing SpatialMaterial so you don't have to write too much boilerplate, by right-clicking on the material within the property field, and "Convert to ShaderMaterial".
Alternatively you could ask for a built-in optional colouring on Github, if it's not too much to add.

How to ask for a built-in on Github?
Where is site url for ask on Github?

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.