Jump to content

Rim lightening


YouGroove
 Share

Recommended Posts

Not tested but give it a shot :

 

in vertex shader add :

 

out vec3 eye;

 

Find :

vec4 modelvertexposition = entitymatrix_ * vec4(vertex_position,1.0);

 

After add :

eye = normalize( modelvertexposition.xyz - cameraposition );

 

In fragment shader :

 

Add :

in vec3 eye;

 

after all normal calculations add :

 

//calculate rim
float NormalToCam = 1.0 - abs(dot(eye*cameranormalmatrix,normal));
float rim = smoothstep(0.0, 1.0, NormalToCam); //adjust here for rim thickness

 

Find :

 

fragData0 = ...

 

After add :

fragData0+=vec4(rim,rim,rim,0);

  • Upvote 1

HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB

Link to comment
Share on other sites

I tried but it failed.

In fact it's modifying diffuse shader ? Will that work with animated diffuse shader ?

 

after all normal calculations add :

Where it is ? seems last lines in fragment ?

 

 

Find :

 

fragData0 = ...

 

After add :

fragData0+=vec4(rim,rim,rim,0);

The problem is this is before normal map calculation.

Stop toying and make games

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...