mirror of
https://github.com/overte-org/overte.git
synced 2025-08-05 22:09:02 +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()) {
|
if (versionJson.isDouble()) {
|
||||||
version = (uint8_t)(floor(versionJson.toDouble()));
|
version = (uint8_t)(floor(versionJson.toDouble()));
|
||||||
// invalid version
|
// invalid version
|
||||||
if (!(version == 1 || version == 2 || version == 3)) {
|
if (!(version == 1 || version == 2 || version == 3 || version == 4)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -56,7 +56,20 @@ LAYOUT_STD140(binding=0) uniform standardInputsBuffer {
|
||||||
#define iChannelResolution standardInputs.channelResolution
|
#define iChannelResolution standardInputs.channelResolution
|
||||||
#define iWorldOrientation standardInputs.worldOrientation
|
#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 position;
|
||||||
vec3 normal;
|
vec3 normal;
|
||||||
vec3 diffuse;
|
vec3 diffuse;
|
||||||
|
|
|
@ -48,7 +48,11 @@ float getProceduralColors(inout vec3 diffuse, inout vec3 specular, inout float s
|
||||||
return 1.0;
|
return 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
float getProceduralFragment(inout ProceduralFragmentData proceduralData) {
|
float getProceduralFragment(inout ProceduralFragment proceduralData) {
|
||||||
|
return 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
float getProceduralFragmentWithPosition(inout ProceduralFragmentWithPosition proceduralData) {
|
||||||
return 1.0;
|
return 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,11 +81,15 @@ void main(void) {
|
||||||
roughness = max(0.0, 1.0 - shininess / 128.0);
|
roughness = max(0.0, 1.0 - shininess / 128.0);
|
||||||
metallic = length(specular);
|
metallic = length(specular);
|
||||||
emissive = vec3(clamp(emissiveAmount, 0.0, 1.0));
|
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();
|
TransformCamera cam = getTransformCamera();
|
||||||
vec4 position = cam._viewInverse * _positionES;
|
vec4 position = cam._viewInverse * _positionES;
|
||||||
ProceduralFragmentData proceduralData = {
|
ProceduralFragmentWithPosition proceduralData = {
|
||||||
position.xyz,
|
position.xyz,
|
||||||
|
#endif
|
||||||
normal,
|
normal,
|
||||||
vec3(0.0),
|
vec3(0.0),
|
||||||
DEFAULT_SPECULAR,
|
DEFAULT_SPECULAR,
|
||||||
|
@ -92,7 +100,12 @@ void main(void) {
|
||||||
DEFAULT_OCCLUSION,
|
DEFAULT_OCCLUSION,
|
||||||
DEFAULT_SCATTERING
|
DEFAULT_SCATTERING
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if defined(PROCEDURAL_V3)
|
||||||
emissiveAmount = getProceduralFragment(proceduralData);
|
emissiveAmount = getProceduralFragment(proceduralData);
|
||||||
|
#else
|
||||||
|
emissiveAmount = getProceduralFragmentWithPosition(proceduralData);
|
||||||
|
#endif
|
||||||
normal = proceduralData.normal;
|
normal = proceduralData.normal;
|
||||||
diffuse = proceduralData.diffuse;
|
diffuse = proceduralData.diffuse;
|
||||||
roughness = proceduralData.roughness;
|
roughness = proceduralData.roughness;
|
||||||
|
@ -101,9 +114,12 @@ void main(void) {
|
||||||
occlusion = proceduralData.occlusion;
|
occlusion = proceduralData.occlusion;
|
||||||
scattering = proceduralData.scattering;
|
scattering = proceduralData.scattering;
|
||||||
|
|
||||||
|
#if defined(PROCEDURAL_V4)
|
||||||
position = vec4(proceduralData.position, 1.0);
|
position = vec4(proceduralData.position, 1.0);
|
||||||
vec4 posClip = cam._projection * (cam._view * position);
|
vec4 posClip = cam._projection * (cam._view * position);
|
||||||
gl_FragDepth = 0.5 * (posClip.z / posClip.w + 1.0);
|
gl_FragDepth = 0.5 * (posClip.z / posClip.w + 1.0);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (emissiveAmount > 0.0) {
|
if (emissiveAmount > 0.0) {
|
||||||
|
|
|
@ -53,7 +53,11 @@ float getProceduralColors(inout vec3 diffuse, inout vec3 specular, inout float s
|
||||||
return 1.0;
|
return 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
float getProceduralFragment(inout ProceduralFragmentData proceduralData) {
|
float getProceduralFragment(inout ProceduralFragment proceduralData) {
|
||||||
|
return 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
float getProceduralFragmentWithPosition(inout ProceduralFragmentWithPosition proceduralData) {
|
||||||
return 1.0;
|
return 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,10 +90,14 @@ void main(void) {
|
||||||
roughness = max(0.0, 1.0 - shininess / 128.0);
|
roughness = max(0.0, 1.0 - shininess / 128.0);
|
||||||
metallic = length(specular);
|
metallic = length(specular);
|
||||||
emissive = vec3(clamp(emissiveAmount, 0.0, 1.0));
|
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;
|
vec4 position = cam._viewInverse * _positionES;
|
||||||
ProceduralFragmentData proceduralData = {
|
ProceduralFragmentWithPosition proceduralData = {
|
||||||
position.xyz,
|
position.xyz,
|
||||||
|
#endif
|
||||||
normal,
|
normal,
|
||||||
vec3(0.0),
|
vec3(0.0),
|
||||||
DEFAULT_SPECULAR,
|
DEFAULT_SPECULAR,
|
||||||
|
@ -100,21 +108,29 @@ void main(void) {
|
||||||
DEFAULT_OCCLUSION,
|
DEFAULT_OCCLUSION,
|
||||||
DEFAULT_SCATTERING
|
DEFAULT_SCATTERING
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if defined(PROCEDURAL_V3)
|
||||||
emissiveAmount = getProceduralFragment(proceduralData);
|
emissiveAmount = getProceduralFragment(proceduralData);
|
||||||
position = vec4(proceduralData.position, 1.0);
|
#else
|
||||||
vec4 posEye4 = cam._view * position;
|
emissiveAmount = getProceduralFragmentWithPosition(proceduralData);
|
||||||
posEye = vec3(posEye4);
|
#endif
|
||||||
occlusion = proceduralData.occlusion;
|
occlusion = proceduralData.occlusion;
|
||||||
normal = proceduralData.normal;
|
normal = proceduralData.normal;
|
||||||
diffuse = proceduralData.diffuse;
|
diffuse = proceduralData.diffuse;
|
||||||
alpha = proceduralData.alpha;
|
|
||||||
fresnel = proceduralData.specular;
|
fresnel = proceduralData.specular;
|
||||||
metallic = proceduralData.metallic;
|
metallic = proceduralData.metallic;
|
||||||
emissive = proceduralData.emissive;
|
emissive = proceduralData.emissive;
|
||||||
roughness = proceduralData.roughness;
|
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;
|
vec4 posClip = cam._projection * posEye4;
|
||||||
gl_FragDepth = 0.5 * (posClip.z / posClip.w + 1.0);
|
gl_FragDepth = 0.5 * (posClip.z / posClip.w + 1.0);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (emissiveAmount > 0.0) {
|
if (emissiveAmount > 0.0) {
|
||||||
|
|
Loading…
Reference in a new issue