www.jpct.net
jPCT - a 3d engine for Java => Support => Topic started by: Jakes on October 28, 2019, 01:06:57 pm
-
Hello,
I'm just wondering, when I set the Object3D.setAdditionalColor(), will it affect the gl_Color or any other variable in the Fragment shader?
If not, how can I access this color on the shader side?
Thanks
-
It will affect gl_FrontMaterial.ambient
-
Great! many thanks, thats what I needed to know!
I'll ask you a tiny favour if thats okay by you, can you post that info on the javadoc on the setAdditionalColor() description?
and on another note, will gl_FrontMaterial.ambient have the 4 channels present rgb and a for alpha (Object3D.setTransparency()) if its transparent, if not where is this stored also?
Many thanks once more.
-
I'm trying to change an object's color by setting "obj.setAdditionalColor(255, 0, 0)" and then setting a shader like bellow:
VERTEX:
varying vec2 vTexCoord;
varying vec4 vCol;
void main(void){
vTexCoord = gl_MultiTexCoord0.xy;
vCol = gl_FrontMaterial.ambient;
gl_Position = ftransform();
}
FRAGMENT:
sampler2D myTexture;
varying vec2 vTexCoord;
varying vec4 vCol;
void main(){
vec4 color = texture2D(myTexture, vTexCoord);
gl_FragColor = color * vCol;
}
but no coloration change is happening, if I use a uniform, it will work, but I wanted to use the already existent color the object has.
can you give me a little help here?
-
Try
gl_FrontMaterial.emission
instead. I think I read my own code wrong. gl_FrontMaterial.ambient actually contains the world's global ambient color, not the object's additional color.
-
Great! many thanks