mirror of
https://github.com/overte-org/overte.git
synced 2025-04-12 09:42:11 +02:00
separate out v3 and v4
This commit is contained in:
parent
9fc7813e24
commit
835615fbbd
4 changed files with 57 additions and 12 deletions
|
@ -75,7 +75,7 @@ void ProceduralData::parse(const QJsonObject& proceduralData) {
|
|||
if (versionJson.isDouble()) {
|
||||
version = (uint8_t)(floor(versionJson.toDouble()));
|
||||
// invalid version
|
||||
if (!(version == 1 || version == 2 || version == 3)) {
|
||||
if (!(version == 1 || version == 2 || version == 3 || version == 4)) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -56,7 +56,20 @@ LAYOUT_STD140(binding=0) uniform standardInputsBuffer {
|
|||
#define iChannelResolution standardInputs.channelResolution
|
||||
#define iWorldOrientation standardInputs.worldOrientation
|
||||
|
||||
struct ProceduralFragmentData {
|
||||
struct ProceduralFragment {
|
||||
vec3 normal;
|
||||
vec3 diffuse;
|
||||
vec3 specular;
|
||||
vec3 emissive;
|
||||
float alpha;
|
||||
float roughness;
|
||||
float metallic;
|
||||
float occlusion;
|
||||
float scattering;
|
||||
};
|
||||
|
||||
// Same as ProceduralFragment but with position
|
||||
struct ProceduralFragmentWithPosition {
|
||||
vec3 position;
|
||||
vec3 normal;
|
||||
vec3 diffuse;
|
||||
|
|
|
@ -48,7 +48,11 @@ float getProceduralColors(inout vec3 diffuse, inout vec3 specular, inout float s
|
|||
return 1.0;
|
||||
}
|
||||
|
||||
float getProceduralFragment(inout ProceduralFragmentData proceduralData) {
|
||||
float getProceduralFragment(inout ProceduralFragment proceduralData) {
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
float getProceduralFragmentWithPosition(inout ProceduralFragmentWithPosition proceduralData) {
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
|
@ -77,11 +81,15 @@ void main(void) {
|
|||
roughness = max(0.0, 1.0 - shininess / 128.0);
|
||||
metallic = length(specular);
|
||||
emissive = vec3(clamp(emissiveAmount, 0.0, 1.0));
|
||||
#elif defined(PROCEDURAL_V3)
|
||||
#elif defined(PROCEDURAL_V3) || defined(PROCEDURAL_V4)
|
||||
#if defined(PROCEDURAL_V3)
|
||||
ProceduralFragment proceduralData = {
|
||||
#else
|
||||
TransformCamera cam = getTransformCamera();
|
||||
vec4 position = cam._viewInverse * _positionES;
|
||||
ProceduralFragmentData proceduralData = {
|
||||
ProceduralFragmentWithPosition proceduralData = {
|
||||
position.xyz,
|
||||
#endif
|
||||
normal,
|
||||
vec3(0.0),
|
||||
DEFAULT_SPECULAR,
|
||||
|
@ -92,7 +100,12 @@ void main(void) {
|
|||
DEFAULT_OCCLUSION,
|
||||
DEFAULT_SCATTERING
|
||||
};
|
||||
|
||||
#if defined(PROCEDURAL_V3)
|
||||
emissiveAmount = getProceduralFragment(proceduralData);
|
||||
#else
|
||||
emissiveAmount = getProceduralFragmentWithPosition(proceduralData);
|
||||
#endif
|
||||
normal = proceduralData.normal;
|
||||
diffuse = proceduralData.diffuse;
|
||||
roughness = proceduralData.roughness;
|
||||
|
@ -101,9 +114,12 @@ void main(void) {
|
|||
occlusion = proceduralData.occlusion;
|
||||
scattering = proceduralData.scattering;
|
||||
|
||||
#if defined(PROCEDURAL_V4)
|
||||
position = vec4(proceduralData.position, 1.0);
|
||||
vec4 posClip = cam._projection * (cam._view * position);
|
||||
gl_FragDepth = 0.5 * (posClip.z / posClip.w + 1.0);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
if (emissiveAmount > 0.0) {
|
||||
|
|
|
@ -53,7 +53,11 @@ float getProceduralColors(inout vec3 diffuse, inout vec3 specular, inout float s
|
|||
return 1.0;
|
||||
}
|
||||
|
||||
float getProceduralFragment(inout ProceduralFragmentData proceduralData) {
|
||||
float getProceduralFragment(inout ProceduralFragment proceduralData) {
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
float getProceduralFragmentWithPosition(inout ProceduralFragmentWithPosition proceduralData) {
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
|
@ -86,10 +90,14 @@ void main(void) {
|
|||
roughness = max(0.0, 1.0 - shininess / 128.0);
|
||||
metallic = length(specular);
|
||||
emissive = vec3(clamp(emissiveAmount, 0.0, 1.0));
|
||||
#elif defined(PROCEDURAL_V3)
|
||||
#elif defined(PROCEDURAL_V3) || defined(PROCEDURAL_V4)
|
||||
#if defined(PROCEDURAL_V3)
|
||||
ProceduralFragment proceduralData = {
|
||||
#else
|
||||
vec4 position = cam._viewInverse * _positionES;
|
||||
ProceduralFragmentData proceduralData = {
|
||||
ProceduralFragmentWithPosition proceduralData = {
|
||||
position.xyz,
|
||||
#endif
|
||||
normal,
|
||||
vec3(0.0),
|
||||
DEFAULT_SPECULAR,
|
||||
|
@ -100,21 +108,29 @@ void main(void) {
|
|||
DEFAULT_OCCLUSION,
|
||||
DEFAULT_SCATTERING
|
||||
};
|
||||
|
||||
#if defined(PROCEDURAL_V3)
|
||||
emissiveAmount = getProceduralFragment(proceduralData);
|
||||
position = vec4(proceduralData.position, 1.0);
|
||||
vec4 posEye4 = cam._view * position;
|
||||
posEye = vec3(posEye4);
|
||||
#else
|
||||
emissiveAmount = getProceduralFragmentWithPosition(proceduralData);
|
||||
#endif
|
||||
occlusion = proceduralData.occlusion;
|
||||
normal = proceduralData.normal;
|
||||
diffuse = proceduralData.diffuse;
|
||||
alpha = proceduralData.alpha;
|
||||
fresnel = proceduralData.specular;
|
||||
metallic = proceduralData.metallic;
|
||||
emissive = proceduralData.emissive;
|
||||
roughness = proceduralData.roughness;
|
||||
alpha = proceduralData.alpha;
|
||||
|
||||
#if defined(PROCEDURAL_V4)
|
||||
position = vec4(proceduralData.position, 1.0);
|
||||
vec4 posEye4 = cam._view * position;
|
||||
posEye = posEye4.xyz;
|
||||
vec4 posClip = cam._projection * posEye4;
|
||||
gl_FragDepth = 0.5 * (posClip.z / posClip.w + 1.0);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
if (emissiveAmount > 0.0) {
|
||||
|
|
Loading…
Reference in a new issue