Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
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
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, SBGuy, Petra), 801 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: Spotlight vs. Dynamic light [Re: Random] #412153
11/23/12 13:28
11/23/12 13:28
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
I tried to you point lights, but I got some problems.. Here are the screens:
Quote:
One:

Two:
Looks like point lights are too weak or something?? I used large lightrange, as you can see on debug screen.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Spotlight vs. Dynamic light [Re: Random] #412154
11/23/12 13:29
11/23/12 13:29
Joined: Feb 2010
Posts: 320
TANA/Madagascar
3dgs_snake Offline
Senior Member
3dgs_snake  Offline
Senior Member

Joined: Feb 2010
Posts: 320
TANA/Madagascar
grin It still suports light but darker. Just 0.02 by something else (As I said, I'm not a shader expert grin ).

Re: Spotlight vs. Dynamic light [Re: 3dgs_snake] #412155
11/23/12 13:40
11/23/12 13:40
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Code:
#define SpotlightArc  10.0f 			// Spotlight-Cone-Arc,  ~(180 / Angle)^2   ||   4 = 90°;  16 = 45°
#define SpotlightArc2  9.0f 			// == SpotlightArc - 1

//Variables
float4x4 matWorld;
float4x4 matWorldViewProj;

float4 vecFog;
float4 vecTime;
float4 vecColor;
float4 vecViewDir;
float4 vecViewPos;
float4 vecSunDir;
float4 vecSunColor;
float4 vecLight;
float4 vecLightPos[8];
float4 vecLightDir[8];
float4 vecLightColor[8];
float fAlpha;
float fAmbient;


//Textures
texture entSkin1;


//Sampler
sampler colorMap = sampler_state
{
	Texture = (entSkin1);
	AddressU = Wrap;
	AddressV = Wrap;
	
	MagFilter = Linear;
	MinFilter = Linear;
	MipFilter = Linear;
};

//Structs
struct VS_TO_PS // Output to the pixelshader
{
	float4 Pos	: POSITION;
	float  Fog	: FOG;
	
	float2 Tex0	: TEXCOORD0;
	float3 WPos	: TEXCOORD1;
	float3 Norm	: TEXCOORD2;
};


//Vertexshader
VS_TO_PS VS_v0(	float4 inPos		: POSITION,
float3 inNormal	: NORMAL,
float2 inTex0		: TEXCOORD0	)
{
	VS_TO_PS Out;
	
	//Do transformations
	Out.Pos = mul(inPos,matWorldViewProj);
	
	//Pass the Texcoords
	Out.Tex0 = inTex0;
	
	//Vertexposition in worldspace
	Out.WPos = mul(inPos,matWorld);
	
	//Vertexnormal
	Out.Norm = normalize(mul(inNormal,matWorld));
	
	//Fog
	Out.Fog = 1 - (distance(Out.WPos,vecViewPos)-vecFog.x) * vecFog.z;
	
	return Out;
}


//Pixelshader
float4 PS_p0( VS_TO_PS In ) : COLOR
{
	float3 LightDir;
	float3 Diffuse = fAmbient+saturate(dot(-vecSunDir,In.Norm))*vecSunColor;
	float attenuation = 0;
	
	for(int i = 0; i < 8; i++)
	{
		LightDir = normalize(vecLightPos[i] - In.WPos);
		attenuation = saturate(1.0f - length(LightDir/vecLightPos[i].w));
		
		if(vecLightDir[i].w > 0) // Spotlight?
			attenuation = saturate(attenuation * dot(-normalize(vecLightDir[i].xyz), LightDir) * SpotlightArc - SpotlightArc2);
		
		Diffuse += saturate(dot(normalize(LightDir),In.Norm))*vecLightColor[i]*attenuation;
	}
	
	float4 Color = tex2D(colorMap,In.Tex0);
	Color.rgb *= Diffuse;
	
	Color.a = step(0.5,Color.a);
	
	return Color;
}


//////////////////////////////////////////////////////////////////
technique Lighting
{
	pass one
	{
		AlphaTestEnable = True;
		zWriteEnable = true;
		
		VertexShader = compile vs_3_0 VS_v0();
		PixelShader = compile ps_3_0 PS_p0();
	}
}

technique fallback { pass one { } }


This version of the shader uses entity.ambient as ambient brightness only (and supports now 8 lights).
This should work for making things darker wink

@3run did you set the *entity.red green and blue high enough?
This controlls the light color and brightness.

EDIT: * I mean the entity which you're using as pointlight.

EDIT#2: I've tested it, the pointlight works fine, I guess you left the entity.red / green / blue at default.

Last edited by Kartoffel; 11/23/12 13:49.

POTATO-MAN saves the day! - Random
Re: Spotlight vs. Dynamic light [Re: Kartoffel] #412165
11/23/12 14:49
11/23/12 14:49
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
I've created it like this:
Code:
// Point light:
you = ent_create("box.mdl", vector(0, 0, 5), NULL);
you.lightrange = 100;
vec_fill(you.blue, 250);

Problem still remains, see pictures above. I can upload a demo laugh


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Spotlight vs. Dynamic light [Re: 3run] #412167
11/23/12 15:12
11/23/12 15:12
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
well if it isn't the light color, then the light is too near to the surface.


POTATO-MAN saves the day! - Random
Re: Spotlight vs. Dynamic light [Re: Kartoffel] #412169
11/23/12 15:24
11/23/12 15:24
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
ups grin my bad, thank you again laugh


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Spotlight vs. Dynamic light [Re: 3run] #412170
11/23/12 15:25
11/23/12 15:25
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
no problem grin
let me know if theres somthing else I can help you with.


POTATO-MAN saves the day! - Random
Re: Spotlight vs. Dynamic light [Re: Random] #412197
11/23/12 20:03
11/23/12 20:03
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Originally Posted By: Random
Potato-man saves the day!

haha, I've got to use that as my new signature grin


POTATO-MAN saves the day! - Random
Re: Spotlight vs. Dynamic light [Re: Kartoffel] #412252
11/24/12 16:51
11/24/12 16:51
Joined: Feb 2010
Posts: 886
Random Offline
User
Random  Offline
User

Joined: Feb 2010
Posts: 886
hahaha ^^



Re: Spotlight vs. Dynamic light [Re: Random] #412315
11/25/12 17:17
11/25/12 17:17
Joined: Feb 2010
Posts: 886
Random Offline
User
Random  Offline
User

Joined: Feb 2010
Posts: 886
Kartoffel, this is a little code pice by "grafton" from aum 71:

Code:
BMAP* projectiontex = "Spotlight1.jpg";

VECTOR temp_vec;  

function mtlProjection_event()  
{
	float pTexAdj[16] = { 0.5, 0.0, 0.0, 0.0, 0.0,-0.5,	0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 }; 
	pTexAdj[12] = 0.5 + (0.5/(float)bmap_width(projectiontex));
	pTexAdj[13] = 0.5 + (0.5/(float)bmap_height(projectiontex));
	mat_set(Levelgeometrie_bump.matrix,matViewProj);	 
	mat_multiply(Levelgeometrie_bump.matrix,pTexAdj);  
}

MATERIAL* mtlProjView =               
{
effect = " technique DepthTechnique { pass p0 {	}}";  
	event = mtlProjection_event;  
	flags = ENABLE_VIEW;		        
}

VIEW* ProjectionView =             
{
	material = mtlProjView;
	flags = VISIBLE;	
}

function initstages_startup()
{
	ProjectionView.stage = camera; 
}



I was wondering if I could attach an projection texture (from the spotlight) to your shader with this. But it didn`t work.

Do you know why it didn`t work?



Page 2 of 2 1 2

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