can't tint model red cause of shader

Posted By: Reconnoiter

can't tint model red cause of shader - 01/13/15 15:17

Hi there,

I have a model that has 3 textures and one of those is a normal map. For 1 texture I want it to use the normal map through a shader, so I go to MED and check the 'Effect Setup' and 'Extern' boxes and load the right normal map shader.

So far so good. But at a specific moment, I want to tint the model red through the LIGHT flag and vec_set(my.blue, vector(0, 0, 255)); . But this only tinted the part of the model that does not use the normal map shader. How to fix this so that the whole model get tinted red?

I tried setting an other material for the model (e.g. mtl_model or default_shader) but that does not work. Any ideas?

Tnx in advance
Posted By: 3run

Re: can't tint model red cause of shader - 01/13/15 16:01

Actually resetting the material and then changing colours should work, cause that's why I've been using to do for years grin Maybe something is about the normal map.. I'll try to do some tests on my side.
Posted By: sivan

Re: can't tint model red cause of shader - 01/13/15 16:01

you need to add to the shader to handle it, i.e. multiply e.g its diffuse by vecLight
Posted By: 3run

Re: can't tint model red cause of shader - 01/13/15 16:17

Originally Posted By: 3run
I'll try to do some tests on my side.
The easiest way to handle this without shader stuff, is to reset the material to 'mtl_model' and then change colors, just as I've thought. And it's working, probably you've made some kind of a mistake on your side.

Here is a working script (you'll need 'box.mdl' from 'shadertest' project in Acknex's root folder):
Code:
#include <acknex.h>
#include <default.c>

#include <mtlFX.c>

void main(){
	level_load("");
	wait(3);
	sun_light = 100;

	vec_set(camera.x, vector(117, 224, 74));
	vec_set(camera.pan, vector(240, -18, 0));

	ENTITY* ent = ent_create("box.mdl", nullvector, NULL);
	ent.material = mtl_specBump;

	while(1){
		sun_angle.pan += 5 * time_step;
		sun_angle.tilt += 5 * time_step;
		draw_text("press space to turn into devil cube!", 10, 10, COLOR_WHITE);
		if(key_space){break;}

		wait(1);
	}

	ent.material = mtl_model;
	set(ent, LIGHT | UNLIT); // UNLIT here is to make it's color more visible
	vec_set(ent.blue, COLOR_RED);

	while(!key_enter){
		draw_text("press enter to turn into normal cube!", 10, 10, COLOR_WHITE);
		wait(1);
	}
	reset(ent, LIGHT | UNLIT);
	vec_set(ent.blue, COLOR_GREY);
	ent.material = mtl_specBump;


	while(1){
		sun_angle.pan += 5 * time_step;
		sun_angle.tilt += 5 * time_step;

		wait(1);
	}
}

You maybe could play with 'emissive' colours of the shader, but that will make all other entities with that material red.

Greets
Posted By: Reconnoiter

Re: can't tint model red cause of shader - 01/13/15 17:10

Thanks for the comments, going to try it out
Posted By: Reconnoiter

Re: can't tint model red cause of shader - 01/13/15 18:19

I only have this bug when using MED to set a shader to an individual skin. And my.material = mtl_model; only resets the mesh part that does not have the normal map shader.

ps: the normal map shader I am testing with is from the shader tutorial.
Posted By: MasterQ32

Re: can't tint model red cause of shader - 01/13/15 18:34

just append a

Code:
*vecColor


to your diffuse textur sampling in the shader and declare vecColor as a float4 shader variable.

There you go

PS.: Could be vecLight as well, can't remember it right tongue
Posted By: sivan

Re: can't tint model red cause of shader - 01/14/15 08:12

I think vecLight also includes PRV, so I use mainly it instead of vecColor
Posted By: Reconnoiter

Re: can't tint model red cause of shader - 01/14/15 14:29

Thanks guys, *vecColor works great.
© 2024 lite-C Forums