0
\$\begingroup\$

I have this shader written on shaderlab, which replaces Ambient and Diffuse values of the material, because I need to tweak vertices colors from the script.

Shader "VertexSimple"
{
    Properties 
    {
        _MainTex ("Base (RGB)", 2D) = "white" {}
    }

    SubShader 
    {
        Pass 
        {
            ColorMaterial AmbientAndDiffuse
            Lighting Off

            SetTexture [_MainTex]
            {
                Combine texture * primary
            }
        }
    }
    Fallback "VertexLit"
}

I need to write an equivalent of this shader on CG\HLSL to do some other routines in it. Ideally it should be vertex\pixel shaders, not surface one. How can I do this?

\$\endgroup\$
  • \$\begingroup\$ I just don't know how to begin because I don't know how to write the ColorMaterial:AmbientAndDiffuse equvalent on CG. \$\endgroup\$ – Netherwire Jan 28 '14 at 20:01
  • \$\begingroup\$ I can help you with HLSL. This is the simplest PixelShader function you can have: float4 PixelShaderFunction(float2 coords: TEXCOORD0) : COLOR0 { return float4(1, 0, 0, 1); } this would output a red colour to any vertices you pass to the pixel shader. However I suggest you google vertex/pixel shader tutorial and either HLSL/CG and you'll get plenty of results. \$\endgroup\$ – TheWanderer Jan 28 '14 at 20:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.