Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, TedMar, dr_panther), 1,049 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Moar lights for bump.fx? #347495
11/15/10 17:38
11/15/10 17:38
Joined: Apr 2005
Posts: 4,506
Germany
F
fogman Offline OP
Expert
fogman  Offline OP
Expert
F

Joined: Apr 2005
Posts: 4,506
Germany
Hola,

I´m very close to the first release of :schutzkontakt.
Close means not more than a week.

I´m using the normalmapping shader bump.fx that comes with gamestudio. This shader supports up to three dynamic lights.
However, three lights are too less because the player needs a flashlight.

Currently it´s a fast hack but it works surprisingly well - except for that ugly flickering that occurs whenever there are four lights in action.

I would like to have four lights supported, this should really be enough. I´ve already tried to add a fourth light, no luck so far, as I got no shader background.
Also I don´t really get the include / default.fx stuff.
Theoretically it should be easy to add another light, but I need some entry point.

So does anyone has an idea where I could start?



no science involved
Re: Moar lights for bump.fx? [Re: fogman] #347497
11/15/10 17:45
11/15/10 17:45
Joined: Aug 2009
Posts: 1,438
Spain
painkiller Offline
Serious User
painkiller  Offline
Serious User

Joined: Aug 2009
Posts: 1,438
Spain
in the wiki there is a normal mapping shader which supports up to 6 lights, but I suppose it slower than bump.fx http://www.opserver.de/wiki/index.php/Normalmapping_Shader


3D Gamestudio A8 Pro
AMD FX 8350 4.00 Ghz
16GB RAM
Gigabyte GeForce GTX 960 4GB
Re: Moar lights for bump.fx? [Re: painkiller] #347503
11/15/10 18:22
11/15/10 18:22
Joined: Nov 2008
Posts: 946
T
the_clown Offline
User
the_clown  Offline
User
T

Joined: Nov 2008
Posts: 946
Hmm, this shader wont work for level blocks I guess?

EDIT: Tried. It gives me very ugly artifacts. Dunno if it's the shader or the usage for level blocks, gonna try it with models later.

Last edited by the_clown; 11/15/10 18:23.
Re: Moar lights for bump.fx? [Re: fogman] #351965
12/30/10 11:46
12/30/10 11:46
Joined: Apr 2005
Posts: 4,506
Germany
F
fogman Offline OP
Expert
fogman  Offline OP
Expert
F

Joined: Apr 2005
Posts: 4,506
Germany
Still no luck...
So - I would even pay some bucks for an enhanced version.


no science involved
Re: Moar lights for bump.fx? [Re: fogman] #353321
01/09/11 12:56
01/09/11 12:56
Joined: Jan 2007
Posts: 651
Germany
R
RedPhoenix Offline
User
RedPhoenix  Offline
User
R

Joined: Jan 2007
Posts: 651
Germany
Code:
// Lambert bump mapping
// (c) oP group 2008  Version 2.1
//edited by redphoenix 01.11 -> supporting 4 lights on shader version 3

#include <define>
#include <transform>
#include <fog>
#include <pos>
#include <normal>
#include <tangent>
#include <lights>
#include <color>


#include <phong>

texture entSkin1;	// texture
texture entSkin2;	// normal map or lightmap
texture entSkin3;	// normal map on blocks

sampler sBaseTex = sampler_state { Texture = <entSkin1>; MipFilter = Linear;	};
sampler sSkin2 = sampler_state { Texture = <entSkin2>; MipFilter = None;	};
sampler sSkin3 = sampler_state { Texture = <entSkin3>; MipFilter = None;	};


struct bumpOut
{
	float4 Pos: POSITION;
	float  Fog:	FOG;
	//float4 Ambient:  COLOR0;
	float4 Tex12:    TEXCOORD0;	
	//float3 PosView:  TEXCOORD1;
	float3 Light1:	 TEXCOORD1;	
	float3 Light2:	 TEXCOORD2;
	float3 Light3:	 TEXCOORD3;	
	float3 Light4:	 TEXCOORD4;	
	float3 Diffuse1: TEXCOORD5;		
	float3 Diffuse2: TEXCOORD6;		
	float3 Diffuse3: TEXCOORD7;		
	float3 Diffuse4: TEXCOORD8;		
};

