Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Catlike Coding's C# and Shader Text Tutorials

Discussion in 'Community Learning & Teaching' started by Jasper-Flick, Jul 31, 2011.

  1. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923
  2. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923
  3. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923
  4. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923
  5. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923
  6. eclipse130300

    eclipse130300

    Joined:
    Dec 6, 2019
    Posts:
    25
    Hello, Jasper! Thanks for tutorials from 2020! :D
    Even though it's pretty hard to grasp shaders for dummy like me, but I learned a lot, anyway!
    I'll support you as soon as I earn my first money as a game developer ;)
     
  7. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923
    @eclipse130300 Cheers! That you may become a successful game developer!
     
  8. SEdmonds

    SEdmonds

    Joined:
    Feb 1, 2019
    Posts:
    2
    I am working my way through the tutorials. In Section 5.1 "Coloring Hexes" the tutorial directs you to "Create a new default shader via Assets / Create / Shader / Default Surface Shader. The latest version of Unity doesn't seem to give you the Default Surface Shader option so I went with Standard Surface Shader. I made the two changes but now I get an "invalid subscript 'Color' d3d11 45" error. Is there another way to create a Default Surface Shader I have missed?
     
  9. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923
    @SEdmonds You can copy the entire shader code as well. That error suggests that you've written "Color" instead of "color" so capitalized when it shouldn't be. I guess your line 45 contains "o.Albedo = c.rgb * IN.Color;" instead of "o.Albedo = c.rgb * IN.color;".
     
  10. SEdmonds

    SEdmonds

    Joined:
    Feb 1, 2019
    Posts:
    2
    Thankyou for your quick reply. It was the wrong case in color. I then created a new material using Assets/Create/Material. The tutorial didn't say to give it a color so I left that part blank. I selected the shader option custom/vertex colors. I went into hex mesh and changed the Element 0 to custom_vertexcolors. But when I hit play and click on a hex no pink hexes appear. It does pick up the coordinates without any problem.
     
  11. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923
    @SEdmonds Hard to say which step is missing. The touched cell's color must be set to the touch color, which has to be configured but is magenta by default. Then the mesh has to be triangulated anew. If you can't find it then you could grab the unitypackage of that section, import it in a new project, and compare.
     
  12. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923
  13. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923
    jamespaterson likes this.
  14. JohnyJones

    JohnyJones

    Joined:
    Nov 23, 2019
    Posts:
    3
    Hello Jasper! Thank you so much for all of your tutorials. They have helped me so much!
    There is however one question I have for you - how did you learn all of this stuff? I am sorry if you get asked this all the time, but I am really interested in your learning process.
     
  15. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923
    @unity_-xOrMfFzzO7y3w The generic stuff I learned mostly on my own as a kid, then later a master degree in computer science, and reading lots of published papers. All the Unity stuff is self-study, working with it professionally, and diving into the docs, APIs, and code.
     
  16. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923
  17. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923
  18. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923
  19. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923
  20. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923
    Lurking-Ninja likes this.
  21. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923
  22. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923
    Swimming
    Moving through and Floating in Water

     
  23. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923
  24. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923
  25. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923
  26. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923
    HDR
    Scattering and Tone Mapping

     
  27. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923
    Peplm likes this.
  28. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923
  29. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923
  30. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923
  31. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923
  32. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923
    mgear likes this.
  33. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923
  34. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923
    Jobs
    Animating a Fractal

     
  35. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923
  36. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923
  37. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923
    FXAA
    Fast approXimate Anti-Aliasing

     
  38. SubOathshot

    SubOathshot

    Joined:
    Nov 23, 2015
    Posts:
    1
    Hey, man!

    Thanks for your work. It has been really helpful for my quarantine project!

    I've done your Rendering tutorials until Rendering 20. Everything worked like a charm, however when adapting it into my project I'm facing 2 errors (been able to figure out 1/2).
    I also tried to add your vanilla package to my project and get exactly the same errors...

    Errors:


    I've been able to solve the first error by incrementing the following TEXCOORDS variables (inside both the 'Interpolators' and 'InterpolatorsVertex' structs):
    Code (CSharp):
    1.  
    2.     #if defined(LIGHTMAP_ON) || ADDITIONAL_MASKED_DIRECTIONAL_SHADOWS
    3.         float2 lightmapUV : TEXCOORD6;
    4.     #endif
    5.  
    6.     #if defined(DYNAMICLIGHTMAP_ON)
    7.         float2 dynamicLightmapUV : TEXCOORD7;
    8.     #endif
    9.  
    10.     #if defined(_PARALLAX_MAP)
    11.         float3 tangentViewDir : TEXCOORD8;
    12.     #endif


    However, I'm unable to fix the second error. The error says:
    Code (CSharp):
    1. Shader error in 'Custom/Paper Squiggly': invalid subscript 'pos' at Assets/AP/Assets/Animations/Shaders/PaperSquiggly/PaperSquigglyLight.cginc(366) (on d3d11)
    2.  
    3. Compiling Vertex program with DIRECTIONAL SHADOWS_SCREEN SHADOWS_SHADOWMASK LIGHTPROBE_SH LOD_FADE_CROSSFADE _SQUIGGLE_ON
    4. Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_LIGHTMAP_RGBM_ENCODING UNITY_PASS_FORWARDBASE
    5. Disabled keywords: _RENDERING_CUTOUT _RENDERING_FADE _RENDERING_TRANSPARENT _METALLIC_MAP _SMOOTHNESS_ALBEDO _SMOOTHNESS_METALLIC _NORMAL_MAP _PARALLAX_MAP _OCCLUSION_MAP _EMISSION_MAP _DETAIL_MASK _DETAIL_ALBEDO_MAP _DETAIL_NORMAL_MAP FOG_LINEAR FOG_EXP FOG_EXP2 INSTANCING_ON DYNAMICLIGHTMAP_ON LIGHTMAP_ON LIGHTMAP_SHADOW_MIXING DIRLIGHTMAP_COMBINED VERTEXLIGHT_ON UNITY_NO_DXT5nm UNITY_ENABLE_NATIVE_SHADOW_LOOKUPS UNITY_METAL_SHADOWS_USE_POINT_FILTERING UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF2 UNITY_PBS_USE_BRDF3 UNITY_NO_FULL_STANDARD_SHADER UNITY_HARDWARE_TIER1 UNITY_HARDWARE_TIER2 UNITY_HARDWARE_TIER3 UNITY_COLORSPACE_GAMMA UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS UNITY_LIGHTMAP_DLDR_ENCODING UNITY_LIGHTMAP_FULL_HDR UNITY_VIRTUAL_TEXTURING

    The line in question is the UNITY_LIGHT_ATTENUATION inside the function CreateLight():
    Code (CSharp):
    1. UnityLight CreateLight (Interpolators i) {
    2.     UnityLight light;
    3.         ...
    4.    
    5.         UNITY_LIGHT_ATTENUATION(attenuation, i, i.worldPos.xyz);  
    6.         ...
    7.     #endif
    8.     return light;
    9. }
    The struct contains the needed variable:


    Any idea or tip?

    Note: I'm using Unity 2020.1.4f1

    Thanks!
     
    Last edited: Mar 8, 2021
  39. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923
    @SubOathshot I cannot really help you with your specific project, but the error indicates that it's compiling a vertex program with LOD_FADE_CROSSFADE defined, in which case pos is indeed missing from Interpolators, because of VPOS shenanigans in the old default pipeline approach. Note that in the tutorial Interpolators is strictly for use in fragment programs, while InterpolatorsVertex is strictly for use in vertex programs. The latter always contains pos.
     
  40. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923
  41. eatitall2002

    eatitall2002

    Joined:
    Apr 25, 2021
    Posts:
    7
    @Jasper-Flick I had been following your Hexagonal map tutorial. Awesome series. Thanks for making it :).

    But I want to place hexagonal blocks on the generated map (like those city building games)
    Example:

    Can you give some resources or a starting point on how I should do it?
    I have currently done till here : https://catlikecoding.com/unity/tutorials/hex-map/part-1/
    Since I will have a plane land without any terrain
    Thanks for the help! :)
     
  42. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923
    @eatitall2002 The game that you're showing is essentially a puzzle game that's about matching tiles on a board. Its fundament is a set of tiles with edge-connection rules. That's something very different that what Hex Map is aimed at, being about free-form big maps, though you could use it as a jumping-off point for whatever you like.
     
  43. eatitall2002

    eatitall2002

    Joined:
    Apr 25, 2021
    Posts:
    7
    @Jasper-Flick Thanks I managed to get it done. Your hex Map series actually served as a great starting point for me.
     
    hopeful likes this.
  44. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923
    Last edited: May 31, 2021
  45. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923
    Last edited: May 31, 2021
    calabi likes this.
  46. dimmduh1

    dimmduh1

    Joined:
    Feb 5, 2021
    Posts:
    24
  47. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923
  48. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923
    dimmduh1 and DEEnvironment like this.
  49. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923
  50. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    923