Dustyroom / flat-kit-doc

Documentation of the Flat Kit asset.
https://flatkit.dustyroom.com
Apache License 2.0
2 stars 1 forks source link

Integrating Curved World Asset/ Shader #58

Open MoAkra opened 3 years ago

MoAkra commented 3 years ago

Hi,

I'm trying to integrate Curved World into Flat Kit shader (StylizedSurfaceOutline in URP). Fortunately, they have extensive documentation, but I have no shader coding experience - I was wondering if you could help?

The documentation is very clear and concise, with plenty of pictures, but it's asking me to paste 3 code snippets in 3 different places. I think I've done the first two correctly, but the rest is unclear.

I would be very happy to send you my project, or any more information you need, but below I have sent the documentation (check pages 41-43) and the three code snippets via notepad. I've also sent some images from the docs, these are the points that confuse me most.

I would be very grateful if you could help me understand where to paste these snippets, but I understand if this is outside the scope of what you do.

Thanks for reading, Mo

Manual.pdf CurevedWorldIntegrationSnippets.txt Screenshot 2021-08-14 162324 Screenshot 2021-08-14 162329

Not sure if this is contributing to the problem, but I'm also getting this message. image

dustyroom-studio commented 3 years ago

Hi Mo,

We don't have a copy of the Curved World asset, be we'll try to help you get it integrated.

Not sure if this is contributing to the problem, but I'm also getting this message.

This should only influence the batching, but not the look of either Flat Kit or Curved World.

Are you seeing any errors, or is either Flat Kit or Curved World not working?


The Curved World documentation mentions two points for the shader integration: ‘Material properties and Definitions’ and ‘Vertex Transformations’. Depending on which Rendering Pipeline you are using, there is small difference in modifying Flat Kit:

dustyroom-studio commented 3 years ago

I've changed the URP version of Flat Kit shaders based on the Curved World documentation and will submit it to the Asset Store today. Once the update is approved (most likely on Monday or Tuesday), please try it out and let us know.

MoAkra commented 3 years ago

Thank you so much for the support, that sounds awesome. I think these assets are made for each other!

I'll try it out and let you know :D

MoAkra commented 3 years ago

I tried the above steps and it hasn't worked for me. I've screen grabbed the code, maybe it's in the wrong place? I'm also going to contact the dev, maybe I'm missing something!

Thanks and let me know if I've done it wrong :)

FlatKit_CurvedWorld_3 FlatKit_CurvedWorld_1 FlatKit_CurvedWorld_2

dustyroom-studio commented 3 years ago

Hi Mo,

Have you tried to activate the updated Flat Kit shaders with Curved World’s Activator tool? It is mentioned on the last page of their manual.

Also, it looks like you modified the code a bit? The changes I made in Flat Kit 2.4.0 (please check if you have this version in Flat Kit Readme) look a bit different, e.g. in the outline shader the line is [CurvedWorldBendSettings] _CurvedWorldBendSettings("0|1|1", Vector) = (0, 0, 0, 0)

On Aug 19, 2021, at 9:48 AM, Mo Akra @.***> wrote:

I tried the above steps and it hasn't worked for me. I've screen grabbed the code, maybe it's in the wrong place? I'm also going to contact the dev, maybe I'm missing something!

Thanks and let me know if I've done it wrong :)

https://user-images.githubusercontent.com/56600104/130109739-33409a19-8744-43ea-b801-f5753050dd43.jpg https://user-images.githubusercontent.com/56600104/130109758-8c187a77-1931-4a38-8239-3b0fadf0daf8.jpg https://user-images.githubusercontent.com/56600104/130109764-0b65ebd7-a13c-40b7-a1d0-feb06aa0a75e.jpg — You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Dustyroom/flat-kit-doc/issues/58#issuecomment-902076083, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARZVF6XOSM67JOIZHPIC5NTT5UYXPANCNFSM5CFFIFMQ. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email.

MoAkra commented 3 years ago

