0
Fixed

Can't use Specular Map(Texture2D) with Deffered and Lightmapping

Tharyn Valavanis 9 years ago updated 9 years ago 6

This bug has been in the program for as long as I can remember and I've been fixing your shaders by hand. Please help. I would do this any other way if i could but this has been broken since the early beta. I can't find a version of shader for where the following isn't broken. We can't go to U5 as we are mid game production.

Unity 4.x / Shader Forge 1.06

Source of the problem.
in "PrePassBase" - "//////// Lighting:"
'float4 _SpecMap_var' is not defined outside of #ifndef LIGHTMAP_OFF block.

the error fails on variations of the dual lightmapping.

This fix is super easy. We just need _SpecMap_var defined before the #ifndef LIGHTMAP_OFF.

float4 _SpecMap_var = tex2D(_SpecMap,TRANSFORM_TEX(i.uv0, _SpecMap));
#ifndef LIGHTMAP_OFF
half3 lightmapAccumulation = half3(0,0,0);
#ifdef DIRLIGHTMAP_OFF
...
...
...
...
...


Thanks so much!
Tharyn


Answer

Answer
Fixed
Unfortunately I'm not supporting the 4.x versions anymore, although this has been fixed in the Unity 5 version of Shader Forge.
I recommend creating a backup of your game, then open it using Unity 5 and see if anything breaks. The upgrade is often much easier than you think, plus, in Unity 5 you have all the pro features of Unity 4 for free
Answer
Fixed
Unfortunately I'm not supporting the 4.x versions anymore, although this has been fixed in the Unity 5 version of Shader Forge.
I recommend creating a backup of your game, then open it using Unity 5 and see if anything breaks. The upgrade is often much easier than you think, plus, in Unity 5 you have all the pro features of Unity 4 for free
Not fixed!! :)

We can't go to Unity 5, our in house lighting setup only works with Beast as U5 GI does not have shadows for spots or Omnis. We are stuck with U4 for this production.

As I said I will make the change to the source myself if you give me the 1.06 code. This is a huge time sink for us. Its just one line of code that needs to be moved and I've very familar with how you have structured your output so I can fix this in about 10-15 minutes and save the team having to hand edit shader everytime we make a small change.

PLEASE

...




Well, like I said, I'm not supporting Unity 4 anymore, and even if I did, I don't have the time to make that change now.
It is fixed already, for Unity 5. It's not my fault that you're still on 4
First, the rest of this is not going to attempt to get you to fix it. Please just read this in the hopes you'll understand that I presented two options. Also I'm just outlining a position ... not arguing. I've developed and released software many times and I suspect you have come to realize the writing cool stuff and getting paid is great and supporting your code pretty much always sucks.

Second, I simply asked if you wouldn't fix it OR just provide me with the depreciated code so I can compile the fix myself. I really not trying to make things difficult for you, they already are for me.

Lastly, I've been super patient for the last 6 months with my requests to fix this very small bug with very big impact. They were ignored.

I know your on to new stuff and that's great. We had no warning that you would all of the sudden stop support.

BTW I've been in the business for nearly 20 years now. I'm sure your sick of fixes to old code, but those of us at companies with experience NEVER jump to a new version of software because we have so much money on the line with production. The new lighting system in Unity is cool, but so far from ready many companies like us won't migrate over for a year or two.

Last thing. Its companies like us that buy multiple licenses over the long term. A one man band that is using your stuff because he's playing with developing for an iPhone and your plugin is cool won't pay your bills a year or two from now. We will.

Cheers man no hard feeling. Just expensive ones.

Tharyn




I apologize if I came across a little bit terse, it certainly wasn't my intention.

The issue of not having time to fix it aside - changes to the compiler in SF has a tendency to create knock-on effects, causing bugs and issues in unexpected places, which is why I'm very wary of making changes in the 4.x version. I've also pretty much removed the entire build -> prepare -> package -> export -> upload pipeline for it, so other external things might break, where assets go missing, or were compiled in the wrong version, and so on.

It's a risky move on my end, which has a potential to break SF for all customers still on Unity 4, leaving me with more bugs to fix, in a time where I can't spend much of it for fixing bugs.

If you want to get this fixed as soon as possible, the most straightforward solution I see is this:

Give one of your coders an hour to code an editor script, that allows you to select a shader, and press a button to make it move that line to the correct place.
It's very straightforward, since the shaders are essentially text files.

For the coder:
1. Add a button to Unity's menu bar (MenuItem)
2. Detect which shader is selected in the project view (Selection Detection)
3. Read the file into a string array (File Handling)
4. Find the line you wanted to move, and move it
5. Write the string array into the file

For the user:
1. Compile the shader in SF
2. Select the shader you just modified
3. Press the button or hotkey that the coder added to Unity

I'm guessing it's not the answer you wanted, but I hope it helps anyhow

Joachim
Totally understand. Right on, we'll do exactly that ... its a good workaround!

Thanks,
Tharyn