+5 votes

Just started to use Godot today, and the first thing I tried is writing a PBR shader. Crazy me!

This is what I have so far. Not quite there, but it's a start.

Godot PBR
I'm pretty sure reflections are not ok and they're just a basic addition to albedo, this far. Cook-Torrance specular seems to be working fine, on the other hand.

The worst thing is that I'm not acoustomed to separate fragment from lighting part, and this is driving me crazy.

Now the questions (a lot):

Do I need to do a linear/gamma correction of the textures (they are sRGB)? When I do, it doesn't look as expected.

For creating shadows, do I need to create a depth map, or can I get it somewhere and pass it as a uniform? How about shadow matrix? Could help a lot to have these as prebuilt uniforms.

I cannot access VAR1 and VAR2 varyings from the Lighting tab. I believe this is a temporary bug?

When accessing matrices, I cannot access values directly, as for instance:

INV_CAMERA_MATRIX.x.xyz

I have to do:

vec4 camMat1 = INV_CAMERA_MATRIX.x;
camMat1.xyz;

This would be a temporarily bug, as well, as I have seen it done in the documentation examples. right?

Thanks in advance. Looking forward for an improval on shader language documentation.

in Engine by (17 points)

1 Answer

+1 vote

Do I need to do a linear/gamma correction of the textures (they are sRGB)? When I do, it doesn't look as expected.

Godot has a sRGB mode and supports high dynamic range. You can enable it in your WorldEnvironment. More information here.

Also, you should know that Godot 3.0 will have physically-based rendering out of the box, using OpenGL ES 3.0. But still, it's a nice effort to implement PBR in OpenGL ES 2.0. :)

by (12,783 points)
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]ine.org with your username.