本文整理汇总了C++中ofShader::setUniform1f方法的典型用法代码示例。如果您正苦于以下问题:C++ ofShader::setUniform1f方法的具体用法?C++ ofShader::setUniform1f怎么用?C++ ofShader::setUniform1f使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofShader
的用法示例。
在下文中一共展示了ofShader::setUniform1f方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw
void draw(){
wc.begin();
if(!switchVideo){
wc.setUniformTexture("colorMap", img.getTexture(), 1);
wc.setUniformTexture("heightMap",gray.getTexture(), 2);
}
else{
wc.setUniformTexture("colorMap", player.getTexture(), 1);
fboDepth.begin();
player.draw(0,0);
fboDepth.end();
wc.setUniformTexture("heightMap",fboDepth.getDepthTexture(),2);
}
wc.setUniform1f("time", ofGetElapsedTimef()*time);
wc.setUniform1f("gradientStep", stepGradient);
wc.setUniform1f("advectStep", advectStep);
wc.setUniform1f("flipHeightMap",flipHeightMap);
wc.setUniform4f("advectMatrix",advectMatrix->w,advectMatrix->x,advectMatrix->y,advectMatrix->z);
fbo.draw(0,0);
wc.end();
img.draw(0,0,img.getWidth()/4,img.getHeight()/4);
player.draw(img.getWidth()/4,0,img.getWidth()/4,img.getHeight()/4);
gui.draw();
}
示例2: draw
void SPECTRUM_INDICATOR__TYPE_CIRCLE::draw(ofShader& shader, float *spectrum)
{
shader.setUniform1f( "DispTextureSize", IndicatorTextureSize ); // 描画サイズ
shader.setUniform1f( "texture_VerticalSpaceRatio", IndicatorVerticalSpace_ratio );
/********************
********************/
for(int LineId = SIZE_S; LineId < NUM_INDICATORS; LineId++){
shader.setUniform4f("BaseColor", IndicatorColor[LineId]);
ofPushMatrix();
ofTranslate(ofGetWidth()/2, ofGetHeight()/2);
ofRotate(BaseAngle[LineId]);
float spectrum_out = spectrum[NUM_DISP_SPECTRUMS/2 - 1];
// same pattern繰り返しで、同軸方向に突き抜けるイメージ
for(int i = 0; i < 2; i++){
for(int i = 0; i < NUM_DISP_SPECTRUMS/2; i++){
spectrum_out = FreqFilter_k * spectrum[i] + (1 - FreqFilter_k) * spectrum_out;
ofRotate(IndicatorAngleStep); // Loopで積算されていくので、"i * IndicatorAngleStep" としないように!!!!!
vbo_drawLine( ofVec3f(0, -radius[LineId], 0), ofVec3f(0, -radius[LineId] - MaxLightHeight[LineId] * spectrum_out, 0) );
}
}
ofPopMatrix();
}
}
示例3: onParticlesUpdate
// set any update uniforms in this function
void testApp::onParticlesUpdate(ofShader& shader)
{
ofVec3f mouse(ofGetMouseX() - .5f * ofGetWidth(), .5f * ofGetHeight() - ofGetMouseY() , 0.f);
shader.setUniform3fv("mouse", mouse.getPtr());
shader.setUniform1f("elapsed", ofGetLastFrameTime());
shader.setUniform1f("radiusSquared", 1000.f * 1000.f);
}
示例4: draw
//--------------------------------------------------------------
void testApp::draw(){
ofEnableLighting();
light.enable();
if(rotating) t++;
fbo.begin();
glColor4f(1, 1, 1, 1);
ofClear(0, 0, 0, 0);
glPushMatrix();
glScalef(2, 2, 2);
glTranslatef(ofGetWidth()/2, ofGetHeight()/2, 0);
glRotatef(t, 0, 1, 1);
/*glBegin(GL_QUADS);
glVertex2f(-100, -100);
glVertex2f(100, -100);
glVertex2f(100, 100);
glVertex2f(-100, 100);
glEnd();*/
ofBox(0, 0, 0, 100);
glPopMatrix();
fbo.end();
ofDisableLighting();
if(shading) {
fxaa.begin();
fxaa.setUniformTexture("bgl_RenderedTexture", fbo.getTextureReference(0), 0);
fxaa.setUniform1f("bgl_RenderedTextureWidth", fbo.getWidth());
fxaa.setUniform1f("bgl_RenderedTextureHeight", fbo.getHeight());
} else {
fbo.getTextureReference(0).bind();
}
glBegin(GL_QUADS);
glTexCoord2f(0, 0);
glVertex2f(0, 0);
glTexCoord2f(fbo.getWidth(), 0);
glVertex2f(ofGetWidth(), 0);
glTexCoord2f(fbo.getWidth(), fbo.getHeight());
glVertex2f(ofGetWidth(), ofGetHeight());
glTexCoord2f(0, fbo.getHeight());
glVertex2f(0, ofGetHeight());
glEnd();
if(shading) {
fxaa.end();
} else {
fbo.getTextureReference(0).unbind();
}
}
示例5: updateLights
void ofMaterial::updateLights(const ofShader & shader,ofGLProgrammableRenderer & renderer) const{
for(size_t i=0;i<ofLightsData().size();i++){
string idx = ofToString(i);
shared_ptr<ofLight::Data> light = ofLightsData()[i].lock();
if(!light || !light->isEnabled){
shader.setUniform1f("lights["+idx+"].enabled",0);
continue;
}
auto lightEyePosition = renderer.getCurrentViewMatrix() * light->position;
shader.setUniform1f("lights["+idx+"].enabled",1);
shader.setUniform1f("lights["+idx+"].type", light->lightType);
shader.setUniform4f("lights["+idx+"].position", lightEyePosition);
shader.setUniform4f("lights["+idx+"].ambient", light->ambientColor);
shader.setUniform4f("lights["+idx+"].specular", light->specularColor);
shader.setUniform4f("lights["+idx+"].diffuse", light->diffuseColor);
if(light->lightType!=OF_LIGHT_DIRECTIONAL){
shader.setUniform1f("lights["+idx+"].constantAttenuation", light->attenuation_constant);
shader.setUniform1f("lights["+idx+"].linearAttenuation", light->attenuation_linear);
shader.setUniform1f("lights["+idx+"].quadraticAttenuation", light->attenuation_quadratic);
}
if(light->lightType==OF_LIGHT_SPOT){
auto direction = toGlm(light->position).xyz() + light->direction;
auto direction4 = renderer.getCurrentViewMatrix() * glm::vec4(direction,1.0);
direction = direction4.xyz() / direction4.w;
direction = direction - lightEyePosition.xyz();
shader.setUniform3f("lights["+idx+"].spotDirection", glm::normalize(direction));
shader.setUniform1f("lights["+idx+"].spotExponent", light->exponent);
shader.setUniform1f("lights["+idx+"].spotCutoff", light->spotCutOff);
shader.setUniform1f("lights["+idx+"].spotCosCutoff", cos(ofDegToRad(light->spotCutOff)));
}else if(light->lightType==OF_LIGHT_DIRECTIONAL){
auto halfVector = glm::normalize(glm::vec4(0.f, 0.f, 1.f, 0.f) + lightEyePosition);
shader.setUniform3f("lights["+idx+"].halfVector", halfVector.xyz());
}else if(light->lightType==OF_LIGHT_AREA){
shader.setUniform1f("lights["+idx+"].width", light->width);
shader.setUniform1f("lights["+idx+"].height", light->height);
auto direction = light->position.xyz() + light->direction;
auto direction4 = renderer.getCurrentViewMatrix() * glm::vec4(direction, 1.0);
direction = direction4.xyz() / direction4.w;
direction = direction - lightEyePosition.xyz();
shader.setUniform3f("lights["+idx+"].spotDirection", glm::normalize(direction));
auto right = toGlm(light->position).xyz() + light->right;
auto right4 = renderer.getCurrentViewMatrix() * glm::vec4(right, 1.0);
right = right4.xyz() / right4.w;
right = right - lightEyePosition.xyz();
auto up = glm::cross(toGlm(right), direction);
shader.setUniform3f("lights["+idx+"].right", glm::normalize(toGlm(right)));
shader.setUniform3f("lights["+idx+"].up", glm::normalize(up));
}
}
}
示例6: onParticlesUpdate
void ofApp::onParticlesUpdate(ofShader& shader)
{
float flip = 1.0;
if (flipParticles) {
flip = -1.0;
}
//ofVec3f mouse(ofGetMouseX() - .5f * ofGetWidth(), .5f * ofGetHeight() - ofGetMouseY() , 0.f);
ofVec3f mouse((mc.x - .5f * ofGetWidth()) * flip, .5f * ofGetHeight() - mc.y, 0.f);
ofVec3f ext1(mc.x - .5f * ofGetWidth(), .5f * ofGetHeight() - mc.y , 0.f);
shader.setUniform3fv("mouse", mouse.getPtr());
shader.setUniform1f("elapsed", ofGetLastFrameTime());
shader.setUniform1f("radiusSquared", 300.f * 300.f);
}
示例7: updateMaterial
void ofMaterial::updateMaterial(const ofShader & shader,ofGLProgrammableRenderer & renderer) const{
shader.setUniform4fv("mat_ambient", &data.ambient.r);
shader.setUniform4fv("mat_diffuse", &data.diffuse.r);
shader.setUniform4fv("mat_specular", &data.specular.r);
shader.setUniform4fv("mat_emissive", &data.emissive.r);
shader.setUniform4fv("global_ambient", &ofGetGlobalAmbientColor().r);
shader.setUniform1f("mat_shininess",data.shininess);
}
示例8: updateMaterial
void ofMaterial::updateMaterial(const ofShader & shader,ofGLProgrammableRenderer & renderer) const{
shader.setUniform4fv("mat_ambient", &data.ambient.r);
shader.setUniform4fv("mat_diffuse", &data.diffuse.r);
shader.setUniform4fv("mat_specular", &data.specular.r);
shader.setUniform4fv("mat_emissive", &data.emissive.r);
shader.setUniform4fv("global_ambient", &ofGetGlobalAmbientColor().r);
shader.setUniform1f("mat_shininess",data.shininess);
for(auto & uniform: uniforms1f){
shader.setUniform1f(uniform.first, uniform.second);
}
for (auto & uniform : uniforms2f) {
shader.setUniform2f(uniform.first, uniform.second);
}
for (auto & uniform : uniforms3f) {
shader.setUniform3f(uniform.first, uniform.second);
}
for (auto & uniform : uniforms4f) {
shader.setUniform4f(uniform.first, uniform.second);
}
for (auto & uniform : uniforms1i) {
shader.setUniform1i(uniform.first, uniform.second);
}
for (auto & uniform : uniforms2i) {
shader.setUniform2i(uniform.first, uniform.second.x, uniform.second.y);
}
for (auto & uniform : uniforms3i) {
shader.setUniform3i(uniform.first, uniform.second.x, uniform.second.y, uniform.second.z);
}
for (auto & uniform : uniforms4i) {
shader.setUniform4i(uniform.first, uniform.second.x, uniform.second.y, uniform.second.z, uniform.second.w);
}
for (auto & uniform : uniforms4m) {
shader.setUniformMatrix4f(uniform.first, uniform.second);
}
for (auto & uniform : uniforms3m) {
shader.setUniformMatrix3f(uniform.first, uniform.second);
}
for (auto & uniform : uniformstex) {
shader.setUniformTexture(uniform.first,
uniform.second.textureTarget,
uniform.second.textureID,
uniform.second.textureLocation);
}
}
示例9: draw
//--------------------------------------------------------------
void DataSet::draw(ofShader & shader)
{
static const auto kLatitudeMin = -HALF_PI;
static const auto kLatitudeMax = HALF_PI;
static const auto kLongitudeMin = 0;
static const auto kLongitudeMax = TWO_PI;
shader.setUniform1f("uCutRadius", ofMap(parameters.cutRadius, 0.0f, 1.0f, this->minRadius, this->maxRadius));
shader.setUniform1f("uMinRadius", ofMap(parameters.minRadius, 0.0f, 1.0f, this->minRadius, this->maxRadius));
shader.setUniform1f("uMaxRadius", ofMap(parameters.maxRadius, 0.0f, 1.0f, this->minRadius, this->maxRadius));
shader.setUniform1f("uMinLatitude", ofMap(parameters.minLatitude, 0.0f, 1.0f, kLatitudeMin, kLatitudeMax));
shader.setUniform1f("uMaxLatitude", ofMap(parameters.maxLatitude, 0.0f, 1.0f, kLatitudeMin, kLatitudeMax));
shader.setUniform1f("uMinLongitude", ofMap(parameters.minLongitude, 0.0f, 1.0f, kLongitudeMin, kLongitudeMax));
shader.setUniform1f("uMaxLongitude", ofMap(parameters.maxLongitude, 0.0f, 1.0f, kLongitudeMin, kLongitudeMax));
ofSetColor(this->parameters.color.get());
this->vbo.draw(GL_POINTS, 0, this->coordinates.size());
}
示例10: begin
//--------------------------------------------------------------- ACTIONS
void CloudsRGBDVideoPlayer::begin(ofShader& shader){
if(playingVO){
return;
}
if(!getPlayer().isLoaded() ){
return;
}
if(!getTextureReference().isAllocated()){
return;
}
getPlayer().bind();
shader.setUniformTexture("rgbdTexture", getTextureReference(), 1);
shader.setUniform2f("textureSize", getPlayer().getWidth(), getPlayer().getHeight());
shader.setUniform4f("colorRect", colorRect.x, colorRect.y, colorRect.width, colorRect.height);
shader.setUniform2f("colorScale", colorScale.x, colorScale.y);
shader.setUniform2f("colorFOV", colorFOV.x, colorFOV.y );
shader.setUniform2f("colorPP", colorPrincipalPoint.x, colorPrincipalPoint.y);
shader.setUniform3f("dK", distortionK.x, distortionK.y, distortionK.z);
shader.setUniform2f("dP", distortionP.x, distortionP.y);
ofMatrix4x4 adjustmentMatrix;
adjustmentMatrix.rotate(adjustRotate.x, 0, 1, 0);
adjustmentMatrix.rotate(adjustRotate.y, 1, 0, 0);
adjustmentMatrix.translate(adjustTranslate.x, adjustTranslate.y, adjustTranslate.z);
shader.setUniformMatrix4f("extrinsics", extrinsics * adjustmentMatrix );
shader.setUniform4f("depthRect", depthRect.x, depthRect.y, depthRect.width, depthRect.height);
shader.setUniform2f("depthPP", depthPrincipalPoint.x, depthPrincipalPoint.y);
shader.setUniform2f("depthFOV", depthFOV.x, depthFOV.y);
shader.setUniform4f("normalRect", normalRect.x, normalRect.y, normalRect.width, normalRect.height);
shader.setUniform4f("faceFeatureRect", faceFeatureRect.x, faceFeatureRect.y, faceFeatureRect.width, faceFeatureRect.height);
shader.setUniform4f("deltaChangeRect", deltaChangeRect.x, deltaChangeRect.y, deltaChangeRect.width, deltaChangeRect.height);
shader.setUniform1f("farClip", farClip);
shader.setUniform1f("nearClip", nearClip);
shader.setUniform1f("edgeClip", edgeClip);
shader.setUniform1f("minDepth", minDepth);
shader.setUniform1f("maxDepth", maxDepth);
shader.setUniform3f("skinSampleColor",skinSampleColor.r,skinSampleColor.g,skinSampleColor.b);
shader.setUniform3f("skinWeights", skinWeights.x,skinWeights.y,skinWeights.z);
shader.setUniform2f("skinThreshold", skinThreshold.min, skinThreshold.max);
shader.setUniform3f("headPosition",headPosition.x,-headPosition.y,headPosition.z);
shader.setUniform1f("flowPosition", flowPosition);
}
示例11: draw
void draw() {
ofBackgroundGradient(64, 0);
if(reflect || sreflect)
env.draw(0,0,env.getWidth()/8,env.getHeight()/8);
if(sreflect)
env1.draw(env.getWidth()/8,0,env1.getWidth()/8,env1.getHeight()/8);
ofEnableDepthTest();
cam.begin();
shader.begin();
if(sreflect){
// shader.setUniform3f("CameraPos",cam.getGlobalPosition().x, cam.getGlobalPosition().y, cam.getGlobalPosition().z);
// shader.setUniformMatrix4f("ModelWorld4x4",cam.getGlobalTransformMatrix());
shader.setUniform3f("CameraPos",cam.getPosition().x, cam.getPosition().y, cam.getPosition().z);
shader.setUniformMatrix4f("ModelWorld4x4",cam.getModelViewMatrix());//getLocalTransformMatrix());
shader.setUniformTexture("frontMap", env,1);
shader.setUniformTexture("backMap", env1,2);
}
if(reflect){
shader.setUniformTexture("colorMap",env1,1);
shader.setUniformTexture("envMap", env,2);
}else if(sreflect==false){
shader.setUniformTexture("texture", img, 1);
shader.setUniform1f("time", ofGetElapsedTimef());
}
if(cube)
ofDrawBox(200);
else {
ofTranslate(0,-150,0);
ofRotateX(-90);
ofRotateY(-90);
ofRotateZ(45);
model.drawFaces();
}
shader.end();
cam.end();
ofDisableDepthTest();
ofDrawBitmapString(ofToString((int) ofGetFrameRate()), 10, 20);
}
示例12: draw
void draw() {
ofBackground(25);
fbo.begin();
ofClear(0,0,0,0);
ofEnableDepthTest();
camera.begin();
glPushMatrix();
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0);
if(dvel) draw_velocity();
if(dden){
draw_density();
}
glDisable(GL_BLEND);
glDisable(GL_ALPHA_TEST);
glPopMatrix();
if( drawAxis ){ ofDrawAxis(15); }
camera.end();
ofDisableDepthTest();
fbo.end();
shader.begin();
shader.setUniformTexture("tex",fbo.getTextureReference(),0);
shader.setUniform2f("resolution",dw,dh);
shader.setUniform1f("timer",ofGetElapsedTimef());
fbo.draw(0,0);
shader.end();
gui.draw();
}
示例13: setupProjectionUniforms
//--------------------------------------------------------------- ACTIONS
void CloudsRGBDVideoPlayer::setupProjectionUniforms(ofShader& shader){
if(!getPlayer().isLoaded()){
ofLogWarning() << " CloudsRGBDVideoPlayer::setupProjectionUniforms -- player is not ready";
return;
}
shader.setUniformTexture("rgbdTexture", getPlayer().getTextureReference(), 0);
shader.setUniform2f("textureSize", getPlayer().getWidth(), getPlayer().getHeight());
shader.setUniform4f("colorRect", colorRect.x, colorRect.y, colorRect.width, colorRect.height);
shader.setUniform2f("colorScale", colorScale.x, colorScale.y);
shader.setUniform2f("colorFOV", colorFOV.x, colorFOV.y );
shader.setUniform2f("colorPP", colorPrincipalPoint.x, colorPrincipalPoint.y);
shader.setUniform3f("dK", distortionK.x, distortionK.y, distortionK.z);
shader.setUniform2f("dP", distortionP.x, distortionP.y);
ofMatrix4x4 adjustmentMatrix;
adjustmentMatrix.rotate(adjustRotate.x, 0, 1, 0);
adjustmentMatrix.rotate(adjustRotate.y, 1, 0, 0);
adjustmentMatrix.translate(adjustTranslate.x, adjustTranslate.y, adjustTranslate.z);
shader.setUniformMatrix4f("extrinsics", extrinsics * adjustmentMatrix );
shader.setUniform4f("depthRect", depthRect.x, depthRect.y, depthRect.width, depthRect.height);
shader.setUniform2f("depthPP", depthPrincipalPoint.x, depthPrincipalPoint.y);
shader.setUniform2f("depthFOV", depthFOV.x, depthFOV.y);
shader.setUniform4f("normalRect", normalRect.x, normalRect.y, normalRect.width, normalRect.height);
shader.setUniform4f("faceFeatureRect", faceFeatureRect.x, faceFeatureRect.y, faceFeatureRect.width, faceFeatureRect.height);
shader.setUniform4f("deltaChangeRect", deltaChangeRect.x, deltaChangeRect.y, deltaChangeRect.width, deltaChangeRect.height);
shader.setUniform1i("useFaces", useFaces ? 1 : 0);
shader.setUniform1f("flowPosition", flowPosition);
shader.setUniform1f("farClip", farClip);
shader.setUniform1f("nearClip", nearClip);
shader.setUniform1f("edgeClip", edgeClip);
shader.setUniform1f("minDepth", minDepth);
shader.setUniform1f("maxDepth", maxDepth);
}
开发者ID:CLOUDS-Interactive-Documentary,项目名称:VisualSystemsLibrary,代码行数:45,代码来源:CloudsRGBDVideoPlayer.cpp
示例14: updateRenderer
void Dude::updateRenderer( ofShader & shader )
{
// update the rendering matrices
renderMats = animSys.getBoneMatrices();
std::vector<float> boneLengths = animSys.getBoneLengths();
for( int i = 0; i < animSys.getNumBones(); i++ )
{
renderMats[i].scale(1,1,boneLengths[i]);
//renderMats[i].preTranslate(position);
renderMats[i].invert();
}
// prepare rendering steer matrix
renderSteerMatrix.identity();
renderSteerMatrix.translate(position);
renderSteerMatrix *= steerMatrix;
//renderSteerMatrix.translate(-position);
// set it up
shader.setUniformMatrix4f("steerMatrix",ofMatrix4x4((float*)renderSteerMatrix.inverse()));
shader.setUniform1f("blend_k",blend_k);
shader.setUniformMatrix4f("box_mats", (ofMatrix4x4&) renderMats[0], renderMats.size());//
}