Gamestudio Links
Zorro Links
Newest Posts
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
Data from CSV not parsed correctly
by jcl. 04/20/24 08:32
Zorro FIX plugin - Experimental
by jcl. 04/20/24 08:30
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
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
2 registered members (7th_zorro, 1 invisible), 581 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
[SOLVED] chrome shader by ello in Shade-C evo #466930
07/09/17 13:36
07/09/17 13:36
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline OP
Serious User
Reconnoiter  Offline OP
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
Hello,

I am trying to get the chrome shader by ello (found in Massive 3DGS Shadercollection lite c) working in my shade-c project, but I get this error when running it;



Below is the function + material + shader code. Does anyone have a quess what the problem could be? Tnx!

Code:
BMAP* chrome_lookup = "tex_chrome_lookup.tga";

MATERIAL* mtl_chrome = {
	skin1 = chrome_lookup;
	effect = "chrome.fx";
}

action testChrome() {
	my.material = mtl_chrome;
	my.skill41 = floatv(random(2)-1);	//r
	my.skill42 = floatv(random(2)-1);	//g
	my.skill43 = floatv(random(2)-1);	//b
	my.skill44 = floatv(1.5);	//specular power
	mtl_chrome.skill1 = floatv(1);	//reflectmap scale
}



And the fx / shader code:

Code:
/////////////////////////////////////////////
/////////Chrome Shader by ello///////////////
/////////www.earthcontrol.de/////////////////
/////////////////////////////////////////////


float4x4 matWorldViewProj;
float4x4 matWorldInv;
float4x4 matWorldView;
float4x4 matWorld;

float4x4 matViewInv;
float4x4 matView;
float4 vecSkill41;
float4 mtlSkill1;
float4 vecSunDir;

float4 vecFog;

float DoFog(float3 Pos)
{
	// convert the vector position to view space to get it's depth (.z)
	float3 P = mul(Pos,matWorldView);
	// apply the linear fog formula
	return saturate((vecFog.y-P.z) * vecFog.z);
}

void mainVS(
in 	float4 inPos 	: POSITION,
in 	float3 inNormal: NORMAL,
in		float2 inXY		: TEXCOORD0,
out	float4 Pos 		: POSITION,
out 	float2 chrome		: TEXCOORD0,
out 	float2 uv		: TEXCOORD1,
out	float oNrm : COLOR0,
out	float  Fog		: FOG
)
{
	// transform the vector position to screen coordinates
	Pos = mul(inPos,matWorldViewProj);
	// rotate and normalize the normal
	float3 N = normalize(mul(inNormal,matWorldInv));
	// Add fog
	Fog = DoFog(inPos);
	// convert texture coordinates or do other stuff
	oNrm = mul(inNormal,matWorld); //pass normal
	chrome=mul(N,matView)*mtlSkill1.x; //mtlSkill1 contains the scale of the reflMap
	uv = inXY;
}

texture mtlSkin1;
sampler basemap = sampler_state 
{
	texture=(mtlSkin1);
	MipFilter = LINEAR;
	MinFilter = LINEAR;
	MagFilter = LINEAR;
	//AddressU = Mirror;
	//Addressv = Mirror;
};

texture entSkin1;
sampler entskin = sampler_state 
{
	texture=(entSkin1);
	MipFilter = LINEAR;
	MinFilter = LINEAR;
	MagFilter = LINEAR;
};


float4 mainPS(
in		float2 chrome		: TEXCOORD0,
in		float2 uv		: TEXCOORD1,
in	float iNrm : COLOR0
) : COLOR
{
	//change shinyness where "2" stands , play around whith it till it fits your needs
	//skill41-43 contains rgb values, skill44 contains power value
	float4 result=0.5*dot(tex2D(basemap,chrome),vecSkill41.w)-0.5; 
	//change the "2" below to adjust the shyniness, too
	result*=result/2+float4(vecSkill41.xyz,1)*tex2D(basemap,chrome); 
	float sunL = 0.5*dot(iNrm,-vecSunDir)+0.5; //sunLight

	//return (result-sunL+tex2D(entskin,uv))*pow(sunL,2); //dark metallic, mixed with entSkin1
	return (result+tex2D(entskin,uv))*sunL; //standard, mixed with entSkin1
}

technique better_looking_chrome
{
	pass base
	{
		//CullMode = none;
		VertexShader=compile vs_2_0 mainVS();
		PixelShader=compile ps_2_0 mainPS();
	}
}

technique fallback_chrome
{
	pass base
	{
		//CullMode = none;
		VertexShader=compile vs_1_1 mainVS();
		PixelShader=compile ps_1_4 mainPS();
	}
}


Last edited by Reconnoiter; 07/10/17 15:10.
Re: chrome shader by ello in Shade-C evo [Re: Reconnoiter] #466931
07/09/17 17:36
07/09/17 17:36
Joined: Oct 2008
Posts: 681
Germany
Ayumi Offline
User
Ayumi  Offline
User

Joined: Oct 2008
Posts: 681
Germany
Try run fx in the work folder, not projects folder. Maybe there are a problem with include.

Re: chrome shader by ello in Shade-C evo [Re: Ayumi] #466946
07/10/17 10:29
07/10/17 10: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
Hi ty for replying. I suspect that the culprit is that I include the shade-c header/stuff, cause it works in a non-shadec project. Though it seems that deactivating shade-c is not enough, its am not entirely sure but my quess is that shade-c scripts that I include change some stuff (light or fog related or such, or maybe something skill related).

What I find odd however is that when I comment stuff out in the chrome.fx file, the error line stays exactly the same (with the same line 47, 15). Maybe I am reading this wrong?

Re: chrome shader by ello in Shade-C evo [Re: Reconnoiter] #466948
07/10/17 11:33
07/10/17 11:33
Joined: Oct 2008
Posts: 681
Germany
Ayumi Offline
User
Ayumi  Offline
User

Joined: Oct 2008
Posts: 681
Germany
Be sure, there are no other "chrome.fx" data.
(another includes)

Re: chrome shader by ello in Shade-C evo [Re: Ayumi] #466950
07/10/17 15:10
07/10/17 15: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
Originally Posted By: Ayumi
Be sure, there are no other "chrome.fx" data.
(another includes)
, genius laugh it was indeed a name problem, I couldn't find a chrome.fx when searching in the (sub)folders but I changed the material name too and it works now.


Moderated by  Blink, Hummel, Superku 

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