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. Dismiss Notice

Question How to edit a shader's .cginc and .shader files?

Discussion in 'General Graphics' started by PolygonPros, Nov 20, 2020.

  1. PolygonPros

    PolygonPros

    Joined:
    Apr 11, 2020
    Posts:
    34
    Hi, I'm trying to edit this camera shader asset that I purchased from the asset store:
    https://assetstore.unity.com/packages/vfx/shaders/fullscreen-camera-effects/oil-painting-136385

    The shader draws these paint strokes all over what the camera sees, based on the pixel info underneath. I would like to change the shapes/textures of these brush strokes, for a different painting style.
    I looked through the asset's files, but I couldn’t find any image files to edit. I assumed there would be some kind of texture sheet of brush strokes or vector files that the shader was pulling from. The only files I can find in the asset are in .cginc and .shader formats.

    9144e1db-342f-4f90-bc9f-b93a0765ac53_scaled.jpg

    Is it possible that textures/sprite sheets are somehow compressed into these .cginc or .shader files? (I'm a relative Unity beginner and not familiar with how these files, and shaders in general, work.) What do I need to do/use to edit these brush shapes that the shader draws?

    I appreciate any help in pointing me in the right direction. Thank you!
     
  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,845
    No.
    This all means that the shapes are generated procedurally - that is, using math.
     
  3. PolygonPros

    PolygonPros

    Joined:
    Apr 11, 2020
    Posts:
    34
    Okay, thank you. How would I edit this procedural generation?
     
  4. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,845
    There is no simple answer to that question :)
    You would need to understand how this specific shader works and then change the math to generate the shape you need.
     
  5. PolygonPros

    PolygonPros

    Joined:
    Apr 11, 2020
    Posts:
    34
    I guess I should be more specific with my question: how are shaders edited? How do I open .cginc and .shader files? Is there a built in function to open and edit these in Unity? Or do I need some sort of additional asset or software tool to open up these files to make changes? Which program?
     
    Last edited: Nov 20, 2020
  6. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,236
    They're text files, with code written in HLSL and Unity's C#-like ShaderLab markup language. They can be opened up in any text editor or IDE like Notepad, Notepad++, Sublime Text, Atom, Visual Studio, Visual Studio Code, Rider, etc. (though don't expect any IDE to actually support proper code completion and the like, though Rider has supposedly made some strides there).
     
    PolygonPros likes this.
  7. PolygonPros

    PolygonPros

    Joined:
    Apr 11, 2020
    Posts:
    34
    Thank you for this very helpful answer!
    From searching around I've seen mentions of packages like Shader Graph and Amplify Shader Editor, to make shaders in a more visual manner. Are such programs able to open pre-made shader files like these and edit them? Or do they use different working formats, and the .cginc and .shader files are just the final outputs?
     
  8. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,236
    Shader Graph and Amplify Shader Editor both use their own formats and output the equivalent of a .shader file for use with Unity. Amplify Shader Editor actually stores the node layout in a .shader file that includes the HLSL output, but as extra data that the regular shader parser ignores so the output can be used in projects that don’t have ASE can still use the shader file.
     
    PolygonPros likes this.
  9. PolygonPros

    PolygonPros

    Joined:
    Apr 11, 2020
    Posts:
    34
    Okay, thank you very much.
     
  10. Krishx007

    Krishx007

    Joined:
    Jul 15, 2014
    Posts:
    14