Specular highlight moves as camera movesOpenGL object glossy/shiny in Mac OS X 10.6, but not 10.5. Why?Strange specular results from GLSL phong shaderSpecular lighting appears on both eye-facing and rear sides of objectSpecular highlights depend on camera distanceNot so smooth shadingOpenGL deferred rendering: point light implementationUniform value is wrong in adreno 305 qualcom device but right in Adreno ProfilerPhong implementation seems dark and also specular not working. Ray tracingWhy does my shader produce incorrect specular results? [DX11]Phong lighting: add specular lighting separately or with ambient and diffuse?
Can a UK national work as a paid shop assistant in the USA?
What weight should be given to writers groups critiques?
What would prevent living skin from being a good conductor for magic?
Is there any chance a man can get the death penalty for causing a miscarriage?
Why is the Eisenstein ideal paper so great?
How to politely tell someone they did not hit reply all in email?
Interpretation of ROC AUC score
Expected maximum number of unpaired socks
Why is unzipped directory exactly 4.0k (much smaller than zipped file)?
Why is this integration method not valid?
Why does the hash of infinity have the digits of π?
What did the 'turbo' button actually do?
Is my plasma cannon concept viable?
Are there any German nonsense poems (Jabberwocky)?
Final exams: What is the most common protocol for scheduling?
Does "was machen sie" have the greeting meaning of "what do you do"?
Python program for fibonacci sequence using a recursive function
How was Daenerys able to legitimise Gendry?
Do copyright notices need to be placed at the beginning of a file?
Why is 'additive' EQ more difficult to use than 'subtractive'?
Is superuser the same as root?
The disk image is 497GB smaller than the target device
What is the recommended procedure to land a taildragger in a crosswind?
Best shape for a necromancer's undead minions for battle?
Specular highlight moves as camera moves
OpenGL object glossy/shiny in Mac OS X 10.6, but not 10.5. Why?Strange specular results from GLSL phong shaderSpecular lighting appears on both eye-facing and rear sides of objectSpecular highlights depend on camera distanceNot so smooth shadingOpenGL deferred rendering: point light implementationUniform value is wrong in adreno 305 qualcom device but right in Adreno ProfilerPhong implementation seems dark and also specular not working. Ray tracingWhy does my shader produce incorrect specular results? [DX11]Phong lighting: add specular lighting separately or with ambient and diffuse?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I am implementing a specular highlight in OpenGL as part of the phong model. Currently, the highlight moves when my camera moves rather that getting brighter or dimmer which obviously isn't the expected result. I have followed the tutorial on learnopengl.com
#version 330 core
in vec3 outColor;
in vec3 outNormal;
in vec3 fragPos;
out vec4 FragColor;
uniform vec3 lightPos = vec3(-2.0f, 0.0f, 0.0f);
uniform vec3 lightColor = vec3(1.0, 0.5f, 1.0f);
uniform vec3 viewPos;
float ambientStrength = 0.2;
float specularStrength = 0.5;
uniform sampler2D tex;
void main()
vec3 normal = normalize(outNormal);
vec3 lightDir = normalize(lightPos - fragPos);
//ambient lighitng
vec3 ambient = ambientStrength * lightColor;
//diffuse lighting
float diffuseFactor = max(dot(normal, lightDir), 0.0);
vec3 diffuse = diffuseFactor * lightColor;
//specular lighting
vec3 viewDir = normalize(viewPos - fragPos);
vec3 reflectDir = reflect(-lightDir, normal);
float spec = pow(max(dot(viewDir, reflectDir), 0.0), 128);
vec3 specular = specularStrength * spec * lightColor;
vec3 result = (ambient + diffuse + specular) * outColor;
FragColor = vec4(result, 1.0f);// texture(tex, outTexCoords);// vec4(0.0f, 1.0f, 0.0f, 1.0f);
opengl glsl phong specular
add a comment |
I am implementing a specular highlight in OpenGL as part of the phong model. Currently, the highlight moves when my camera moves rather that getting brighter or dimmer which obviously isn't the expected result. I have followed the tutorial on learnopengl.com
#version 330 core
in vec3 outColor;
in vec3 outNormal;
in vec3 fragPos;
out vec4 FragColor;
uniform vec3 lightPos = vec3(-2.0f, 0.0f, 0.0f);
uniform vec3 lightColor = vec3(1.0, 0.5f, 1.0f);
uniform vec3 viewPos;
float ambientStrength = 0.2;
float specularStrength = 0.5;
uniform sampler2D tex;
void main()
vec3 normal = normalize(outNormal);
vec3 lightDir = normalize(lightPos - fragPos);
//ambient lighitng
vec3 ambient = ambientStrength * lightColor;
//diffuse lighting
float diffuseFactor = max(dot(normal, lightDir), 0.0);
vec3 diffuse = diffuseFactor * lightColor;
//specular lighting
vec3 viewDir = normalize(viewPos - fragPos);
vec3 reflectDir = reflect(-lightDir, normal);
float spec = pow(max(dot(viewDir, reflectDir), 0.0), 128);
vec3 specular = specularStrength * spec * lightColor;
vec3 result = (ambient + diffuse + specular) * outColor;
FragColor = vec4(result, 1.0f);// texture(tex, outTexCoords);// vec4(0.0f, 1.0f, 0.0f, 1.0f);
opengl glsl phong specular
2
Um, why isn't it the expected result?
– Nicol Bolas
Mar 23 at 22:40
Isn't it supposed to get brighter or dimmer, not move?
– Callum Perks
Mar 23 at 22:42
@NicolBolas Isn't it supposed to get brighter or dimmer, not move?
– Callum Perks
Mar 23 at 22:43
2
Well, if a center of the highlight moves, then there are positions on the surface where it gets brighter or darker. Just take any real object with a shiny surface and move around it. You will see that the highlights will move. This is what the Phong illumination model tries to mimic.
– Nico Schertler
Mar 23 at 23:44
add a comment |
I am implementing a specular highlight in OpenGL as part of the phong model. Currently, the highlight moves when my camera moves rather that getting brighter or dimmer which obviously isn't the expected result. I have followed the tutorial on learnopengl.com
#version 330 core
in vec3 outColor;
in vec3 outNormal;
in vec3 fragPos;
out vec4 FragColor;
uniform vec3 lightPos = vec3(-2.0f, 0.0f, 0.0f);
uniform vec3 lightColor = vec3(1.0, 0.5f, 1.0f);
uniform vec3 viewPos;
float ambientStrength = 0.2;
float specularStrength = 0.5;
uniform sampler2D tex;
void main()
vec3 normal = normalize(outNormal);
vec3 lightDir = normalize(lightPos - fragPos);
//ambient lighitng
vec3 ambient = ambientStrength * lightColor;
//diffuse lighting
float diffuseFactor = max(dot(normal, lightDir), 0.0);
vec3 diffuse = diffuseFactor * lightColor;
//specular lighting
vec3 viewDir = normalize(viewPos - fragPos);
vec3 reflectDir = reflect(-lightDir, normal);
float spec = pow(max(dot(viewDir, reflectDir), 0.0), 128);
vec3 specular = specularStrength * spec * lightColor;
vec3 result = (ambient + diffuse + specular) * outColor;
FragColor = vec4(result, 1.0f);// texture(tex, outTexCoords);// vec4(0.0f, 1.0f, 0.0f, 1.0f);
opengl glsl phong specular
I am implementing a specular highlight in OpenGL as part of the phong model. Currently, the highlight moves when my camera moves rather that getting brighter or dimmer which obviously isn't the expected result. I have followed the tutorial on learnopengl.com
#version 330 core
in vec3 outColor;
in vec3 outNormal;
in vec3 fragPos;
out vec4 FragColor;
uniform vec3 lightPos = vec3(-2.0f, 0.0f, 0.0f);
uniform vec3 lightColor = vec3(1.0, 0.5f, 1.0f);
uniform vec3 viewPos;
float ambientStrength = 0.2;
float specularStrength = 0.5;
uniform sampler2D tex;
void main()
vec3 normal = normalize(outNormal);
vec3 lightDir = normalize(lightPos - fragPos);
//ambient lighitng
vec3 ambient = ambientStrength * lightColor;
//diffuse lighting
float diffuseFactor = max(dot(normal, lightDir), 0.0);
vec3 diffuse = diffuseFactor * lightColor;
//specular lighting
vec3 viewDir = normalize(viewPos - fragPos);
vec3 reflectDir = reflect(-lightDir, normal);
float spec = pow(max(dot(viewDir, reflectDir), 0.0), 128);
vec3 specular = specularStrength * spec * lightColor;
vec3 result = (ambient + diffuse + specular) * outColor;
FragColor = vec4(result, 1.0f);// texture(tex, outTexCoords);// vec4(0.0f, 1.0f, 0.0f, 1.0f);
opengl glsl phong specular
opengl glsl phong specular
asked Mar 23 at 22:39
Callum PerksCallum Perks
84
84
2
Um, why isn't it the expected result?
– Nicol Bolas
Mar 23 at 22:40
Isn't it supposed to get brighter or dimmer, not move?
– Callum Perks
Mar 23 at 22:42
@NicolBolas Isn't it supposed to get brighter or dimmer, not move?
– Callum Perks
Mar 23 at 22:43
2
Well, if a center of the highlight moves, then there are positions on the surface where it gets brighter or darker. Just take any real object with a shiny surface and move around it. You will see that the highlights will move. This is what the Phong illumination model tries to mimic.
– Nico Schertler
Mar 23 at 23:44
add a comment |
2
Um, why isn't it the expected result?
– Nicol Bolas
Mar 23 at 22:40
Isn't it supposed to get brighter or dimmer, not move?
– Callum Perks
Mar 23 at 22:42
@NicolBolas Isn't it supposed to get brighter or dimmer, not move?
– Callum Perks
Mar 23 at 22:43
2
Well, if a center of the highlight moves, then there are positions on the surface where it gets brighter or darker. Just take any real object with a shiny surface and move around it. You will see that the highlights will move. This is what the Phong illumination model tries to mimic.
– Nico Schertler
Mar 23 at 23:44
2
2
Um, why isn't it the expected result?
– Nicol Bolas
Mar 23 at 22:40
Um, why isn't it the expected result?
– Nicol Bolas
Mar 23 at 22:40
Isn't it supposed to get brighter or dimmer, not move?
– Callum Perks
Mar 23 at 22:42
Isn't it supposed to get brighter or dimmer, not move?
– Callum Perks
Mar 23 at 22:42
@NicolBolas Isn't it supposed to get brighter or dimmer, not move?
– Callum Perks
Mar 23 at 22:43
@NicolBolas Isn't it supposed to get brighter or dimmer, not move?
– Callum Perks
Mar 23 at 22:43
2
2
Well, if a center of the highlight moves, then there are positions on the surface where it gets brighter or darker. Just take any real object with a shiny surface and move around it. You will see that the highlights will move. This is what the Phong illumination model tries to mimic.
– Nico Schertler
Mar 23 at 23:44
Well, if a center of the highlight moves, then there are positions on the surface where it gets brighter or darker. Just take any real object with a shiny surface and move around it. You will see that the highlights will move. This is what the Phong illumination model tries to mimic.
– Nico Schertler
Mar 23 at 23:44
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55319042%2fspecular-highlight-moves-as-camera-moves%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55319042%2fspecular-highlight-moves-as-camera-moves%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
Um, why isn't it the expected result?
– Nicol Bolas
Mar 23 at 22:40
Isn't it supposed to get brighter or dimmer, not move?
– Callum Perks
Mar 23 at 22:42
@NicolBolas Isn't it supposed to get brighter or dimmer, not move?
– Callum Perks
Mar 23 at 22:43
2
Well, if a center of the highlight moves, then there are positions on the surface where it gets brighter or darker. Just take any real object with a shiny surface and move around it. You will see that the highlights will move. This is what the Phong illumination model tries to mimic.
– Nico Schertler
Mar 23 at 23:44