Hi all, im trying to create something similar to detail maps
but basically a detail ambient texture that tiles separately from the ambient texture. with limited documentation on material plugins my thought was to just copy the detail map code and base my detail ambient texture plugin off of that.
however i don’t actually see where the detail map stuff is being calculated in the fragment shader in the above code?
for my use case the fragment shader would just multiply the ambient texture with the detail ambient texture eg:
You will need to replace vec3(0.5) by your own code, of course.
We don’t have a predefined replacement point (like CUSTOM_FRAGMENT_BEGIN, CUSTOM_FRAGMENT_DEFINITIONS, CUSTOM_FRAGMENT_UPDATE_ALPHA, etc) for the ambient value, so I had to find a place in the sources where the code could be injected. It turns out that the ambient value is calculated before the reflectivityOutParams reflectivityOut; declaration, hence the regexp I used.
@Evgeni_Popov
so I went ahead and implemented this and it works in the playground but the shader does not compile in my own app. I create and assigned the material in the same way I do in the PG example, the setup is identical. Also note that if I cut paste the simplified getCustomCode from the shader block above in the thread it works.
In the above shader code do you see anything bad or wrong im doing in terms of not following best practices…or initializing ubo’s.? ( we can assume all shaders are PBRMaterial NOT StandardMaterial as we never use StandardMaterial. )
here is what the error log is giving me:
Offending line [730] in fragment code: vec2 AOuv = vAlbedoUV * detailAOScale;
FYI this is how I initialize the material plugin in my own code . Note, the mesh is an imported GLTF mesh that is imported in a previous step. The mesh is completely valid and is importing properly.
// apply detail AO plugin
mesh.material = new PBRMaterial("pbr",scene);
mesh.material.detailaoplugin = new DetailAOMaterialPlugin(mesh.material);
mesh.material.detailaoplugin.texture = pbr.ambientTexture;
//mesh.material.detailaoplugin.texture = pbr.ambientTexture;
//mesh.material.detailaoplugin.detailAOScale = 10;
// mesh.material.detailaoplugin.detailAOIntensity = 0.0;
mesh.material.detailaoplugin.isEnabled = true;
We have to request access to get the files from the Google drive.
Anyway, I think your problem is that you use vAlbedoUV in your plugin but don’t have an albedo texture in your material: vAlbedoUV is only defined if material.albedoTexture is not empty.
yep that was it. the material in question did not have an Albedo Texture. I ended up using vAmbientUV as I was using the base ambient texture and fixed my issue.