Add a universal common effect shader even if the material is different for each modeling !!!!

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By dalxung


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 !!! )

:bust_in_silhouette: Reply From: Zylann

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: Allow multiple material overrides for a MeshInstance (where underlying Mesh has multiple materials) · Issue #14588 · godotengine/godot · GitHub

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.

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!

dalxung | 2018-02-18 12:05

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.

Zylann | 2018-02-18 16:18

Can I change the rim light color to another color?

dalxung | 2018-02-19 07:06

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.

Zylann | 2018-02-19 21:55

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

dalxung | 2018-02-27 12:33

Issues · godotengine/godot · GitHub

Zylann | 2018-02-27 20:14