Forum rules - please read before posting.

2D background and per pixel 3D object occlusion, shader, game like disco elysium

Hi, I'm an Artist who is trying to make a small point-and-click adventure game and wants to showcase more of the art side of things,
can't find anything better than this asset, but I want to achieve some specific visual art style, here is my plan for the visual
1. I will make the whole environment in 3d (Maya/blender) and then render the diffuse, normal, and Z depth.
2. paint over the final render and this will be the texture of a flat 2d plane.
3. need a shader to calculate the depth using the pre-rendered Z depth so that I can use the 3d characters/ moveable objects to occlude from front/back.

But, I'm stuck with the 3rd point, here are a few videos, so that you can understand what exactly I'm looking for

this is a tech demo of pillars of eternity

this is the exact system I'm looking for

I'm trying to create an environment very close to Disco Elysium

a side note- as far as I know the inbuild dialogue system of AC cant replicate the dialogue system of Disco Elysium, like what is in the right, like a book and the choices are also part of it, it would be really awesome if any of you can give me a heads up for the solution here in AC.

back to the topic,

Ive somehow managed to find a solution where I am able to use the depth system, my 3d characters are properly sorted based on z depth, but the shader that I'm using does not support any Normal map, and it also does not react to light, I have Zero knowledge of shader coding, here is the shader code

_Shader "Custom/BackgroundDepthShader"
{
Properties
{
_MainTex("Background", 2D) = "white" {}
_DepthTex("Depth", 2D) = "white" {}
}
SubShader
{
Tags {"Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent"}
Blend SrcAlpha OneMinusSrcAlpha
ZWrite Off
Cull back

Pass
{
CGPROGRAM

pragma vertex vert

pragma fragment frag

include "UnityCG.cginc"

struct VertexInput
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};

struct Vert2Frag
{
float4 vertex : SV_POSITION;
float2 uv : TEXCOORD0;
half4 posScreen : TEXCOORD1;
};

uniform sampler2D _MainTex;
uniform float4 _MainTex_ST;
uniform sampler2D _DepthTex;

uniform sampler2D _LastCameraDepthTexture;

Vert2Frag vert (VertexInput vertIn)
{
Vert2Frag output;
output.vertex = UnityObjectToClipPos(vertIn.vertex);
output.posScreen = ComputeScreenPos(output.vertex);
output.uv = TRANSFORM_TEX(vertIn.uv, _MainTex);
return output;
}

float4 frag (Vert2Frag fragIn) : SV_Target
{
float4 col = tex2D(_MainTex, fragIn.uv);
float depth = 1 - SAMPLE_DEPTH_TEXTURE_PROJ(_LastCameraDepthTexture, UNITY_PROJ_COORD(fragIn.posScreen));
float texDepth = 1 - tex2D(_DepthTex, fragIn.uv).z;
col.a = 1 - saturate((texDepth - depth) * 1000);
return col;
}
ENDCG
}
}
}

_

NOW, can any of you please help me understand how to add a normal map in this shader that reacts based on light? As far as I understand this is not a surface shader. What can I do to make it like the shader in the second video?

Sorry for my bad English. Thank you.

Comments

  • edited April 28

    Welcome to the community, @pixelRant.

    Firstly: apologies for the delay in replying. Your post mistakely ended up in the automatic spam filter - I've now verified your account so it shouldn't occur again.

    Regarding the 2D/3D situation: in AC terms, this would be a 3D game - with the background art being 2D sprites/quads underneath the NavMesh, similar to the first video.

    The difference between the first two videos, however, is that the first relies on isometric projection, while the other uses perspective projection. The shader code, I'd expect, would be different for each - are you going for an isometric projection?

    In terms of the shaders involved: those used in the videos are very specific, tailored to the exact needs of their respective projects. AC isn't a graphics tool, but it can be used with custom shaders it is supplied with.

    My guess at a more simplified approach would be to create a lower poly version of your set, which is then placed in the scene in the correct 3D space. This would be invisible, but still able to project shadows, and occlude characters that move behind it. I'm not sure of the exact shaderwork involved, but I'd imagine this approach would be a fair bit easier than purely relying on flat textures, at least so far as any custom code goes.

    a side note- as far as I know the inbuild dialogue system of AC cant replicate the dialogue system of Disco Elysium, like what is in the right, like a book and the choices are also part of it, it would be really awesome if any of you can give me a heads up for the solution here in AC.

    The "Chat Log" script over on the AC wiki demonstrates how custom scripting can be used to list spoken lines in a scrolling text box:

    https://adventure-creator.fandom.com/wiki/Chat_log

    Chosen dialogue options can be included as well, but Conversation options to choose from must currently be displayed in a separate Menu.

    I shall give some thought as to how this might be achieved, however.

  • edited April 28

    Turns out the Conversation options wasn't a big issue - I've updated the Chat Log to include clickable Conversation options, and added it as a package to the Downloads page.

    On the 2D/3D topic: there is an asset on the store that assists with 3D characters on 2D characters, and I believe it integrates with Adventure Creator:

    https://assetstore.unity.com/packages/tools/game-toolkits/2-5d-toolkit-137626

    I'm not sure how it handles lighting etc, so I would recommend asking the author for advice on this.

  • Hi Chris , sorry for the late reply, thank you for your suggestions, will try low poly base for occluding characters instead of pure 2d flat. my project is isometric... I guess they have also used a 3d base of occlusion ... idk, not sure how to, but will try , thanks :)

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.