Quantcast
Channel: Forum Pasja Informatyki - Najnowsze pytania bez odpowiedzi
Viewing all articles
Browse latest Browse all 21942

Obiekt staje się jaśniejszy gdy się oddalam

$
0
0

Cześć. Napisałem takiego shadera:

#version 330 core

in vec2 texture_coordinates;

uniform sampler2D basic_texture;
uniform vec3 ambientColor;
uniform vec3 borderColour;
uniform int alphaFactor;
uniform vec4 colour;

uniform mat4 view_matrix;

out vec4 frag_colour;

uniform int colorTextures;
in vec3 vertexToCamera;
in vec3 normalToCamera;

vec3 lightPosition = vec3(0.0, 30.0, 0.0);
vec3 distanceToLight;
vec3 lightDirection;

vec3 specularColor = vec3(1.0, 1.0, 1.0);

void textures()
{
	vec3 lightPostion = vec3(3.0, 0.0, 1.0);

	vec3 diffuseColor = vec3(1.0, 1.0, 1.0);
	vec3 spectularColor = vec3(1.0, 1.0, 1.0);

	vec3 ambientFactor = vec3(1.0, 1.0, 1.0);
	vec3 diffuseFactor = vec3(0.5, 0.5, 0.5);
	vec3 spectularFactor = vec3(1.0, 1.0, 1.0);

	vec3 ambientIntense = ambientColor * ambientFactor;
	//**********************************************************
	
	distanceToLight = vec3(view_matrix * vec4(lightPosition, 1.0)) - vertexToCamera;
	lightDirection = normalize(distanceToLight);
	float dotProduct = dot(lightDirection, normalToCamera);	
	dotProduct = max(dotProduct, 0.0);
	
	vec3 diffuseIntense = diffuseColor * vec3(0.5, 0.5, 0.5) * dotProduct;
	
	//**********************************************************
	/*
	vec3 reflection = reflect(-lightDirection, normalToCamera);
	vec3 surfaceToCamera = normalize(-vertexToCamera);
	float dotSpecular = dot(reflection, surfaceToCamera);
	dotSpecular = max(dotSpecular, 0.0);
	float specularPower = 10.0;
	float specularFactor = pow(dotSpecular, specularPower);
	vec3 specularIntense = specularColor * specularFactor; 
	*/
	//**********************************************************
	vec4 texel = texture(basic_texture, texture_coordinates);
	
	if(colorTextures == 1)
	{
		frag_colour = vec4(ambientIntense + diffuseIntense, 1.0) * texel * colour;
	}
	else
	{
		frag_colour = vec4(ambientIntense + diffuseIntense, 1.0) * colour;
	}
}

void main()
{
	textures();
}

I obiekty stają się jaśniejsze gdy oddalam się od krzyża który jest na środku mojej mapy. Chciałem aby obiekty były jako tako cieniowane, ale nic takiego się nie dzieje. Do uniformów chyba nieważne co przesyłam.


Viewing all articles
Browse latest Browse all 21942

Trending Articles


Sprawdź z którą postacią z anime dzielisz urodziny


MDM - Muzyka Dla Miasta (2009)


Częstotliwość 3.722MHz


POSZUKIWANY TOMASZ SKOWRON-ANGLIA


Ciasto 3 Bit


Kasowanie inspekcji Hyundai ix35


Steel Division 2 SPOLSZCZENIE


SZCZOTKOWANIE TWARZY NA SUCHO


Potrzebuje schemat budowy silnika YX140


Musierowicz Małgorzata - Kwiat kalafiora [audiobook PL]