The reason it's different is because each setting has different code. I'm using Little Planet Y, but it's helpful to know where to place the code, thanks :)

I also have to update the shader for each BendID manually with the button shown below, that also adds to the code.

FlatKitCurvedWorld_5 FlatKitCurvedWorld_4

dustyroom-studio commented 3 years ago

Does it work correctly with the steps you mentioned?

MoAkra commented 3 years ago

No, I've contacted the developer, hopefully he can give some insight. I'll relay what he says to you guys. If we can get it working for one setting, it should apply to all of them.

dustyroom-studio commented 3 years ago

Thanks, please keep us updated.

MoAkra commented 3 years ago

Hey guys, I got a response today, but unfortunately it doesn't look we're going to get much help from the developer. If there's anything else I can do, let me know. I can record my screen, or send my project.

"If asset developer do not want (or can not) integrate Curved World into his shader, it is up to the user to do it, but it requires appropriate knowledge of shader programming. Documentation explains all required steps for it."

Either way, thanks so much for the help so far! <3

dustyroom-studio commented 3 years ago

Hey Mo, it seems the author is missing some context since we did integrate Curved World with Flat Kit in v2.4.0...

MoAkra commented 3 years ago

I contacted the developer and he helped just a bit, but seemed like he wasn't all that interested, so I took some time off. I'm back and trying to get it working, but I'm not a shader programmer, so I'm effectively hitting my keyboard with a hammer trying to get it to work.

I've contacted the dev again today, so we'll see what happens.

I've tried to follow the documentation and convert the shaders, but I'm getting a heap of errors. image

If there's any way you can help, I'd be eternally grateful, but I understand if you're not interested. I'll keep trying different things.

Thanks for the support so far :)

MoAkra commented 3 years ago

Also when I convert the Flat Kit material, I lose most of the options that make Flat Kit great.

image

Hitomilras commented 3 years ago

Hi. I face this issue too.

I did make it work, almost.

  1. Added all #pragma & #include to the LitForwardPass_DR.hlsl
  2. Remove #if defined(CURVEDWORLD_IS_INSTALLED) && !defined(CURVEDWORLD_DISABLED_ON) from LitForwardPass_DR

Now bending is work. But flatkit lighting now broken in some cases. Just bend everything like in Subway Surfer (down) and shadows are broken completely. Works very inappropriate .

Conclusion:

  1. I think there is some problems with activation because flatkit shader using LitForwardPass_DR.hlsl. I think CurvedWorld developer just don't expect this scenario and it doesn't work properly out of the box. Because as soon as we removing #if's everything start working.
  2. Flat kit also don't expect such vertex manipulation and shadows are broken.

I believe that this is very important to make this 2 exceptional assets work together somehow. May be it's possible that developers of flat kit will contact with CurvedWorld developers and manage to fix all problems?

For now I think I must to remove Flat Kit from my project and rewrite part of it myself to make it work good with CurvedWorld.

@dustyroom-studio

dustyroom-studio commented 3 years ago

Hi @Hitomilras. Could you please locate the [Readme] file in the 'Flat Kit' folder, press 'Copy Debug Info' and paste it here. We'll need to know what versions of software you are using.

dustyroom-studio commented 3 years ago

The reason that the shadows do not work with Curved World might be that the edits need to be done to all the shader passes (including ShadowCaster, DepthOnly, etc), where currently you are applying them only to the forward rendering pass.

Hitomilras commented 3 years ago

The reason that the shadows do not work with Curved World might be that the edits need to be done to all the shader passes (including ShadowCaster, DepthOnly, etc), where currently you are applying them only to the forward rendering pass.

Sounds very logic. I'll try it now. Also i'll send you specifications soon. We can try to fix all issues on my machine if you want (I have flat kit and curved world in one project already installed). I can give you my skype / telegram and we will fix everything during the call so you can make an update for Flat Kit.

Hitomilras commented 3 years ago

@dustyroom-studio

