CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
hrydgard

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: hrydgard/ppsspp
Path: blob/master/GPU/Software/Lighting.h
Views: 1401
1
// Copyright (c) 2013- PPSSPP Project.
2
3
// This program is free software: you can redistribute it and/or modify
4
// it under the terms of the GNU General Public License as published by
5
// the Free Software Foundation, version 2.0 or later versions.
6
7
// This program is distributed in the hope that it will be useful,
8
// but WITHOUT ANY WARRANTY; without even the implied warranty of
9
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
// GNU General Public License 2.0 for more details.
11
12
// A copy of the GPL 2.0 should have been included with the program.
13
// If not, see http://www.gnu.org/licenses/
14
15
// Official git repository and contact information can be found at
16
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
17
18
#pragma once
19
20
#include "TransformUnit.h"
21
22
namespace Lighting {
23
24
struct State {
25
struct {
26
// Pre-normalized if directional.
27
Vec3f pos;
28
Vec3f att;
29
Vec3f spotDir;
30
float spotCutoff;
31
float spotExp;
32
33
Vec4<int> ambientColorFactor;
34
Vec4<int> diffuseColorFactor;
35
Vec4<int> specularColorFactor;
36
37
struct {
38
bool enabled : 1;
39
bool spot : 1;
40
bool directional : 1;
41
bool poweredDiffuse : 1;
42
bool ambient : 1;
43
bool diffuse : 1;
44
bool specular : 1;
45
};
46
} lights[4];
47
48
struct {
49
Vec4<int> ambientColorFactor;
50
Vec4<int> diffuseColorFactor;
51
Vec4<int> specularColorFactor;
52
} material;
53
54
Vec4<int> baseAmbientColorFactor;
55
float specularExp;
56
57
struct {
58
bool colorForAmbient : 1;
59
bool colorForDiffuse : 1;
60
bool colorForSpecular : 1;
61
bool setColor1 : 1;
62
bool addColor1 : 1;
63
bool usesWorldPos : 1;
64
bool usesWorldNormal : 1;
65
};
66
};
67
68
void ComputeState(State *state, bool hasColor0);
69
70
void GenerateLightST(VertexData &vertex, const WorldCoords &worldnormal);
71
void Process(VertexData &vertex, const WorldCoords &worldpos, const WorldCoords &worldnormal, const State &state);
72
73
}
74
75