Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 677 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
can't tint model red cause of shader #447931
01/13/15 15:17
01/13/15 15:17
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline OP
Serious User
Reconnoiter  Offline OP
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
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

Re: can't tint model red cause of shader [Re: Reconnoiter] #447933
01/13/15 16:01
01/13/15 16:01
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
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.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: can't tint model red cause of shader [Re: Reconnoiter] #447934
01/13/15 16:01
01/13/15 16:01
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
you need to add to the shader to handle it, i.e. multiply e.g its diffuse by vecLight


Free world editor for 3D Gamestudio: MapBuilder Editor
Re: can't tint model red cause of shader [Re: 3run] #447936
01/13/15 16:17
01/13/15 16:17
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
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


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: can't tint model red cause of shader [Re: 3run] #447938
01/13/15 17:10
01/13/15 17:10
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline OP
Serious User
Reconnoiter  Offline OP
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
Thanks for the comments, going to try it out

Re: can't tint model red cause of shader [Re: Reconnoiter] #447941
01/13/15 18:19
01/13/15 18:19
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline OP
Serious User
Reconnoiter  Offline OP
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
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.

Re: can't tint model red cause of shader [Re: Reconnoiter] #447943
01/13/15 18:34
01/13/15 18:34
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
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

Last edited by MasterQ32; 01/13/15 19:25.

Visit my site: www.masterq32.de
Re: can't tint model red cause of shader [Re: MasterQ32] #447954
01/14/15 08:12
01/14/15 08:12
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
I think vecLight also includes PRV, so I use mainly it instead of vecColor


Free world editor for 3D Gamestudio: MapBuilder Editor
Re: can't tint model red cause of shader [Re: sivan] #447957
01/14/15 14:29
01/14/15 14:29
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline OP
Serious User
Reconnoiter  Offline OP
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
Thanks guys, *vecColor works great.


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1