Shader3D Start
{
type:Shader3D,
name:MySkyBox,
enableInstancing:false,
shaderType:ShaderFeatureType.Sky,
supportReflectionProbe:false,
uniformMap:{
u_TintColor: { type: Color, default: [0.5, 0.5, 0.5, 0.5] },
u_Exposure: { type: Float, default: 1.0 },
u_Rotation: { type: Float, default: 0.0 },
u_CubeTexture: { type: TextureCube, options: { define: "CUBETEXTURE" } }
},
defines: {
},
attributes: {
a_Position: { type: Vector4, vertex: MESH_POSITION0 }
},
shaderPass:[
{
pipeline:Forward,
VS:MySkyBoxVS,
FS:MySkyBoxFS,
state:{
depthTest: LEQUAL,
depthWrite: false,
stencilWrite: false,
cull: Back,
statefirst: true
}
}
]
}
Shader3D End
GLSL Start
#defineGLSL MySkyBoxVS
#define SHADER_NAME MySkyBoxVS
#include "SkyCommon.glsl";
varying vec3 v_Texcoord;
void main()
{
// todo 这个转换 ?
v_Texcoord = vec3(-a_Position.x, a_Position.yz); //转换坐标系
vec4 position = rotateAroundYInDegrees(a_Position, u_Rotation);
// gl_Position = getPositionCS(position.xyz);
gl_Position = u_SkyProjectionViewMat * position;
gl_Position = remapSkyPositionZ(gl_Position);
}
#endGLSL
#defineGLSL MySkyBoxFS
#define SHADER_NAME MySkyBoxFS
#include "Color.glsl";
varying vec3 v_Texcoord;
const vec4 c_ColorSpace = vec4(4.59479380, 4.59479380, 4.59479380, 2.0);
void main()
{
vec3 uv = v_Texcoord;
vec4 cubeSampler = textureCube(u_CubeTexture, uv);
#ifdef Gamma_u_CubeTexture
cubeSampler = gammaToLinear(cubeSampler);
#endif // Gamma_u_CubeTexture
vec3 color = cubeSampler.rgb * u_TintColor.rgb * pow(u_Exposure, 2.2) * c_ColorSpace.rgb;
gl_FragColor = vec4(color, 1.0);
gl_FragColor = outputTransform(gl_FragColor);
}
#endGLSL
GLSL End
这个shader哪里有问题, 实际运行不报错,也没颜色有效果