mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-05 19:12:40 +08:00
8d2ef1fe51
* fix skybox * fix subMesh.iaInfo
63 lines
1.4 KiB
Plaintext
63 lines
1.4 KiB
Plaintext
CCEffect %{
|
|
techniques:
|
|
- passes:
|
|
- vert: sky-vs:vert
|
|
frag: sky-fs:frag
|
|
priority: max - 10
|
|
rasterizerState:
|
|
cullMode: none
|
|
depthStencilState:
|
|
depthTest: true
|
|
depthWrite: false
|
|
}%
|
|
|
|
CCProgram sky-vs %{
|
|
precision highp float;
|
|
#include <cc-global>
|
|
#include <decode>
|
|
|
|
out mediump vec4 viewDir;
|
|
|
|
vec4 vert () {
|
|
CCDecode(viewDir);
|
|
|
|
mat4 matViewRotOnly = mat4(mat3(cc_matView));
|
|
mat4 matProj = cc_matProj;
|
|
|
|
// orthographic projection adaptation
|
|
if (matProj[3].w > 0.0) {
|
|
// default ortho height 10 approximate to default FOV 45
|
|
// stretch x by 2 to remedy perspective effect
|
|
vec2 scale = vec2(48.0, 24.0);
|
|
matProj[0].xy *= scale;
|
|
matProj[1].xy *= scale;
|
|
matProj[2].zw = vec2(-1.0);
|
|
matProj[3].zw = vec2(0.0);
|
|
}
|
|
|
|
vec4 pos = matProj * matViewRotOnly * viewDir;
|
|
pos.z = 0.99999 * pos.w;
|
|
return pos;
|
|
}
|
|
}%
|
|
|
|
CCProgram sky-fs %{
|
|
precision mediump float;
|
|
#include <cc-global>
|
|
#include <cc-environment>
|
|
#include <unpack>
|
|
#include <gamma>
|
|
#include <output-standard>
|
|
|
|
in mediump vec4 viewDir;
|
|
|
|
vec4 frag () {
|
|
#if USE_RGBE_CUBEMAP
|
|
vec3 c = unpackRGBE(texture(cc_environment, viewDir.xyz));
|
|
#else
|
|
vec3 c = SRGBToLinear(texture(cc_environment, viewDir.xyz).rgb);
|
|
#endif
|
|
return CCFragOutput(vec4(c * cc_ambientSky.w, 1.0));
|
|
}
|
|
}%
|