bumpOut bump_VS(vertexIn In)
{
	bumpOut Out;

	Out.Pos	= DoTransform(In.Pos);
	Out.Tex12 = float4(In.Tex1,In.Tex2);
	Out.Fog	= DoFog(In.Pos);
	//Out.Ambient = DoAmbient();	

	CreateTangents(In.Normal,In.Tangent);
   float3 PosWorld = DoPos(In.Pos).xyz;
	//Out.PosView = DoTangent(vecViewPos-PosWorld);
	Out.Light1 = DoTangent(vecLightPos[0].xyz-PosWorld);
	Out.Light2 = DoTangent(vecLightPos[1].xyz-PosWorld);
	Out.Light3 = DoTangent(vecLightPos[2].xyz-PosWorld);
	Out.Light4 = DoTangent(vecLightPos[3].xyz-PosWorld);
	
  float3 Normal = DoNormal(In.Normal);
	Out.Diffuse1 = DoLightFactorBump(vecLightPos[0],PosWorld,Normal) * vecLightColor[0].xyz;
	Out.Diffuse2 = DoLightFactorBump(vecLightPos[1],PosWorld,Normal) * vecLightColor[1].xyz;
	Out.Diffuse3 = DoLightFactorBump(vecLightPos[2],PosWorld,Normal) * vecLightColor[2].xyz;
	Out.Diffuse4 = DoLightFactorBump(vecLightPos[3],PosWorld,Normal) * vecLightColor[3].xyz;
	
	return Out;		
}

float3 DoDiffuse(bumpOut In,float3 Normal)
{
	float3 Diffuse = In.Diffuse1 * saturate(dot(normalize(In.Light1.xyz),Normal));
	Diffuse += In.Diffuse2 * saturate(dot(normalize(In.Light2.xyz),Normal));
	Diffuse += In.Diffuse3 * saturate(dot(normalize(In.Light3.xyz),Normal));
	Diffuse += In.Diffuse4 * saturate(dot(normalize(In.Light4.xyz),Normal));
	return Diffuse * vecDiffuse.xyz;
}

float4 diffuseBump_PS(bumpOut In): COLOR
{
	float4 myambient = (vecAmbient * vecLight) + float4(vecEmissive.xyz*vecColor.xyz,vecLight.w);
	float4 Base = tex2D(sBaseTex,In.Tex12.xy);
	float3 Normalmap = tex2D(sSkin2,In.Tex12.xy).rgb*2-1;
   float3 Diffuse = DoDiffuse(In,Normalmap);	
	return Base * DoColor(Diffuse,myambient);
}

float4 diffuseBumpLM_PS(bumpOut In): COLOR
{
	float4 myambient = (vecAmbient * vecLight) + float4(vecEmissive.xyz*vecColor.xyz,vecLight.w);
	float4 Base = tex2D(sBaseTex,In.Tex12.xy);
	float4 Lightmap = tex2D(sSkin2,In.Tex12.zw);
	float3 Normalmap = tex2D(sSkin3,In.Tex12.xy).rgb*2-1;
   float3 Diffuse = DoDiffuse(In,Normalmap);	
	return Base * DoLightmap(Diffuse,Lightmap,myambient);
}

technique bump
{
	pass one
	{		
		VertexShader = compile vs_3_0 bump_VS();
		PixelShader = compile ps_3_0 diffuseBump_PS();
	}
}

technique bump_lm
{
	pass one
	{		
		VertexShader = compile vs_3_0 bump_VS();
		PixelShader = compile ps_3_0 diffuseBumpLM_PS();
	}
}

technique fallback { pass one { } }



Re: Moar lights for bump.fx? [Re: RedPhoenix] #353358
01/09/11 17:56
01/09/11 17:56
Joined: Apr 2005
Posts: 4,506
Germany
F
fogman Offline OP
Expert
fogman  Offline OP
Expert
F

Joined: Apr 2005
Posts: 4,506
Germany
Thank you very much again.


no science involved

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