Ariel Manzur is co-creator of Godot and is currently maintaining the open source project. George Marques is a full-stack developer at Open Journal Solutions. He is an active contributor to the Godot game engine. His projects include the plugin to import Tiled Map Editor levels. For compiling under macOS, the following is required: Python 3.5+. SCons 3.0+ build system. Xcode (or the more lightweight Command Line Tools for Xcode). Optional - yasm (for WebM SIMD optimizations). If you have Home.
Answers
As a quick thought: do your instance objects have a basic shader for initialization that you override per-instance later?
- edited May 2018
Thanks for the quick reply.
No, I don't think so.
I create the mesh using SurfaceTool. I first set the material and then add the vertices. This is correctly rendered when using SpatialMaterial. The problem arises when I try to create a shader object.I'm really new to Godot, so I might not understand this all completely.
Ah, you are defining constants inside the
void fragment()
! In GLES you are not supposed to do that. Try this perhaps(not tested just typed it up here quickly):Mind you this could be optimized. Starting with using mix or smoothstep for splatting perhaps.
- edited May 2018Accepted Answer
I was able to solve my problem indirectly by creating a node in the scene tree that contains a MeshInstance with the shader loaded.
Next I load this shader in my resource manager singleton:and later apply it to the mesh:
It works perfectly
Still I'm wondering what would be the preferred way to do it. @Megalomaniak said:
Ah, you are defining constants inside thevoid fragment()
! In GLES you are not supposed to do that. Try this perhaps(not tested just typed it up here quickly):Mind you this could be optimized. Starting with using mix or smoothstep for splatting perhaps.
When I define any variable outside of fragment() I get:
error(9): Expected '(' after identifier
Thanks for the tips on how to optimizeAs I mentioned, I don't think there is anything substantially wrong with the shader as it works otherwise. I just don't know how to load it from GDScript. I can use the shader in the Godot editor and later access it (see my previous post) but I can't load it directly from GDScript.
- edited May 2018
Now that I think about it - perhaps it was only the uniforms and varyings that had to be defined outside(and at the very beginning) the voids. Been a while since I have written a shader for godot - might have gotten my wires crossed, currently busy writing a new theme for the future forum upgrade.
Also I'm starting to remember someone else having had a somewhat similar problem. Here:
https://godotdevelopers.org/forum/discussion/comment/21655/#Comment_21655Uses SpatialShader IIRC, but also needed to do something similar to what you did.
Perhaps the materials(shaders) need to get compiled by the gpu before they can be instanced/applied to generated meshes or something.
Ok, been working on trying to get a splatmat on a terrain all day. Been trying this video
and using this post. But I'm getting all kinds of errors.
Not only that, but in the video example he gets an area to assign his textures (8:40 in).
Have shaders changed in 3.0.2 to where this post, and this video are no longer relevant?
Even copying/pasting the code from this thread gives me errors.
My assumption is that you can no longer just say 'uniform texture grass', but have to declare a type of sampler2D? (WITH a capitol D by the way).
I even change my vec3 declarations to uniform vec3, and then those errors go away, but then my 'results = grasscolor+dirtcolor+rockcolor;' throws errors....
Ugh...pretty frustrated right now.
-emo
Ok, found this thread LOL
Now I have no errors...but just a blue plane with no textures at all...
- edited May 2018
Need to load the textures from the uniforms respective properties in the inspector(step one inspector level back). Don't forget to save your shader first!
I think that's what I've done here right? On the right side where they are showing up? And I hit save up there on the top of the inspector.
I think it's something with my obj file. Was reading this post here.
I re-exported my terrain as Collada and now it seems to be working...however it's really washed out.
I'll keep grinding, but any thoughts are appreciated !
-emo
- edited May 2018
Ah, yes, you will want to output something into the shaders Roughness value. The ShaderMaterial is basically overriding values of the SpatialMaterial and right now I guess your materials roughness is 0. So it's super reflective.
Also does your material do something with the metallic/specular component(s)?
It would be easiest if you included your shader code.
- edited May 2018
You bet The shader code is:
Is the SpatialMaterial roughness something I have to code for? Also the material shouldn't be doing anything with metallic or specular components (that I'm aware of any)
-emo
- edited May 2018
Hm, in
version 3.0.2
it's working fine for me, but then I am applying it to a Sphere primitiveMeshInstance
. Yep, addedROUGHNESS = float(0.0);
to confirm and it turned reflective then. So works as it should on my end.edit: @bluepangolin55 If you want me to split @emo10001 's posts in a separate thread just let me know.
- edited May 2018
@Megalomaniak said:
Hm, inversion 3.0.2
it's working fine for me, but then I am applying it to a Sphere primitiveMeshInstance
. Yep, addedROUGHNESS = float(0.0);
to confirm and it turned reflective then. So works as it should on my end.Ok, I can see what Roughness can do (I put this in the shader void fragment correct?). But I'm not sure this is the issue. The terrain has this washed out blue tint to everything. Is this the sky? (seems like a watched a tutorial where they talked about the default sky causing things to look funny)
It looks the same if I put ROUGHNESS at 1 or comment it out. Washed out blue tint.
-emo
@emo10001 said:
Ok, I can see what Roughness can do (I put this in the shader void fragment correct?).Yep.
@emo10001 said:
But I'm not sure this is the issue. The terrain has this washed out blue tint to everything. Is this the sky? (seems like a watched a tutorial where they talked about the default sky causing things to look funny)I bet it's to do with the colorspaces of the textures you are using(they are likely sRGB while godot's rendering pipleine is HDR and works in linear space!)
So see the edit I added to my last post in the thread you linked to earlier and the post above it for an example of using hints:
https://godotdevelopers.org/forum/discussion/comment/22241/#Comment_22241Ha...thanks for the reminder. I actually had the hints in there at one point...I must have copy/pasted some older code I had before I put it in (it's actually in my 2nd screenshot LOL).
That certainly helps! Thanks a ton @Megalomaniak !
-emo
The Book of Shaders ported to Godot's shader language with an editor.
Live loading, editing and saving of godot shaders in a simplified interface.
Experiment, create new shaders, but most importantly - have fun!
Source code: https://github.com/jayaarrgh/BookOfShaders-Godot
Migrate to Godot's shader language
Book Of Shaders - Godot Mac Os Download
Status | Released |
Platforms | Windows, macOS, Linux, HTML5 |
Rating | |
Author | jayaarrgh |
Genre | Educational |
Tags | godotengine, shaders |
Download
Log in with itch.io to leave a comment.
Holy Moly, this is just what I was searching for. Thank you!!
omg, this is amazing. I'm actually speechless rn. GOOD JOB!!!!!!!
for linux you cant open it. first turn on allow launching.
Water Shader Godot
$ chmod +x BookOfShadersGodot_alpha.x86_64
$ ./BookOfShadersGodot_alpha.x86_64