leopeltola / Godot-3d-pixelart-demo

A 3D pixelart outline/highlight shader for Godot 4.
MIT License
250 stars 13 forks source link

Shader changes scene background colour #2

Closed dodgyville closed 1 year ago

dodgyville commented 1 year ago

Hi, I love this shader a lot, you've done a great job. I can't quite get the effect the same though.

  1. I create a 3D scene and a camera. Screenshot from 2023-03-08 09-46-39

  2. I place a quadmesh in front of the camera.

  3. I add a material override with the shader attached, with purple highlights and blue shadows.

Screenshot from 2023-03-08 09-51-29

  1. The objects in the scene get blue shadows and black outlines.
  2. The background colour of the whole scene goes purple. Screenshot from 2023-03-08 09-46-45

I was expecting the objects to get purple highlights or a purple outline but the background to stay the same colour. Do you have any suggestions maybe? This is godot 4.0

leopeltola commented 1 year ago

I never tested the shader with no background, seems like the normals start acting funny without meshes to collide with. Adding a distance check seems to fix this:

if (highlights_enabled) to if (highlights_enabled && getDepth(SCREEN_UV, DEPTH_TEXTURE, INV_PROJECTION_MATRIX) < 1000.)

This works but is suboptimal performance-wise. Shouldn't really matter since the rendering resolution is so low but I'll do a better version once I update the shader again.

Let me know if the problem persists