Skip to main content
added 144 characters in body
Source Link
Dahl
  • 21
  • 7

I have found a solution where I am using a depth texture for each sprite to simulate 3D shadows similar to the illustration in my question.

I don't know if "Songs of Syx" in particular does it the same way, but i suspect it's in the same ball park.

I am rendering the scene to multiple textures bound to a framebuffer object.

Diffuse (rgb8), Normals(rgb8), Height(red8) (Off screen buffers)

After the entire scene is rendered I do another shader pass where I calculate shadows. (Height texture only). In the fragment shader, every fragment cast a ray FROM it's position TOWARDS the light. I sample pixels from the height texture along that ray (with a delta value), if any sampled pixel values are greater than the value of the fragment you are processing, then you know it is in shadow.

Here you could "accumulate shadow" if you want, based on how many pixels you "hit" while tracing the light.

Then you could store the accumulation in another "shadow texture" used in the final lighting calculations.

At this point, you have a "shadow texture", "normal texture" and "color texture" of the entire scene. To use with any lighting algorithms you want.

I am still testing things out, but I am very happy with how it looks, feels and performs. :)

I have found a solution where I am using a depth texture for each sprite to simulate 3D shadows similar to the illustration in my question.

I don't know if "Songs of Syx" in particular does it the same way, but i suspect it's in the same ball park.

I am rendering the scene to multiple textures bound to a framebuffer object.

Diffuse (rgb8), Normals(rgb8), Height(red8)

After the entire scene is rendered I do another shader pass where I calculate shadows. (Height texture only). In the fragment shader, every fragment cast a ray FROM it's position TOWARDS the light. I sample pixels from the height texture along that ray (with a delta value), if any sampled pixel values are greater than the value of the fragment you are processing, then you know it is in shadow.

Here you could "accumulate shadow" if you want, based on how many pixels you "hit" while tracing the light.

Then you could store the accumulation in another "shadow texture" used in the final lighting calculations.

At this point, you have a "shadow texture", "normal texture" and "color texture" of the entire scene. To use with any lighting algorithms you want.

I am still testing things out, but I am very happy with how it looks, feels and performs. :)

I have found a solution where I am using a depth texture for each sprite to simulate 3D shadows similar to the illustration in my question.

I don't know if "Songs of Syx" in particular does it the same way, but i suspect it's in the same ball park.

I am rendering the scene to multiple textures bound to a framebuffer object.

Diffuse (rgb8), Normals(rgb8), Height(red8) (Off screen buffers)

After the entire scene is rendered I do another shader pass where I calculate shadows. (Height texture only). In the fragment shader, every fragment cast a ray FROM it's position TOWARDS the light. I sample pixels from the height texture along that ray (with a delta value), if any sampled pixel values are greater than the value of the fragment you are processing, then you know it is in shadow.

Here you could "accumulate shadow" if you want, based on how many pixels you "hit" while tracing the light.

Then you could store the accumulation in another "shadow texture" used in the final lighting calculations.

At this point, you have a "shadow texture", "normal texture" and "color texture" of the entire scene. To use with any lighting algorithms you want.

I am still testing things out, but I am very happy with how it looks, feels and performs. :)

Source Link
Dahl
  • 21
  • 7

I have found a solution where I am using a depth texture for each sprite to simulate 3D shadows similar to the illustration in my question.

I don't know if "Songs of Syx" in particular does it the same way, but i suspect it's in the same ball park.

I am rendering the scene to multiple textures bound to a framebuffer object.

Diffuse (rgb8), Normals(rgb8), Height(red8)

After the entire scene is rendered I do another shader pass where I calculate shadows. (Height texture only). In the fragment shader, every fragment cast a ray FROM it's position TOWARDS the light. I sample pixels from the height texture along that ray (with a delta value), if any sampled pixel values are greater than the value of the fragment you are processing, then you know it is in shadow.

Here you could "accumulate shadow" if you want, based on how many pixels you "hit" while tracing the light.

Then you could store the accumulation in another "shadow texture" used in the final lighting calculations.

At this point, you have a "shadow texture", "normal texture" and "color texture" of the entire scene. To use with any lighting algorithms you want.

I am still testing things out, but I am very happy with how it looks, feels and performs. :)