Flat Kit version 2.6.0 Unity 2020.3.21f1 Dev platform: WindowsEditor Target platform: Android URP installed: True, version 10.7.0 Render pipeline: UniversalPipeline,LightweightPipeline Quality config: UniversalRenderPipelineAsset Graphics config: UniversalRenderPipelineAsset

Hitomilras commented 3 years ago

@dustyroom-studio yeah, you are right.

I added bending to the shadow caster pass and now it works :) Thank you :)

dustyroom-studio commented 3 years ago

@Hitomilras great! Glad you were able to get it working. Can you please share the final StylizedSurfase.shader here for us to merge it for the next update?

Hitomilras commented 3 years ago

@Hitomilras great! Glad you were able to get it working. Can you please share the final StylizedSurfase.shader here for us to merge it for the next update?

@dustyroom-studio yeah, shure. But there is also changes in LitForwardPass_DR. I can share it too if it's not a violation of anything :)

https://pastebin.com/YtC4pS6R // Stylized Surface

Also, please note that path to the CurvedWorld includes are hardcoded.

dustyroom-studio commented 3 years ago

Thanks! Can you please send the files to info@dustyroom.com? We'll reply with a voucher :)

lpzapata commented 3 years ago

Do you know when the update is going to come out with the fixes for Curve World?

dustyroom-studio commented 3 years ago

Hi, it should be available by the end of this week.

On Mon, Nov 8, 2021, 07:16 Luis @.***> wrote:

Do you know when the update is going to come out with the fixes for Curve World?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Dustyroom/flat-kit-doc/issues/58#issuecomment-963259689, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARZVF6R3BQ573LECLIQI7ETUK7ST3ANCNFSM5CFFIFMQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

Osashes commented 2 years ago

@Hitomilras great! Glad you were able to get it working. Can you please share the final StylizedSurfase.shader here for us to merge it for the next update?

@dustyroom-studio yeah, shure. But there is also changes in LitForwardPass_DR. I can share it too if it's not a violation of anything :)

https://pastebin.com/YtC4pS6R // Stylized Surface

Also, please note that path to the CurvedWorld includes are hardcoded.

Can you provide a new pastebin of this? I've tried getting FlatKit to work with CurvedWorld and can get it to play ball with the Stylized Surface texture, but can't get it working with the terrain shader. I'm hoping to see what you did with the Sylized Surface texture to see if I can apply something similar to get the terrain shader working.

The Activator built into Curved World doesn't seem to be working for the terrain shader to automate this process.

Any suggestions on how to get this playing ball with the terrain shader would also be much appreciated.

Thanks!

Osashes commented 2 years ago

I have fought with this all weekend with no success. Has anybody had any success in getting the FlatKit terrain shader to work with Curved World?

Thanks!

dustyroom-studio commented 2 years ago

Hi @Osashes ,

This might be because Curved World needs to inject its vertex transformation code, but Flat Kit uses URP library for the vertex functions.

To fix this, please replace the line #include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitPasses.hlsl" to #include "Amazing Assets/Curved World/Shaders/Custom/Terrain/TerrainLitPasses.hlsl" in the following files:

This should be done after updating Flat Kit to the newest version (2.8.1).

Osashes commented 2 years ago

Hi @Osashes ,

This might be because Curved World needs to inject its vertex transformation code, but Flat Kit uses URP library for the vertex functions.

To fix this, please replace the line #include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitPasses.hlsl" to #include "Amazing Assets/Curved World/Shaders/Custom/Terrain/TerrainLitPasses.hlsl" in the following files:

  • Assets/FlatKit/Shaders/StylizedSurface/Terrain.shader,
  • Assets/FlatKit/Shaders/StylizedSurface/TerrainLitAdd_DR.shader.

This should be done after updating Flat Kit to the newest version (2.8.1).

After updating Flat Kit to the newest version and attempting to re-activate using Curved World's activator, I'm immediately getting the following:

https://pastebin.com/BvbYKZME

