Skip to content

spatial shader: using VIEWPORT_SIZE in VERTEX calculation breaks shadows #82782

Closed
@alexjhetherington

Description

@alexjhetherington

Godot version

v4.1.1.stable.mono.official [bd6af8e]

System information

Godot v4.1.1.stable.mono - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1070 (NVIDIA; 31.0.15.3713) - Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz (8 Threads)

Issue description

I'm trying to implement a vertex jitter shader to emulate psx style graphics.

See: https://github.com/AnalogFeelings/godot-psx for a public implementation I am using for reference.

The shader should support shadows but there appears to be a bug in Godot that is preventing shadows from appearing.

As far as I can tell, the issue relates to VIEWPORT_SIZE. The shader uses VIEWPORT_SIZE to scale the jitter based on screensize.

Steps to reproduce

  1. spatial shader
  2. include render mode render_mode skip_vertex_transform
  3. inside the vertex() function,
  4. use VIEWPORT_SIZE in some part of the calculation of VERTEX.

Minimal reproduction project

no_shadows.zip

See screenshot below:

  1. A cube with a default material; shadows are displayed correctly
  2. A cube with a custom material jitter-not-using-viewport.tres; shadows are displayed correctly
    The custom material essentially just does VERTEX = round(VERTEX * i) / i;, where i is set by the user
  3. A cube with a custom material jitter-using-viewport; shadows are not displayed correctly
    The custom material scales i by VIEWPORT_SIZE.y

cubes

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions