Dava
March 17, 2022, 11:55pm
#1
I created a simple albedo chunk, and assign white color.
Created material and script to connect and apply to image inside 2D screen object.
The problem is, the color is so dark, not like the one I assign getAlbedo with.
Since it’s an Image, I can’t really add light or something, am I right?
Hi @Dava ,
I think text elements use a special shader chunks for rendering, it may require overriding that as well, to do what you are looking for.
@mvaligursky may know more.
I’m not sure without investigation. I’d suggest to capture original and new material using Spector JS, and compare the shaders to see what the difference is - that’s what I would do.
1 Like
Dava
March 18, 2022, 6:03pm
#4
This is what i get when i capture the frame with my image
#version 300 es
#define varying in
out highp vec4 pc_fragColor;
#define gl_FragColor pc_fragColor
#define texture2D texture
#define textureCube texture
#define texture2DProj textureProj
#define texture2DLodEXT textureLod
#define texture2DProjLodEXT textureProjLod
#define textureCubeLodEXT textureLod
#define texture2DGradEXT textureGrad
#define texture2DProjGradEXT textureProjGrad
#define textureCubeGradEXT textureGrad
#define GL2
#define SUPPORTS_TEXLOD
precision highp float;
#ifdef GL2
precision highp sampler2DShadow;
#endif
varying vec3 vPositionW;
varying vec2 vUv0;
uniform vec3 view_position;
uniform vec3 light_globalAmbient;
float square(float x) {
return x*x;
}
float saturate(float x) {
return clamp(x, 0.0, 1.0);
}
vec3 saturate(vec3 x) {
return clamp(x, vec3(0.0), vec3(1.0));
}
vec4 dReflection;
vec3 dAlbedo;
vec3 dDiffuseLight;
vec3 dSpecularLight;
vec3 dSpecularity;
float dAlpha;
vec4 ccReflection;
vec3 ccSpecularLight;
#define AREA_LUTS_PRECISION highp
vec4 texture2DSRGB(sampler2D tex, vec2 uv) {
return texture2D(tex, uv);
}
vec4 texture2DSRGB(sampler2D tex, vec2 uv, float bias) {
return texture2D(tex, uv, bias);
}
vec4 textureCubeSRGB(samplerCube tex, vec3 uvw) {
return textureCube(tex, uvw);
}
vec3 gammaCorrectOutput(vec3 color) {
return color;
}
vec3 gammaCorrectInput(vec3 color) {
return color;
}
float gammaCorrectInput(float color) {
return color;
}
vec4 gammaCorrectInput(vec4 color) {
return color;
}
vec3 toneMap(vec3 color) {
return color;
}
float dBlendModeFogFactor = 1.0;
vec3 addFog(vec3 color) {
return color;
}
vec3 decodeLinear(vec4 raw) {
return raw.rgb;
}
vec3 decodeGamma(vec4 raw) {
return pow(raw.xyz, vec3(2.2));
}
vec3 decodeRGBM(vec4 raw) {
vec3 color = (8.0 * raw.a) * raw.rgb;
return color * color;
}
vec3 decodeRGBE(vec4 raw) {
if (raw.a == 0.0) {
return vec3(0.0, 0.0, 0.0);
}
else {
return raw.xyz * pow(2.0, raw.w * 255.0 - 128.0);
}
}
const float PI = 3.141592653589793;
vec2 toSpherical(vec3 dir) {
return vec2(dir.xz == vec2(0.0) ? 0.0 : atan(dir.x, dir.z), asin(dir.y));
}
vec2 toSphericalUv(vec3 dir) {
vec2 uv = toSpherical(dir) / vec2(PI * 2.0, PI) + 0.5;
return vec2(uv.x, 1.0 - uv.y);
}
// equirectangular helper functions
// envAtlas is fixed at 512 pixels. every equirect is generated with 1 pixel boundary.
const float atlasSize = 512.0;
const float seamSize = 1.0 / atlasSize;
// map a normalized equirect UV to the given rectangle (taking 1 pixel seam into account).
vec2 mapUv(vec2 uv, vec4 rect) {
return vec2(mix(rect.x + seamSize, rect.x + rect.z - seamSize, uv.x), mix(rect.y + seamSize, rect.y + rect.w - seamSize, uv.y));
}
// map a normalized equirect UV and roughness level to the correct atlas rect.
vec2 mapRoughnessUv(vec2 uv, float level) {
float t = 1.0 / exp2(level);
return mapUv(uv, vec4(0, 1.0 - t, t, t * 0.5));
}
//
vec2 mapMip(vec2 uv, float level) {
float t = 1.0 / exp2(level);
return mapUv(uv, vec4(1.0 - t, 1.0 - t, t, t * 0.5));
}
#undef MAPFLOAT
#undef MAPCOLOR
#define MAPCOLOR
#undef MAPVERTEX
#undef MAPTEXTURE
#ifdef MAPCOLOR
uniform vec3 material_diffuse;
#endif
#ifdef MAPTEXTURE
uniform sampler2D texture_diffuseMap;
#endif
void getAlbedo() {
dAlbedo = vec3(1.0);
#ifdef MAPCOLOR
dAlbedo *= material_diffuse.rgb;
#endif
#ifdef MAPTEXTURE
dAlbedo *= gammaCorrectInput(addAlbedoDetail(texture2D(texture_diffuseMap, UV).CH));
#endif
#ifdef MAPVERTEX
dAlbedo *= gammaCorrectInput(saturate(vVertexColor.VC));
#endif
}
#undef MAPFLOAT
#define MAPFLOAT
#undef MAPCOLOR
#undef MAPVERTEX
#undef MAPTEXTURE
#define MAPTEXTURE
#ifdef MAPFLOAT
uniform float material_opacity;
#endif
#ifdef MAPTEXTURE
uniform sampler2D texture_opacityMap;
#endif
void getOpacity() {
dAlpha = 1.0;
#ifdef MAPFLOAT
dAlpha *= material_opacity;
#endif
#ifdef MAPTEXTURE
dAlpha *= texture2D(texture_opacityMap, vUv0).a;
#endif
#ifdef MAPVERTEX
dAlpha *= clamp(vVertexColor.VC, 0.0, 1.0);
#endif
}
#undef MAPFLOAT
#undef MAPCOLOR
#define MAPCOLOR
#undef MAPVERTEX
#undef MAPTEXTURE
#define MAPTEXTURE
#ifdef MAPCOLOR
uniform vec3 material_emissive;
#endif
#ifdef MAPFLOAT
uniform float material_emissiveIntensity;
#endif
#ifdef MAPTEXTURE
uniform sampler2D texture_emissiveMap;
#endif
vec3 getEmission() {
vec3 emission = vec3(1.0);
#ifdef MAPFLOAT
emission *= material_emissiveIntensity;
#endif
#ifdef MAPCOLOR
emission *= material_emissive;
#endif
#ifdef MAPTEXTURE
emission *= texture2DSRGB(texture_emissiveMap, vUv0).rgb;
#endif
#ifdef MAPVERTEX
emission *= gammaCorrectInput(saturate(vVertexColor.VC));
#endif
return emission;
}
vec3 combineColor() {
return dAlbedo * dDiffuseLight;
}
void addAmbient() {
dDiffuseLight += light_globalAmbient;
}
void main(void) {
dDiffuseLight = vec3(0);
dSpecularLight = vec3(0);
dReflection = vec4(0);
dSpecularity = vec3(0);
#ifdef CLEARCOAT
ccSpecularLight = vec3(0);
ccReflection = vec4(0);
#endif
getOpacity();
getAlbedo();
addAmbient();
#ifdef CLEARCOAT
gl_FragColor.rgb = combineColorCC();
#else
gl_FragColor.rgb = combineColor();
#endif
gl_FragColor.rgb += getEmission();
gl_FragColor.rgb = addFog(gl_FragColor.rgb);
#ifndef HDR
gl_FragColor.rgb = toneMap(gl_FragColor.rgb);
gl_FragColor.rgb = gammaCorrectOutput(gl_FragColor.rgb);
#endif
gl_FragColor.rgb *= dAlpha;
gl_FragColor.a = dAlpha;
}
LeXXik
March 19, 2022, 9:57pm
#5
Not sure what’s the issue. But by looking at a glance, seems your custom getAlbedo
function is not used.