blob: 88d7b0da45071585ed0d5cfa6cabe0c5f76d0d73 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
#pragma once
#include "External/shaderlab/Library/FastPropertyName.h"
#include "Runtime/Math/Vector2.h"
#include "Runtime/Math/Color.h"
#include "Runtime/Graphics/Texture.h"
namespace ShaderLab {
class PropertySheet;
struct ParserShader;
}
// Serialized material property data (colors, textures, ...).
// This is used only for saving & loading of materials; at runtime ShaderLab PropertySheets
// are used (they can have more data that's not serialized, like matrices etc.).
class UnityPropertySheet
{
public:
DECLARE_SERIALIZE (UnityPropertySheet)
struct UnityTexEnv {
UnityTexEnv();
DECLARE_SERIALIZE (UnityTexEnv)
Vector2f m_Scale;
Vector2f m_Offset;
PPtr<Texture> m_Texture;
};
typedef std::map<ShaderLab::FastPropertyName, UnityTexEnv> TexEnvMap;
typedef std::map<ShaderLab::FastPropertyName, float> FloatMap;
typedef std::map<ShaderLab::FastPropertyName, ColorRGBAf> ColorMap;
TexEnvMap m_TexEnvs;
FloatMap m_Floats;
ColorMap m_Colors;
// Set the properties of target.
// This attempts to fill the properties of target with any info this may have.
// It never adds a property to target.
void AssignDefinedPropertiesTo (ShaderLab::PropertySheet &target);
// Add any properties defined by source, without overwriting anything already here.
bool AddNewShaderlabProps (const ShaderLab::PropertySheet &source);
void AddNewSerializedProps (const UnityPropertySheet &source);
#if UNITY_EDITOR
// Remove any properties not used by source.
// This is called when building a player by Material::Transfer
void CullUnusedProperties (const ShaderLab::ParserShader* source);
#endif
};
template<class TransferFunc>
void UnityPropertySheet::Transfer (TransferFunc& transfer)
{
transfer.SetVersion (2);
TRANSFER (m_TexEnvs);
TRANSFER (m_Floats);
TRANSFER (m_Colors);
}
template<class TransferFunc>
void UnityPropertySheet::UnityTexEnv::Transfer (TransferFunc& transfer)
{
TRANSFER (m_Texture);
TRANSFER (m_Scale);
TRANSFER (m_Offset);
}
|