I have managed to apply a shader effect that I like to a 3d model of a box (that I found online). In the pic you can see two boxes, both started off with the design that is on the top box but to get the shader onto the bottom box, i had to apply the shader effect to a shaderMaterial, How can I keep the original look of the top box?
Apply shader but keep visual look of mesh?
- Edited
The original pixel (fragment) will be COLOR in the fragment shader. If you want the original look, you could do:
ALBEDO = COLOR.rgb
At the end of the shader. If you want to add stuff on top, then you will have to mix the colors somehow. For example, to mix 50/50 opacity, you could do:
vec3 custom_color = vec3(1.0, 1.0, 1.0); // or whatever
ALBEDO = mix(COLOR.rgb, custom_color, 0.5);
See the documentation for details:
https://docs.godotengine.org/en/stable/tutorials/shaders/shader_reference/shading_language.html
https://docs.godotengine.org/en/stable/tutorials/shaders/shader_reference/spatial_shader.html
Or use multiple material passes and some blending option such as add or multiply.
cybereality Thanks for the help! I had a go but no joy.
Looking at the model I would GUESS that I can't do what I want as the box already has a graphical mesh on it as default? I certainly cannot see how/where to add a shader as another material layer on top of it. Anything I try erases the nice metallic skin
- Edited
if you look a bit further down in the inspector right after Software Skinning
there is another collapsed subsection called Material
. What you are tweaking is the meshes 'default'/base surface material rather than the instances materials.
Megalomaniak Thanks for replying
When i open material, and click on [empty] i get two options Shader/Spatial Material, both of which will turn the box into a single color cube and I lose the metallic mesh.
Apologies If i am missing something obvious, this learning curve is hard going!
- Edited
Wait - i made progress, I needed to go into the Mesh and edit it and then i got to add a pass where i could add my shader!!
SINCERE THANKS ALL !