And my shaders are no longer displaying/working at all, whereas before updating my shaders were working great with the terrain, just not bending.

Replacing the lines in Terrain and TerranLitAdd_DR shaders with #include "Amazing Assets/Curved World/Shaders/Custom/Terrain/TerrainLitPasses.hlsl" does not correct the issue.

dustyroom-studio commented 2 years ago

Thanks for pointing this out. We've uploaded an updated version of the asset, please re-download it from the Package Manager (same version) and try the updated version.

dustyroom-studio commented 2 years ago

I hope that fixed it. Please re-open this issue if there's a problem with Curved World integration.

MuratTenet commented 1 year ago

Hi,

I'm using the latest version of both pacakges and activated Flat Kit Stylized Shader. I checked every possible setting mentioned above and still no luck. There is no errors and I'm using Curved World's demo to make sure everything is set right. What can I do to make it work?

dustyroom-studio commented 1 year ago

Please check if everything in Assets/FlatKit/Shaders/StylizedSurface/StylizedSurface.shader related to CurvedWorld got uncommited in the activation.

MuratTenet commented 1 year ago

Please check if everything in Assets/FlatKit/Shaders/StylizedSurface/StylizedSurface.shader related to CurvedWorld got uncommited in the activation.

I have found that below check is returning false in LitForwardPass_DR.hlsl:

#if defined(CURVEDWORLD_IS_INSTALLED) && !defined(CURVEDWORLD_DISABLED_ON)
#ifdef CURVEDWORLD_NORMAL_TRANSFORMATION_ON
    CURVEDWORLD_TRANSFORM_VERTEX_AND_NORMAL(input.positionOS, input.normalOS, input.tangentOS)
#else
    CURVEDWORLD_TRANSFORM_VERTEX(input.positionOS)
#endif
#endif

So I added below on top, now it works.

define CURVEDWORLD_BEND_TYPE_CLASSICRUNNER_Z_POSITIVE

define CURVEDWORLD_BEND_ID_1

pragma shader_feature_local CURVEDWORLD_DISABLED_ON

pragma shader_feature_local CURVEDWORLD_NORMAL_TRANSFORMATION_ON

include "Assets/Amazing Assets/Curved World/Shaders/Core/CurvedWorldTransform.cginc"

I guess some lines above is not necesseary, but if it works, then I don't care about the rest :)

dustyroom-studio commented 1 year ago

@MuratTenet Thanks for the update!

Eniotnacram commented 1 year ago

Yes, the only possible way to make it work is the @MuratTenet way.

Thank you so much!

KZkici commented 1 year ago

Could there be an official support for Curved World?

Or a how to concise tutorial?

Or is it just this that needs to be done? https://github.com/Dustyroom/flat-kit-doc/issues/58#issuecomment-1328239481

dustyroom-studio commented 1 year ago

@KZkici unfortunately we can't do built-in support for Curved World because Flat Kit uses some standard Unity's shader passes and CW requires all shader passes to be edited. To finish the integration yourself, you need to do #58, replace the ShaderPass in StylizedSurface with the one in Unity's SimpleLit shader and add the same modifications as in #58 to that pass.

KZkici commented 1 year ago

@KZkici unfortunately we can't do built-in support for Curved World because Flat Kit uses some standard Unity's shader passes and CW requires all shader passes to be edited. To finish the integration yourself, you need to do #58, replace the ShaderPass in StylizedSurface with the one in Unity's SimpleLit shader and add the same modifications as in #58 to that pass.

Alright so i got it mostly working, however the outline seems to be left behind:

image

how can the outline be fixed to also be curved by CURVEDWORLD_BEND_TYPE_LITTLEPLANET_Y

dustyroom-studio commented 1 year ago

The outline is applied in the same shader file StylizedSurface.shader, it is the second pass. You need to add the same block (#if defined(CURVEDWORLD_IS_INSTALLED) ...) to the beginning of VertexProgram there. This is an oversight on our part, I'm going to add it by default in the next update.