diff --git a/packages/shaderlab/src/shaders/Normal.glsl b/packages/shaderlab/src/shaders/Normal.glsl index ac26729d..9a5b2430 100644 --- a/packages/shaderlab/src/shaders/Normal.glsl +++ b/packages/shaderlab/src/shaders/Normal.glsl @@ -6,10 +6,10 @@ // https://bugs.chromium.org/p/chromium/issues/detail?id=1154842 vec3 getNormal(Varyings varyings, bool isFrontFacing){ #ifdef RENDERER_HAS_NORMAL - vec3 normal = normalize(varyings.v_normal); + vec3 normal = normalize(varyings.normalWS); #elif defined(HAS_DERIVATIVES) - vec3 pos_dx = dFdx(varyings.v_pos); - vec3 pos_dy = dFdy(varyings.v_pos); + vec3 pos_dx = dFdx(varyings.positionWS); + vec3 pos_dy = dFdy(varyings.positionWS); vec3 normal = normalize( cross(pos_dx, pos_dy) ); #else vec3 normal = vec3(0, 0, 1); @@ -29,11 +29,11 @@ vec3 getNormalByNormalTexture(mat3 tbn, sampler2D normalTexture, float normalInt mat3 getTBN(Varyings varyings, bool isFrontFacing){ #if defined(RENDERER_HAS_NORMAL) && defined(RENDERER_HAS_TANGENT) - mat3 tbn = mat3(varyings.v_tangent, varyings.v_bitangent, varyings.v_normal); + mat3 tbn = mat3(varyings.tangentWS, varyings.bitangentWS, varyings.normalWS); #else vec3 normal = getNormal(varyings, isFrontFacing); - vec3 position = varyings.v_pos; - vec2 uv = isFrontFacing? varyings.v_uv: -varyings.v_uv; + vec3 position = varyings.positionWS; + vec2 uv = isFrontFacing? varyings.uv: -varyings.uv; #ifdef HAS_DERIVATIVES // ref: http://www.thetenthplanet.de/archives/1180 diff --git a/packages/shaderlab/src/shaders/shadingPBR/ForwardPassPBR.glsl b/packages/shaderlab/src/shaders/shadingPBR/ForwardPassPBR.glsl index b7212a99..90c0035d 100644 --- a/packages/shaderlab/src/shaders/shadingPBR/ForwardPassPBR.glsl +++ b/packages/shaderlab/src/shaders/shadingPBR/ForwardPassPBR.glsl @@ -17,38 +17,38 @@ Varyings PBRVertex(Attributes attributes) { Varyings varyings; - varyings.v_uv = getUV0(attributes); + varyings.uv = getUV0(attributes); #ifdef RENDERER_HAS_UV1 - varyings.v_uv1 = attributes.TEXCOORD_1; + varyings.uv1 = attributes.TEXCOORD_1; #endif #ifdef RENDERER_ENABLE_VERTEXCOLOR - varyings.v_color = attributes.COLOR_0; + varyings.vertexColor = attributes.COLOR_0; #endif VertexInputs vertexInputs = getVertexInputs(attributes); // positionWS - varyings.v_pos = vertexInputs.positionWS; + varyings.positionWS = vertexInputs.positionWS; // positionVS #if SCENE_FOG_MODE != 0 - varyings.v_positionVS = vertexInputs.positionVS; + varyings.positionVS = vertexInputs.positionVS; #endif // normalWS、tangentWS、bitangentWS #ifdef RENDERER_HAS_NORMAL - varyings.v_normal = vertexInputs.normalWS; + varyings.normalWS = vertexInputs.normalWS; #ifdef RENDERER_HAS_TANGENT - varyings.v_tangent = vertexInputs.tangentWS; - varyings.v_bitangent = vertexInputs.bitangentWS; + varyings.tangentWS = vertexInputs.tangentWS; + varyings.bitangentWS = vertexInputs.bitangentWS; #endif #endif // ShadowCoord #if defined(NEED_CALCULATE_SHADOWS) && (SCENE_SHADOW_CASCADED_COUNT == 1) - varyings.v_shadowCoord = getShadowCoord(vertexInputs.positionWS); + varyings.shadowCoord = getShadowCoord(vertexInputs.positionWS); #endif gl_Position = renderer_MVPMat * vertexInputs.positionOS; @@ -69,11 +69,11 @@ void PBRFragment(Varyings varyings) { float shadowAttenuation = 1.0; #if defined(SCENE_DIRECT_LIGHT_COUNT) && defined(NEED_CALCULATE_SHADOWS) #if SCENE_SHADOW_CASCADED_COUNT == 1 - vec3 shadowCoord = varyings.v_shadowCoord; + vec3 shadowCoord = varyings.shadowCoord; #else - vec3 shadowCoord = getShadowCoord(varyings.v_pos); + vec3 shadowCoord = getShadowCoord(varyings.positionWS); #endif - shadowAttenuation *= sampleShadowMap(varyings.v_pos, shadowCoord); + shadowAttenuation *= sampleShadowMap(varyings.positionWS, shadowCoord); #endif // Evaluate direct lighting @@ -87,7 +87,7 @@ void PBRFragment(Varyings varyings) { #if SCENE_FOG_MODE != 0 - color = fog(color, varyings.v_positionVS); + color = fog(color, varyings.positionVS); #endif #ifndef ENGINE_IS_COLORSPACE_GAMMA diff --git a/packages/shaderlab/src/shaders/shadingPBR/FragmentPBR.glsl b/packages/shaderlab/src/shaders/shadingPBR/FragmentPBR.glsl index 68e91c79..a4bb2a94 100644 --- a/packages/shaderlab/src/shaders/shadingPBR/FragmentPBR.glsl +++ b/packages/shaderlab/src/shaders/shadingPBR/FragmentPBR.glsl @@ -78,7 +78,7 @@ SurfaceData getSurfaceData(Varyings v, bool isFrontFacing){ vec3 emissiveRadiance = material_EmissiveColor; #ifdef MATERIAL_HAS_BASETEXTURE - vec4 baseTextureColor = texture2D(material_BaseTexture, v.v_uv); + vec4 baseTextureColor = texture2D(material_BaseTexture, v.uv); #ifndef ENGINE_IS_COLORSPACE_GAMMA baseTextureColor = gammaToLinear(baseTextureColor); #endif @@ -86,7 +86,7 @@ SurfaceData getSurfaceData(Varyings v, bool isFrontFacing){ #endif #ifdef RENDERER_ENABLE_VERTEXCOLOR - baseColor *= v.v_color; + baseColor *= v.vertexColor; #endif @@ -97,13 +97,13 @@ SurfaceData getSurfaceData(Varyings v, bool isFrontFacing){ #endif #ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE - vec4 metalRoughMapColor = texture2D( material_RoughnessMetallicTexture, v.v_uv ); + vec4 metalRoughMapColor = texture2D( material_RoughnessMetallicTexture, v.uv ); roughness *= metalRoughMapColor.g; metallic *= metalRoughMapColor.b; #endif #ifdef MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE - vec4 specularGlossinessColor = texture2D(material_SpecularGlossinessTexture, v.v_uv ); + vec4 specularGlossinessColor = texture2D(material_SpecularGlossinessTexture, v.uv ); #ifndef ENGINE_IS_COLORSPACE_GAMMA specularGlossinessColor = gammaToLinear(specularGlossinessColor); #endif @@ -113,7 +113,7 @@ SurfaceData getSurfaceData(Varyings v, bool isFrontFacing){ #endif #ifdef MATERIAL_HAS_EMISSIVETEXTURE - vec4 emissiveColor = texture2D(material_EmissiveTexture, v.v_uv); + vec4 emissiveColor = texture2D(material_EmissiveTexture, v.uv); #ifndef ENGINE_IS_COLORSPACE_GAMMA emissiveColor = gammaToLinear(emissiveColor); #endif @@ -135,12 +135,12 @@ SurfaceData getSurfaceData(Varyings v, bool isFrontFacing){ // geometry - surfaceData.position = v.v_pos; + surfaceData.position = v.positionWS; #ifdef CAMERA_ORTHOGRAPHIC surfaceData.viewDir = -camera_Forward; #else - surfaceData.viewDir = normalize(camera_Position - v.v_pos); + surfaceData.viewDir = normalize(camera_Position - v.positionWS); #endif #ifdef NEED_TANGENT @@ -148,7 +148,7 @@ SurfaceData getSurfaceData(Varyings v, bool isFrontFacing){ surfaceData.tangent = tbn[0]; surfaceData.bitangent = tbn[1]; #ifdef MATERIAL_HAS_NORMALTEXTURE - surfaceData.normal = getNormalByNormalTexture(tbn, material_NormalTexture, material_NormalIntensity, v.v_uv, isFrontFacing); + surfaceData.normal = getNormalByNormalTexture(tbn, material_NormalTexture, material_NormalIntensity, v.uv, isFrontFacing); #else surfaceData.normal = tbn[2]; #endif @@ -221,7 +221,7 @@ void initCommonBRDFData(SurfaceData surfaceData, inout BRDFData brdfData){ void initClearCoatBRDFData(Varyings v, inout BRDFData brdfData, bool isFrontFacing){ #ifdef MATERIAL_ENABLE_CLEAR_COAT #ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE - brdfData.clearCoatNormal = getNormalByNormalTexture(mat3(brdfData.tangent, brdfData.bitangent, brdfData.normal), material_ClearCoatNormalTexture, material_NormalIntensity, v.v_uv, isFrontFacing); + brdfData.clearCoatNormal = getNormalByNormalTexture(mat3(brdfData.tangent, brdfData.bitangent, brdfData.normal), material_ClearCoatNormalTexture, material_NormalIntensity, v.uv, isFrontFacing); #else brdfData.clearCoatNormal = getNormal(v, isFrontFacing); #endif @@ -231,11 +231,11 @@ void initClearCoatBRDFData(Varyings v, inout BRDFData brdfData, bool isFrontFaci brdfData.clearCoatRoughness = material_ClearCoatRoughness; #ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE - brdfData.clearCoat *= (texture2D( material_ClearCoatTexture, v.v_uv )).r; + brdfData.clearCoat *= (texture2D( material_ClearCoatTexture, v.uv )).r; #endif #ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE - brdfData.clearCoatRoughness *= (texture2D( material_ClearCoatRoughnessTexture, v.v_uv )).g; + brdfData.clearCoatRoughness *= (texture2D( material_ClearCoatRoughnessTexture, v.uv )).g; #endif brdfData.clearCoat = saturate( brdfData.clearCoat ); @@ -251,7 +251,7 @@ void initAnisotropyBRDFData(Varyings v, inout BRDFData brdfData){ float anisotropy = material_AnisotropyInfo.z; vec3 anisotropicDirection = vec3(material_AnisotropyInfo.xy, 0.0); #ifdef MATERIAL_HAS_ANISOTROPY_TEXTURE - vec3 anisotropyTextureInfo = (texture2D( material_AnisotropyTexture, v.v_uv )).rgb; + vec3 anisotropyTextureInfo = (texture2D( material_AnisotropyTexture, v.uv )).rgb; anisotropy *= anisotropyTextureInfo.b; anisotropicDirection.xy *= anisotropyTextureInfo.rg * 2.0 - 1.0; #endif @@ -270,10 +270,10 @@ void initAO(Varyings v, inout BRDFData brdfData){ float specularAO = 1.0; #ifdef MATERIAL_HAS_OCCLUSION_TEXTURE - vec2 aoUV = v.v_uv; + vec2 aoUV = v.uv; #ifdef RENDERER_HAS_UV1 if(material_OcclusionTextureCoord == 1.0){ - aoUV = v.v_uv1; + aoUV = v.uv1; } #endif diffuseAO = ((texture2D(material_OcclusionTexture, aoUV)).r - 1.0) * material_OcclusionIntensity + 1.0; diff --git a/packages/shaderlab/src/shaders/shadingPBR/VaryingsPBR.glsl b/packages/shaderlab/src/shaders/shadingPBR/VaryingsPBR.glsl index f7fda0e4..bf111d43 100644 --- a/packages/shaderlab/src/shaders/shadingPBR/VaryingsPBR.glsl +++ b/packages/shaderlab/src/shaders/shadingPBR/VaryingsPBR.glsl @@ -2,32 +2,32 @@ #define VARYINGS_PBR_INCLUDED struct Varyings{ - vec2 v_uv; + vec2 uv; #ifdef RENDERER_HAS_UV1 - vec2 v_uv1; + vec2 uv1; #endif #ifdef RENDERER_ENABLE_VERTEXCOLOR - vec4 v_color; + vec4 vertexColor; #endif - vec3 v_pos; + vec3 positionWS; #if SCENE_FOG_MODE != 0 - vec3 v_positionVS; + vec3 positionVS; #endif #ifdef RENDERER_HAS_NORMAL - vec3 v_normal; + vec3 normalWS; #ifdef RENDERER_HAS_TANGENT - vec3 v_tangent; - vec3 v_bitangent; + vec3 tangentWS; + vec3 bitangentWS; #endif #endif #if defined(NEED_CALCULATE_SHADOWS) && (SCENE_SHADOW_CASCADED_COUNT == 1) - vec3 v_shadowCoord; + vec3 shadowCoord; #endif };