Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am trying to create a texture of elliptical dots but it isn't#version 3 3 0 compatibility out vec 4 FragColor; / / lighting uniform

I am trying to create a texture of elliptical dots but it isn't#version 330 compatibility
out vec4 FragColor;
// lighting uniform variables -- these can be set once and left alone:
uniform float uKa, uKd, uKs; // coefficients of each type of lighting -- make sum to 1.0
uniform vec4 uColor; // object color
uniform vec4 uSpecularColor; // light color
uniform float uShininess; // specular exponent
// ellipse parameters:
uniform float uAd, uBd, uTol;
// in variables from the vertex shader and interpolated in the rasterizer:
in vec3 vN; // normal vector
in vec3 vL; // vector from point to light
in vec3 vE; // vector from point to eye
in vec2 vST; //(s,t) texture coordinates
void main()
{
float s = vST.s;
float t = vST.t;
// determine the color using the ellipse equation:
float ellipseResult =(pow((s - uAd),2.0)/ pow(uAd,2.0))+(pow((t - uBd),2.0)/ pow(uBd,2.0));
float blendFactor = smoothstep(1.- uTol, 1.+ uTol, ellipseResult);
vec3 myColor = mix(uColor.rgb, vec3(0.8,0.6,1.0), blendFactor); // lilac
// apply the per-fragment lighting to myColor:
vec3 Normal = normalize(vN);
vec3 Light = normalize(vL);
vec3 Eye = normalize(vE);
vec3 ambient = uKa * myColor;
float dd = max(dot(Normal, Light),1.); // only do diffuse if the light can see the point
vec3 diffuse = uKd * dd * myColor;
float ss =0.5;
if (dot(Normal, Light)>.1)// only do specular if the light can see the point
{
vec3 ref = normalize(reflect(-Light, Normal));
ss = pow(max(dot(Eye, ref),0.), uShininess);
}
vec3 specular = uKs * ss * uSpecularColor.rgb;
FragColor = vec4(myColor,1.0);
}
working. what should it look like?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions