0
\$\begingroup\$

I'm building a solar system and have made the simplifying assumption that the sun will always be at 0,0,0.

Rather than worry about "real" lighting, my planet shader just works out where it is relative to 0,0,0 and lights itself appropriately.

enter image description here

Planet-planet shadows/eclipses aren't a concern right now.

So far I've been getting away with using a single directional light which is always pointed at the player ship to handle lighting for the only properly-lit object in the scene.

enter image description here

Unfortunately, I now need to add other objects to the system, so the single directional light isn't going to cut it.

The player ship is from the Asset Store but uses the standard unity "Autodesk Interactive" shader.

I've found a copy of the shader on Github

https://github.com/TwoTailsGames/Unity-Built-in-Shaders/blob/master/DefaultResourcesExtra/AutodeskInteractive.shader

I've taken a copy and have swapped the "official" shader on the model for my own (and it works), but I'm stumped as to how to forcibly set the directional light orientation.

There doesn't seem to be much actual code, no vertex or fragment shaders, it's all just includes of the Unity Standard libraries and I don't know which parts I need to duplicate/override/configure/????

Pass
{
    Name "FORWARD"
    Tags { "LightMode" = "ForwardBase" }

    Blend [_SrcBlend] [_DstBlend]
    ZWrite [_ZWrite]

    CGPROGRAM
    #pragma target 3.5

    // -------------------------------------
    #pragma shader_feature_local _NORMALMAP
    #pragma shader_feature_local _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
    #pragma shader_feature _EMISSION
    #pragma shader_feature_local _METALLICGLOSSMAP
    #pragma shader_feature_local _SPECGLOSSMAP
    #pragma shader_feature_local _DETAIL_MULX2
    #pragma shader_feature_local _SPECULARHIGHLIGHTS_OFF
    #pragma shader_feature_local _GLOSSYREFLECTIONS_OFF
    #pragma shader_feature_local _PARALLAXMAP

    #pragma multi_compile_fwdbase
    #pragma multi_compile_fog
    #pragma multi_compile_instancing

    #pragma vertex vertBase
    #pragma fragment fragBase
    #include "UnityStandardCoreForward.cginc"

    ENDCG
}

Effectively: How can I configure the shader so that the lighting for each vertex is coincident with its position in world space?

\$\endgroup\$

0

You must log in to answer this question.

Browse other questions tagged .