-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for KHR_materials_unlit #6977
Changes from 4 commits
ccad16c
b136052
7a9faa7
c56a339
21caa93
7c28d2a
ba4d840
f3afd01
974af0d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,6 +143,7 @@ define([ | |
var hasNormals = false; | ||
var hasTangents = false; | ||
var hasTexCoords = false; | ||
var isUnlit = false; | ||
|
||
if (defined(primitiveInfo)) { | ||
skinningInfo = primitiveInfo.skinning; | ||
|
@@ -181,6 +182,12 @@ define([ | |
} | ||
}; | ||
|
||
if (defined(material.extensions) && defined(material.extensions.KHR_materials_unlit)) { | ||
isUnlit = true; | ||
hasNormals = false; | ||
hasTangents = false; | ||
} | ||
|
||
if (hasNormals) { | ||
techniqueUniforms.u_normalMatrix = { | ||
semantic : 'MODELVIEWINVERSETRANSPOSE', | ||
|
@@ -628,19 +635,22 @@ define([ | |
fragmentShader += ' vec3 color = baseColor;\n'; | ||
} | ||
|
||
if (defined(generatedMaterialValues.u_occlusionTexture)) { | ||
fragmentShader += ' color *= texture2D(u_occlusionTexture, ' + v_texcoord + ').r;\n'; | ||
} | ||
if (defined(generatedMaterialValues.u_emissiveTexture)) { | ||
fragmentShader += ' vec3 emissive = SRGBtoLINEAR3(texture2D(u_emissiveTexture, ' + v_texcoord + ').rgb);\n'; | ||
if (defined(generatedMaterialValues.u_emissiveFactor)) { | ||
fragmentShader += ' emissive *= u_emissiveFactor;\n'; | ||
// Ignore occlusion and emissive when unlit | ||
if (!isUnlit) { | ||
if (defined(generatedMaterialValues.u_occlusionTexture)) { | ||
fragmentShader += ' color *= texture2D(u_occlusionTexture, ' + v_texcoord + ').r;\n'; | ||
} | ||
fragmentShader += ' color += emissive;\n'; | ||
} | ||
else if (defined(generatedMaterialValues.u_emissiveFactor)) { | ||
fragmentShader += ' color += u_emissiveFactor;\n'; | ||
if (defined(generatedMaterialValues.u_emissiveTexture)) { | ||
fragmentShader += ' vec3 emissive = SRGBtoLINEAR3(texture2D(u_emissiveTexture, ' + v_texcoord + ').rgb);\n'; | ||
if (defined(generatedMaterialValues.u_emissiveFactor)) { | ||
fragmentShader += ' emissive *= u_emissiveFactor;\n'; | ||
} | ||
fragmentShader += ' color += emissive;\n'; | ||
} | ||
else if (defined(generatedMaterialValues.u_emissiveFactor)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
fragmentShader += ' color += u_emissiveFactor;\n'; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please run the auto-formatter on your blocks of changed code so that the source file stays consistently formatted. |
||
} | ||
|
||
// Final color | ||
fragmentShader += ' color = LINEARtoSRGB(color);\n'; | ||
|
@@ -660,6 +670,8 @@ define([ | |
} | ||
fragmentShader += '}\n'; | ||
|
||
console.log(fragmentShader); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Accidental debug code? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, sorry. Thanks for catching that! |
||
|
||
// Add shaders | ||
var vertexShaderId = addToArray(shaders, { | ||
type : WebGLConstants.VERTEX_SHADER, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this isn't targeting master, as the changelog is 2 versions out of date as of today's release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I'm merging into #6805 since that PR moves
gltfPipeline
fromThirdParty
into Cesium core.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@OmarShehata Create a section for October's release and move your changes there. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see the problem now. I moved it into a new section for October. Thanks for pointing this out!