Jump to content

  • Log In with Google      Sign In   
  • Create Account

14 years ago on June 15th Gamedev.net was first launched! We want to thank all of you for being part of our community and hope the best years are ahead of us. Happy birthday Gamedev.net!

FrozenSnake

Member Since 07 Aug 2008
Offline Last Active May 16 2013 01:26 PM
-----

Topics I've Started

Pros and Cons with Specular and Diffuse lighting

04 May 2013 - 08:44 AM

First, I hope I post in the right forum for this question!

 

I am working on a shader in RenderMonkey and the shader is complete, so now I am writing a small report on the shader. My problem here is that I can't find any sources to read about pros and cons about "Specular light" and "Diffuse light". I have googled but I mainly find sources that is about what specular/diffuse light is, and these sources do not talk about the pros of each light model.

 

I have also checked in my course books to for some clues but I cannot find any. Do anyone here have any suggestion about where I can read about the pros and cons of these to light models? 

 

Best regards!


Problem with shader in RenderMonkey

20 April 2013 - 11:03 AM

I hope this is in the correct forum, since I am programming the shader I decided to put the topic in here. 

 

I have been working on a shader in RenderMonkey on my desktop computer, and when I transferred the rfx-file to my laptop to continue the work in school I get two error messages that I do not get at home.

 

OpenGL Preview Window: Linking program .. failure

The fragment shader uses varying uDiffuseColor, but previous shader does not write to it.
The fragment shader uses varying uOpacity, but previous shader does not write to it.

 

This is the Fragment program

// Ljus 1
uniform vec3  uLight1Position;
uniform float uLight1DiffIntent, Light1SpecIntent;
float uLight1RimIntent;


// Ljus 2
uniform vec3  uLight2Position;
uniform float uLight2DiffIntent, uLight2SpecIntent, uLight2RimIntent;

varying vec3 uLight1Color, uDiffuseColor, vColor, vNormal, vLightDir, vEyeVec;
varying float uLight1Intent, luminosity1, luminosity2, uLight1RimLight, uOpacity;
varying vec2 vTexCoord;

uniform sampler2D baseMap;

void main(void)
{
   vec3 N = normalize(vNormal);
   vec3 L = normalize(vLightDir);
   vec3 E = normalize(vEyeVec);
   vec3 H = normalize(-L + E);
   
   // Lambert Diffuse Lighting.
   float diffuse = clamp(dot(N, -L), 0.0, 1.0);

   // Blinn Specular
   float specular = pow(max(dot(N, H), 0.0), 120.0);
   //float diffuse = dot(N, -L);
   
   // Rim Lighting.
   float rimLight = smoothstep(0.5, 0.05, dot(N,E));// * (uLight1RimIntent + uLight2RimIntent);
   specular += rimLight;
   
   // Diffuse Attenuation
   specular *= diffuse;

   vec3 base = texture2D( baseMap, vTexCoord ).xyz;
   
   // Lägg till kantljus till den diffusa komponenten.
   //vec4 finalColor = vec4(diffuse + rimLight, rimLight, rimLight, uLight1Intent) / (length(uLight1Position) * 0.02);
   vec3 vColor = mix(uDiffuseColor.xyz, base, uOpacity);// diffuse + finalColor;
   vec4 finalColor = vec4(base * diffuse, 2.0);
   gl_FragColor = vec4(vColor * finalColor + rimLight, 0.5);
   //gl_FragColor = finalColor;
}

The Vertex Program

uniform vec3 uLight1Position;
uniform vec3 uLight2Position;
uniform vec3 uEyePosition;

varying vec3 vColor;
varying vec3 vLightDir;
varying vec3 vNormal;
varying vec3 vEyeVec, uOpacity, uDiffuseColor;
varying float uLight1Intent, luminosity1, luminosity2;
varying vec2 vTexCoord;

void main( void )
{ 
   vec3 N = normalize(vNormal);
   vec3 L = normalize(vLightDir);
   
   vec4 vertex = gl_ModelViewProjectionMatrix * gl_Vertex;
   gl_Position = vertex;
   
   uLight1Intent = distance(gl_Position.xyz, uLight1Position.xyz);
   //uLight1RimIntent = distance(gl_Position.xyz, uLight1Position.xyz);   
   luminosity1 = smoothstep(120, 0, uLight1Intent);
   
   vLightDir = -vec3(gl_ModelViewMatrix * vec4(uLight1Position, 0.0));
   vNormal = gl_NormalMatrix * gl_Normal;
   vEyeVec = -vec3(gl_ModelViewMatrix * gl_Vertex);
   vTexCoord = vec2(gl_MultiTexCoord0);
   //float diffuse = dot(N, -L) * luminosity1; 
   //vColor=vec3(diffuse,0.5,0.3);
}

I use the exact same rfx file (the exact same code) on the two different computers, I tried it in school as well and the same problem is there as well. We just started to work with hardware shaders so I dont know how rendermonkey work and why this is happening. It only work at home, all the files are the same on the different systems. Anyone that has any idea what I can try to get this to work?


Who to follow on Twitter?

13 November 2012 - 01:59 AM

I do not know where this post should be posted to be under the correct category so I decided to place it here and hope for the best!

I am a student at the university of Skövde in Sweden and I wish to follow some people on twitter that is relevant to my future line of work (game development). The type of people I want to follow are well known programmers, designers, artists, etc, so if anyone can help me find some of these people it would be great!

I hope you guys understand what I am asking for, my English is not the best one out here!
Best regards, Kim

[Beginner] DX11 Book example problem

18 July 2012 - 06:48 AM

Hi first of all, sorry for the "newb" thread!

I have problem with one of the examples from the book "Introduction to 3D Game Programming With DirectX 11". I just received the book and decided to test one of the examples so I can get follow the book without to many problems! So I picked one of the examples the book have. After I compile it and tries to run it this comes up: "Direct3D Feature Level 11 unsupported." and I do not know why this is coming up.

If anyone own the book it is the Chapter 19, Terrain demo I have tried. I checked in dxdiag and it say I have DirectX 11. So is there any way to find out why this error is coming up? Included the dxDiag.txt in case someone need the information to help me!

Best regards,
Kim

PARTNERS