You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While working on a sandcastle for #10180, I had tried making procedural normals for a torus. the lighting wasn't showing up and it took my a while to realize, the HAS_NORMALS define is only applied if the original model had normals. the lightingModel: LightingModel.PBR option does not add this define.
// This is a bug, I shouldn't have to add this define in custom shaders...
#define HAS_NORMALS
void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material) {
// See https://en.wikipedia.org/wiki/Toroidal_and_poloidal_coordinates
float toroidal = 2.0 * czm_pi * (float(fsInput.featureIds.featureId_0) / 29.0);
float poloidal = 2.0 * czm_pi * (float(fsInput.featureIds.featureId_1) / 19.0);
mat3 rotate = mat3(
cos(toroidal), sin(toroidal), 0.0,
-sin(toroidal), cos(toroidal), 0.0,
0.0, 0.0, 1.0
);
// normal when toroidal = 0;
vec3 normal0 = vec3(cos(poloidal), 0.0, sin(poloidal));
vec3 normalMC = rotate * normal0;
// unfortunately this requires using private API, czm_normal
material.normalEC = czm_normal * normalMC;
material.specular = vec3(0.98, 0.90, 0.59);
material.roughness = 0.3;
}
Not sure the cleanest place to handle this in the code. Maybe in CustomShaderPipelineStage? or should it be handled later in LightingPipelineStage regardless of what set the PBR mode? And should ShaderBuilder have a way to add a define if it doesn't already exist so we don't add repeated code?
Regardless, this is low priority since procedural normals computed in the shader is likely not a very common use case.
The text was updated successfully, but these errors were encountered:
While working on a sandcastle for #10180, I had tried making procedural normals for a torus. the lighting wasn't showing up and it took my a while to realize, the
HAS_NORMALS
define is only applied if the original model had normals. thelightingModel: LightingModel.PBR
option does not add this define.excerpt from this sandcastle (requires the
feature-id-labels
branch from #10180):Not sure the cleanest place to handle this in the code. Maybe in
CustomShaderPipelineStage
? or should it be handled later inLightingPipelineStage
regardless of what set the PBR mode? And should ShaderBuilder have a way to add a define if it doesn't already exist so we don't add repeated code?Regardless, this is low priority since procedural normals computed in the shader is likely not a very common use case.
The text was updated successfully, but these errors were encountered: