Jump to content

2 posts in this topic Last Reply

Highlighted Posts

Posted:
Last Online:  
 

Hi, 
I'm working on improved rendering system for TM:PE. Currently I have 100% working version of rendering system (custom shaders and other stuff) in Unity Editor.


The heart of rendering system is custom Replacement Shader to create depth normal texture. I am using additional camera to render that texture using camera.renderWithShader(shader, "RenderType")
That texture is used in every Renderer shader to render literally anything (procedural shape, texture, bezier lines) on intersection between Renderer and object within(inside) that cube.

Renderer - empty GameObject with attached MeshRenderer and MeshFilter with sharedMesh - regular cube of size (1,1,1) with custom transparent shader which uses Replacement Shader texture for intersection calculations.
Example below - Unity Editor:

https://www.youtube.com/watch?v=U_osHmVfYpM

The problem I have is that when I moved everything to mod project, nothing is working as expected.
I mean nothing is rendered at all.
I've checked which RenderTypes are used by game for rendering terrain, road networks and other things. I've added necessary SubSteps to Replacement Shader to properly discover object of which shader has to be replaced during rendering with replacement shader and still nothing.
MeshRenderer enabled,  isVisible == true if camera looks at renderer location (tested in Update method of Renderer MonoBehaviour object)
I use Nvidia nsight as Frame Debugger to check if shader and mesh is rendered. Shader is used by Renderer but nothing is drawn there.
I tried setting RenderType to null/string.Empty but after that change, Renderer texture/shape is rendered on top of cube - Renderer cube meshes is not skipped while rendering depthNormals texture by replacement shader.

According to Unity manual with RenderType set to null or empty string, every object is rendered with replacement shader, but when I leave that tag as it should be ("RenderType") nothing is drawn even if I have proper SubShaders inside replacement shader.

Shader "Custom/Net/Road" => "QUEUE" = "AlphaTest" "RenderType" = "TransparentCutout"
Shader "Custom/Net/Group/Road" => "QUEUE" = "AlphaTest" "RenderType" = "TransparentCutout"
Shader "Custom/Terrain/Default" => "QUEUE" = "AlphaTest" "RenderType" = "Terrain"

I am using "QUEUE" = "AlphaTest+1" in Renderer custom shader so it should be rendered after IIRC.

Additional note:
When I use standard diffuse shader for Renderer mesh, game renders it properly.

I will try to replace Replacement Shader logic and experiment with Camera.depthTextureMode =  DepthTextureMode.DepthNormals and use _CameraDepthNormalsTexture.

 

  • Like 1

Share this post


Link to post
Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    I've fixed that, finally.
    I totally forgot about copying camera culling mask :D

    Share this post


    Link to post
    Share on other sites

    Sign In or register to comment...

    To comment in reply, you must be a community member

    Sign In  

    Already have an account? Sign in here.

    Sign In Now

    Create an Account  

    Sign up to join our friendly community. It's easy!  

    Register a New Account


    ×

    Thank You for the Continued Support!

    Simtropolis depends on donations to fund site maintenance costs.
    Without your support, we just would not be in our 24th year online!  You really help make this a great community. *:thumb:

    But we still need your support to stay online. If you're able to, please consider a donation to help us stay up and running. This helps sustain a platform where we can share our community creations for years to come.

    Make a Donation, Get a Gift!

    Expand your city with the best from the Simtropolis Exchange.
    Make a Donation and get one or all three discs today!

    STEX Collections

    By way of a "Thank You" gift, we'd like to send you our STEX Collector's DVD. It's some of the best buildings, lots, maps and mods collected for you over the years. Check out the STEX Collections for more info.

    Each donation helps keep Simtropolis online, open and free!

    Thank you for reading and enjoy the site!

    More About STEX Collections