Hello Guest

Author Topic: Which shaders are NOT vertex lit / fixed function?  (Read 7104 times)

mrkake

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 17
    • View Profile
Which shaders are NOT vertex lit / fixed function?
« on: February 25, 2015, 04:45:06 am »
Sorry if this is an amateur question, but I really don't understand the names and differences between the shaders terminology at all.

I am trying to run a game I created with 2d toolkit on the wii u, and its crashing, when i checked the error log and for help on the official forums, the reason is because vertex lit and fixed function shaders are not supported currently with unity games.

I can see the 2d toolkit had a lot of different shaders in the tk2d menu, and that unity itself also comes with a lot of shaders. But, I don't particularly want to brute force try them all (though i can if it comes to this) since I will have to change the shader on every texture/sprite.

I am wondering, which textures are NOT vertex lit and NOT fixed function? Also GLSL shaders are not supported, whatever that means. So I need a shader which is not one of these three. Is one already in unity or tk2d? Or any ideas how I could obtain one? And is there any way I could have known this without asking? And if its not too in depth to give a high level overview, what does "fixed function" even mean in terms of a shader? (vertex lit i kind of understand)

thanks so much


edit:  also i'm using tilemap, and regular 2d toolkit sprite renderers on prefabs combined.  i'm wondering if the tilemap is respecting the shader on the material attached to its sprite collection?  no matter what i pick i am getting errors running on the console about unsupported vertex shaders. i have picked "diffuse" "transparent\diffuse",  neither of these work but i feel they should.  tk2d\blend2vertexshader definitely does not work. sprites\diffuse also definetely does not work. any ideas greatly appreciated
« Last Edit: February 25, 2015, 06:01:52 am by mrkake »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Which shaders are NOT vertex lit / fixed function?
« Reply #1 on: February 25, 2015, 09:53:20 am »
Almost all of them don't have vertex lighting and while they have a fixed function subshader, the main one isn't fixed function. Eg. BlendVerexColor should work. Or at least it did work.

Fixed function is the second subshader in BlendVertexColor, used as a fallback in old devices.
The tilemap uses the shader on the sprite collection.

I am pretty sure this used to work. Can you tell me the error message you're seeing when running on the device?

mrkake

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Which shaders are NOT vertex lit / fixed function?
« Reply #2 on: February 25, 2015, 01:21:33 pm »
When using Blend2TexVertexColor I got the following error:  Unsupported: 'tk2d/Blend2TexVertexColor' - Pass '' has no shader programs (Fixed-Function not supported)

Actually it's possible that BlendVertexColor is supported.

I get a lot of warning messages no matter what shader I use, but I realized that even if I pick a supported shader it shows a warning like "Unsupported: 'Diffuse' - All passes removed".

But when I look quite close at the full output I see it is making it farther so perhaps there is a bug in my code as well but I'm not sure. Trying to get my game running at all on the system at this point, it works fine on PC.

I will post an update if I can resolve this , I'm thinking now its not the fault of 2d toolkit

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Which shaders are NOT vertex lit / fixed function?
« Reply #3 on: February 25, 2015, 01:42:05 pm »
I have an idea what it could be. Try one quad with the blendvertexcolor shader - paste what it spits out here and we'll take it from there.

SullyTheStrange

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 55
    • View Profile
Re: Which shaders are NOT vertex lit / fixed function?
« Reply #4 on: July 21, 2015, 08:32:05 am »
Just got my own Wii U dev kit up and running today, I've been afraid to see what shaders won't be supported. Looks like BlendAdditiveVertexColor is off limits...

And I haven't gotten my build working well enough to test it myself yet, but the output mentions the Depth Mask shader being unsupported too. Do you know if that's true, unikron? If so I'm in some big trouble, I use that in so many places... :(

I'd wait until I get the build working myself, but I was hoping to have the Wii U version functional for a show in a few weeks, and if this is true then I might as well not bother for now since I'd have to redo/remove everything using the depth mask. If it's true, is there any way to replicate that effect without a fixed function shader? I'm helpless at writing my own...

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Which shaders are NOT vertex lit / fixed function?
« Reply #5 on: July 21, 2015, 12:33:51 pm »
The only 2 fixed function shaders are DepthMask and DepthMaskSolid. These shaders don't need anything in them and just need to be dummy shaders so if you throw this block into this section in the shaders. Thing is it should work regardless as unity will fall back to the pink shader, and that will be enough to make the depth mask work.

Code: [Select]
Pass
{
[here]
}

that will sort it out

Code: [Select]
CGPROGRAM
#pragma vertex vert_vct
#pragma fragment frag_mult
#pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"

sampler2D _MainTex;
float4 _MainTex_ST;

struct vin_vct
{
float4 vertex : POSITION;
float4 color : COLOR;
float2 texcoord : TEXCOORD0;
};

struct v2f_vct
{
float4 vertex : SV_POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
};

v2f_vct vert_vct(vin_vct v)
{
v2f_vct o;
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
o.color = v.color;
o.texcoord = v.texcoord;
return o;
}

fixed4 frag_mult(v2f_vct i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.texcoord) * i.color;
return col;
}

ENDCG

Not sure about BlendAdditiveVertexColor, its not part of the tk2d distribution is it? All the built in shaders apart from depth mask have been converted in my build directory.

SullyTheStrange

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 55
    • View Profile
Re: Which shaders are NOT vertex lit / fixed function?
« Reply #6 on: July 22, 2015, 08:39:33 pm »
The Wii U gods have accepted your offering, the depth mask works perfectly now. Thanks! :D

I'm pretty sure BlendAdditiveVertexColor was just a random thing you posted here: http://2dtoolkit.com/forum/index.php/topic,391.msg1708.html#msg1708

Is there a simple way to salvage that one too? It's not as critical as the depth mask, but it does allow for some cool effects.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Which shaders are NOT vertex lit / fixed function?
« Reply #7 on: July 22, 2015, 08:45:56 pm »
Turns out I'd fixed that one ages ago -
Code: [Select]
// unlit, vertex colour, alpha blended
// cull off

Shader "tk2d/BlendAdditiveVertexColor"
{
Properties
{
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
}

SubShader
{
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
ZWrite Off Lighting Off Cull Off Fog { Mode Off } Blend SrcAlpha OneMinusSrcAlpha
LOD 110

Pass
{
CGPROGRAM
#pragma vertex vert_vct
#pragma fragment frag_mult
#pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"

sampler2D _MainTex;
float4 _MainTex_ST;

struct vin_vct
{
float4 vertex : POSITION;
float4 color : COLOR;
float2 texcoord : TEXCOORD0;
};

struct v2f_vct
{
float4 vertex : SV_POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
};

v2f_vct vert_vct(vin_vct v)
{
v2f_vct o;
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
o.color = v.color;
o.texcoord = v.texcoord;
return o;
}

fixed4 frag_mult(v2f_vct i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.texcoord);
col.rgb += i.color.rgb;
col.a *= i.color.a;
return col;
}

ENDCG
}
}
}

SullyTheStrange

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 55
    • View Profile
Re: Which shaders are NOT vertex lit / fixed function?
« Reply #8 on: July 22, 2015, 09:14:15 pm »
Also perfect! :D Thank you very much! Everything else with tk2d has been working as it should on Wii U so far.